Skip to main content

Telegraf

Introduction​

The Telegraf agent collects metrics and computes statuses on the servers it monitors, and sends them to Centreon. Centreon's OpenTelemetry processor allows it to understand data sent in OpenTelemetry format.

Developed by InfluxDB, the Telegraf agent can be installed on Windows or Linux servers. Centreon Engine is able to send the configuration of monitored resources to the agent (existing hosts, thresholds...), so that the agent can execute checks and compute the statuses of these resources.

As they are Nagios-based, both Centreon and custom plugins are compatible with the agent. This is because Centreon's Telegraf integration is based on the native Nagios input data format.

Limitations​

Due to Telegraf or Centreon constraints, the following limitations need to be considered.

  • Due to Telegraf limitations, the configuration of resources known to the agent is only updated when you start or reload the agent (typically, you would do that after deploying the configuration). Technically, the agent requests an up-to-date configuration from Centreon.
  • Only known metrics (i.e., the metrics for the hosts and services created in Centreon) are sent to Centreon. Metrics for unknown hosts or services are discarded.
  • Only metrics and statuses are returned (no outputs).
  • Network connections are one-way only: data goes from the agent to the poller. This means that a host in a DMZ will need a poller in this DMZ.
  • When an enhancement or fix is released, the Centreon plugin must be re-deployed on your monitored host (there is no auto-update).

Step 1: Configure Centreon​

Install the Monitoring Connector​

  1. On your central server, go to Configuration > Monitoring Connector Manager.
  2. Install the Linux Telegraf Agent monitoring connector.

Create the Telegraf connector​

Install the Open Telemetry processor for Telegraf on your central server:

  1. Go to Configuration > Commands > Connectors.
  2. Create a new connector with the following values:
ParameterValue
Connector NameTelegraf
Connector DescriptionTelegraf
Command Lineopentelemetry --processor=nagios_telegraf --extractor=attributes --host_path=resource_metrics.scope_metrics.data.data_points.attributes.host --service_path=resource_metrics.scope_metrics.data.data_points.attributes.service
Used by commandType Telegraf-Agent and click Select all
Connector StatusEnabled

Configure Engine​

  1. On the poller that will receive the data from the agent, create the following file:

    touch /etc/centreon-engine/otl_server.json
  2. Enter the following contents. This will allow the poller to receive the data that the agent will send.

{
"otel_server": {
"host": "0.0.0.0",
"port": 4317,
"encryption": false
},
"max_length_grpc_log": 0,
"telegraf_conf_server": {
"http_server": {
"port": 1080,
"encryption": false
},
"telegraf_conf": {
"interval": "60s",
}
}
}
  • The interval field is the frequency of checks performed by Telegraf, and should be set to 60 seconds as it is the frequency of Engine checks.

For the sake of simplicity, this page only covers the configuration of Telegraf without encryption. You may find how to secure the communications in the Linux Telegraf Agent and Windows Telegraf Agent pages.

Add a new Broker module​

  1. Go to Configuration > Pollers > Engine configuration, then click on the poller you want to monitor your resources.

  2. On the Data tab, in the Broker module section, in the Multiple Broker Module parameter, click on Add a new entry.

  3. Add the following entry :

    /usr/lib64/centreon-engine/libopentelemetry.so /etc/centreon-engine/otl_server.json
  4. Export the configuration

  5. Restart the monitoring engine

    systemctl restart centengine

The Telegraf agent is now able to communicate with Centreon. You can set up the monitoring of your hosts.

Step 2: Prepare the host​

Download and install the agent​

dnf -y install epel-release
dnf -y config-manager --set-enabled 'powertools'

This part is an excerpt from Telegraf's official documentation.

cat > /etc/yum.repos.d/influxdb.repo <<'EOF'
[influxdb]
name = InfluxData Repository - Stable
baseurl = https://repos.influxdata.com/stable/$basearch/main
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdata-archive_compat.key
EOF
dnf install -y telegraf

Then:

  1. Stop the Telegraf service
systemctl stop telegraf
  1. Edit the telegraf.service file.
vi /etc/systemd/system/telegraf.service
  1. Replace:
/usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d $TELEGRAF_OPTS

By (replace the placeholders by your values):

/usr/bin/telegraf -config http(s)://<ip poller>:<port poller>/engine?host=<host to monitor>
  1. Start the Telegraf service:
systemctl start telegraf

Deploy the Centreon plugin​

The Centreon plugin will execute the checks on the host.

Enable our plugins repository and install the plugin​

This repository will provide you our packaged plugins as well as the dependencies that are not available in the standard distribution repositories.

cat >/etc/yum.repos.d/centreon-plugins.repo <<'EOF'
[centreon-plugins-stable]
name=Centreon plugins repository.
baseurl=https://packages.centreon.com/rpm-plugins/el8/stable/$basearch/
enabled=1
gpgcheck=1
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES
module_hotfixes=1

[centreon-plugins-stable-noarch]
name=Centreon plugins repository.
baseurl=https://packages.centreon.com/rpm-plugins/el8/stable/noarch/
enabled=1
gpgcheck=1
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES
module_hotfixes=1

[centreon-plugins-testing]
name=Centreon plugins repository. (UNSUPPORTED)
baseurl=https://packages.centreon.com/rpm-plugins/el8/testing/$basearch/
enabled=0
gpgcheck=1
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES
module_hotfixes=1

[centreon-plugins-testing-noarch]
name=Centreon plugins repository. (UNSUPPORTED)
baseurl=https://packages.centreon.com/rpm-plugins/el8/testing/noarch/
enabled=0
gpgcheck=1
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES
module_hotfixes=1

[centreon-plugins-unstable]
name=Centreon plugins repository. (UNSUPPORTED)
baseurl=https://packages.centreon.com/rpm-plugins/el8/unstable/$basearch/
enabled=0
gpgcheck=1
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES
module_hotfixes=1

[centreon-plugins-unstable-noarch]
name=Centreon plugins repository. (UNSUPPORTED)
baseurl=https://packages.centreon.com/rpm-plugins/el8/unstable/noarch/
enabled=0
gpgcheck=1
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES
module_hotfixes=1
EOF

Install the plugin:

dnf install -y centreon-plugin-Operatingsystems-Linux-Local.noarch

Step 3: Monitoring a host with the Telegraf agent​

Create hosts using templates​

On the central server, create hosts and apply to them the OS-Linux-Telegraf-Agent-custom template.

Reload the agent​

To let the agent know about the hosts you just created and start monitoring them, run the following command on the host:

systemctl restart telegraf