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​
- Linux
- Windows
Create the Telegraf connector​
Install the Open Telemetry processor for Telegraf on your central server:
- Go to Configuration > Commands > Connectors.
- Create a new connector with the following values:
Parameter | Value |
---|---|
Connector Name | Telegraf |
Connector Description | Telegraf |
Command Line | opentelemetry --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 command | Type Telegraf-Agent and click Select all |
Connector Status | Enabled |
Configure Engine​
On the poller that will receive the data from the agent, create the following file:
touch /etc/centreon-engine/otl_server.json
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​
Go to Configuration > Pollers > Engine configuration, then click on the poller you want to monitor your resources.
On the Data tab, in the Broker module section, in the Multiple Broker Module parameter, click on Add a new entry.
Add the following entry :
/usr/lib64/centreon-engine/libopentelemetry.so /etc/centreon-engine/otl_server.json
Export the configuration
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​
- Linux
- Windows
- Alma / RHEL / Oracle Linux 8
- Alma / RHEL / Oracle Linux 9
- Debian 11 & 12
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:
- Stop the Telegraf service
systemctl stop telegraf
- Edit the telegraf.service file.
vi /etc/systemd/system/telegraf.service
- 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>
- Start the Telegraf service:
systemctl start telegraf
dnf -y install epel-release
dnf -y config-manager --set-enabled 'crb'
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:
- Stop the Telegraf service
systemctl stop telegraf
- Edit the telegraf.service file.
vi /etc/systemd/system/telegraf.service
- 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>
- Start the Telegraf service:
systemctl start telegraf
This part is an excerpt from Telegraf's official documentation.
wget -q https://repos.influxdata.com/influxdata-archive_compat.key -O influxdata-archive_compat.key
echo '393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c influxdata-archive_compat.key' | sha256sum -c && cat influxdata-archive_compat.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null
echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list
apt-get update
apt-get -y install telegraf
You must then configure the Telegraf OpenTelemetry output. You must uncomment this paragraph or recreate a configuration file with just the following lines:
# [[outputs.opentelemetry]]
# ## Override the default (localhost:4317) OpenTelemetry gRPC service
# ## address:port
# # service_address = "localhost:4317"
#
# ## Override the default (5s) request timeout
# # timeout = "5s"
#
# ## Optional TLS Config.
# ##
# ## Root certificates for verifying server certificates encoded in PEM format.
# # tls_ca = "/etc/telegraf/ca.pem"
# ## The public and private keypairs for the client encoded in PEM format.
# ## May contain intermediate certificates.
# # tls_cert = "/etc/telegraf/cert.pem"
# # tls_key = "/etc/telegraf/key.pem"
# ## Use TLS, but skip TLS chain and host verification.
# # insecure_skip_verify = false
# ## Send the specified TLS server name via SNI.
# # tls_server_name = "foo.example.com"
If the communication between Telegraf and the poller is not encrypted, you just have to enter the IP address and port of the poller in the service_address option (port entered in the otel_server field in the poller’s configuration). If not, you will also need to provide a value for at least tls_ca.
Now you need to add the Telegraf configuration server provided by the poller. You must create the */etc/default/telegraf file and add the following line:
TELEGRAF_OPTS=-config https://<ip poller>:<http_server port>/engine? host=<host_to_monitor>
The arguments of this command will allow Telegraf to know where to get the configuration of the resources it must monitor (that is to say on the poller or on the central server following the IP address defined in the command). The parameter <host_to_monitor>
is the name of the host as entered in the Name field of its configuration.
You now have to restart Telegraf:
systemctl restart telegraf
Download the agent on all the servers you want to monitor.
You must then configure the Telegraf OpenTelemetry output. You must uncomment this paragraph or recreate a configuration file with just the following lines:
# [[outputs.opentelemetry]]
# ## Override the default (localhost:4317) OpenTelemetry gRPC service
# ## address:port
# # service_address = "localhost:4317"
#
# ## Override the default (5s) request timeout
# # timeout = "5s"
#
# ## Optional TLS Config.
# ##
# ## Root certificates for verifying server certificates encoded in PEM format.
# # tls_ca = "/etc/telegraf/ca.pem"
# ## The public and private keypairs for the client encoded in PEM format.
# ## May contain intermediate certificates.
# # tls_cert = "/etc/telegraf/cert.pem"
# # tls_key = "/etc/telegraf/key.pem"
# ## Use TLS, but skip TLS chain and host verification.
# # insecure_skip_verify = false
# ## Send the specified TLS server name via SNI.
# # tls_server_name = "foo.example.com"
- Install the agent on the servers using the following command (replace the placeholders by your values):
.\telegraf.exe --service install --config <previous conf file path> --config "http(s)://<ip_poller>:<port poller>/engine?host=<host_to_monitor>"
The arguments in this command will allow Telegraf to know where to fetch the configuration of the resources that it must monitor (i.e on the poller or the central, according to the IP address you have entered in the command). The <host_to_monitor>
parameter is the name of the host as you entered it in the Name field in its configuration.
Deploy the Centreon plugin​
The Centreon plugin will execute the checks on the host.
- Linux
- Windows
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.
- Alma / RHEL / Oracle Linux 8
- Alma / RHEL / Oracle Linux 9
- Debian 11 & 12
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
cat >/etc/yum.repos.d/centreon-plugins.repo <<'EOF'
[centreon-plugins-stable]
name=Centreon plugins repository.
baseurl=https://packages.centreon.com/rpm-plugins/el9/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/el9/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/el9/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/el9/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/el9/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/el9/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
wget -O- https://apt-key.centreon.com | gpg --dearmor | tee /etc/apt/trusted.gpg.d/centreon.gpg > /dev/null 2>&1
echo "deb https://packages.centreon.com/apt-plugins-stable/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/centreon-plugins.list
apt-get update
Install the plugin:
apt -y install centreon-plugin-operatingsystems-linux-local
On the hosts you want to monitor, download and execute the corresponding package for Windows. We suggest that you place the plugin at the same place as the Telegraf agent, for example C:\Program Files\InfluxData\telegraf\telegraf-1.30.3
.
Step 3: Monitoring a host with the Telegraf agent​
Create hosts using templates​
- Linux
- Windows
On the central server, create hosts and apply to them the OS-Linux-Telegraf-Agent-custom template.
On the central server, create hosts and apply to them the OS-Windows-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:
- Linux
- Windows
systemctl restart telegraf
telegraf.exe --service stop
telegraf.exe --service start