Install and Configure Telegraf on RHEL 8 / CentOS 8

0
15

Question: How to install telegraf on RHEL 8 / CentOS 8?. Telegraf is a powerful monitoring agent used for collecting and reporting performance metrics from the system it is running on. It is part of TICK Stack. The metrics collected by Telegraf can be saved in a time-series database such as InfluxDB or any other supported data store.

Features of Telegraf

Here are the key features of Telegraf metrics collector.

  • Has small memory footprint – the power of Go
  • Being written in Go. It compiles into a single binary with no external dependencies.
  • It is plugin-driven to allow easy addition of new inputs and outputs
  • Supports InfluxDB, Graphite, OpenTSDB, Datadog, Librato, Kafka, MQTT, NSQ, and many other datastores.

Install Telegraf on RHEL 8 / CentOS 8

As of this writing, there is no official repository for RHEL 8 but we will use InfluxData repository for RHEL 7 which works fine.

Update your system RHEL 8 system.

sudo yum -y update

Step 1: Add Influxdata RPM repository

Then add Influxdata RPM repository.

cat <<EOF | sudo tee /etc/yum.repos.d/influxdb.repo
[influxdb]
name = InfluxDB Repository - RHEL 
baseurl = https://repos.influxdata.com/rhel/8/x86_64/stable/
enabled = 1
gpgcheck = 0
gpgkey = https://repos.influxdata.com/influxdb.key
EOF

Step 2: Install Telegraf on RHEL 8 / CentOS 8

Once the repository has been added, install Telegraf on RHEL 8 using the command below.

sudo yum -y install telegraf

You can view package details with rpm command.

$ rpm -qi telegraf
Name        : telegraf
Version     : 1.26.0
Release     : 1
Architecture: x86_64
Install Date: Thu 16 Mar 2023 08:45:19 AM UTC
Group       : default
Size        : 167946710
License     : MIT
Signature   : RSA/SHA512, Mon 13 Mar 2023 08:35:48 PM UTC, Key ID d8ff8e1f7df8b07e
Source RPM  : telegraf-1.26.0-1.src.rpm
Build Date  : Mon 13 Mar 2023 08:12:28 PM UTC
Build Host  : 7265b38eeb35
Relocations : /
Packager    : [email protected]
Vendor      : InfluxData
URL         : https://github.com/influxdata/telegraf
,,,

Step 3: Configure Telegraf Service

You’ll need to configure an output before you can start the service.

Edit the file and configure output plugin after setting it up.

sudo vi /etc/telegraf/telegraf.conf

See sample configuration for sending metrics to InfluxDB.

[[outputs.influxdb]]
urls = ["http://127.0.0.1:8086"]
database = "telegraf"

Now that telegraf is installed on RHEL 8, let’s start the service and enable it to start on boot.

sudo systemctl enable --now telegraf

Confirm status of the service after starting it.

$ systemctl status telegraf
 telegraf.service - Telegraf
   Loaded: loaded (/usr/lib/systemd/system/telegraf.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2023-03-16 08:54:53 UTC; 7s ago
     Docs: https://github.com/influxdata/telegraf
 Main PID: 2672 (telegraf)
    Tasks: 7 (limit: 23036)
   Memory: 34.0M
   CGroup: /system.slice/telegraf.service
           └─2672 /usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d

Mar 16 08:54:53 rocky8.mylab.io telegraf[2672]: 2023-03-16T08:54:53Z I! Starting Telegraf 1.26.0
Mar 16 08:54:53 rocky8.mylab.io telegraf[2672]: 2023-03-16T08:54:53Z I! Available plugins: 235 inputs, 9 aggregators, 27 processors, 22 parsers, 57 outputs, 2 secret-stores
Mar 16 08:54:53 rocky8.mylab.io telegraf[2672]: 2023-03-16T08:54:53Z I! Loaded inputs: cpu disk diskio kernel mem processes swap system
Mar 16 08:54:53 rocky8.mylab.io telegraf[2672]: 2023-03-16T08:54:53Z I! Loaded aggregators:
Mar 16 08:54:53 rocky8.mylab.io telegraf[2672]: 2023-03-16T08:54:53Z I! Loaded processors:
Mar 16 08:54:53 rocky8.mylab.io telegraf[2672]: 2023-03-16T08:54:53Z I! Loaded secretstores:
Mar 16 08:54:53 rocky8.mylab.io telegraf[2672]: 2023-03-16T08:54:53Z I! Loaded outputs: influxdb
Mar 16 08:54:53 rocky8.mylab.io telegraf[2672]: 2023-03-16T08:54:53Z I! Tags enabled: host=rocky8.mylab.io
Mar 16 08:54:53 rocky8.mylab.io telegraf[2672]: 2023-03-16T08:54:53Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"rocky8.mylab.io", Flush Interval:10s
Mar 16 08:54:53 rocky8.mylab.io systemd[1]: Started Telegraf.

Step 4: Configure Telegraf on RHEL 8 / CentOS 8

Follow our guide below to see example on configuration of Telegraf.

For Telegraf and Grafana installation, use the links below.

Related articles:

LEAVE A REPLY

Please enter your comment!
Please enter your name here