Telegraf is an agent written in Go for collecting performance metrics from the system it’s running on and the services running on that system. The collected metrics are output to InfluxDB or other supported data stores. From InfluxDB, you should be able to visualize trends and systems performance using tools like Grafana.
A basic usage flow of Telegraf is:
- Telegraf agent is installed on all servers ( Ubuntu, Debian, Windows, CentOS e.t.c). It is the configured to collect metrics you want
- Metrics collected are pushed to InfluxDB
- InfluxDB data source is then added to Grafana
- Grafana Graphs are created – They get data from an influxdb data source
I recently covered the installation of Grafana and InfluxDB on Linux:
- How To Install InfluxDB on Ubuntu
- Install Grafana and InfluxDB on CentOS / RHEL
- How To Install InfluxDB on Debian
How to Install Telegraf on Ubuntu
Installation of telegraf on Ubuntu 18.04 is done from Influxdata repository. Once the repo is added, the package can then be installed using an apt package manager. Add the InfluxData repository to the file /etc/apt/sources.list.d/influxdata.list
cat <<EOF | sudo tee /etc/apt/sources.list.d/influxdata.list
deb https://repos.influxdata.com/ubuntu $(lsb_release -cs) stable
EOF
Import apt key:
curl -fsSL https://repos.influxdata.com/influxdata-archive_compat.key|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/influxdata.gpg
Update apt index and install telegraf
sudo apt update
Install telegraf:
$ sudo apt install telegraf
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
telegraf
0 upgraded, 1 newly installed, 0 to remove and 10 not upgraded.
Need to get 53.9 MB of archives.
After this operation, 194 MB of additional disk space will be used.
Get:1 https://repos.influxdata.com/ubuntu bullseye/stable amd64 telegraf amd64 1.27.3-1 [53.9 MB]
Fetched 53.9 MB in 1s (39.7 MB/s)
Selecting previously unselected package telegraf.
(Reading database ... 33878 files and directories currently installed.)
Preparing to unpack .../telegraf_1.27.3-1_amd64.deb ...
Unpacking telegraf (1.27.3-1) ...
Setting up telegraf (1.27.3-1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/telegraf.service → /lib/systemd/system/telegraf.service.
Start and enable the service to start on boot up.
$ sudo systemctl enable --now telegraf
$ sudo systemctl is-enabled telegraf
enabled
Check service status:
$ systemctl status telegraf
* telegraf.service - The plugin-driven server agent for reporting metrics into InfluxDB
Loaded: loaded (/lib/systemd/system/telegraf.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2019-01-30 04:03:11 PST; 2min 54s ago
Docs: https://github.com/influxdata/telegraf
Main PID: 3385 (telegraf)
Tasks: 11 (limit: 1110)
CGroup: /system.slice/telegraf.service
`-3385 /usr/bin/telegraf -config /etc/telegraf/telegraf.conf --config-directory /etc/telegraf/telegraf.d
....
Install Telegraf on Debian
Add Influx Data repository using the following command:
cat <<EOF | sudo tee /etc/apt/sources.list.d/influxdata.list
deb https://repos.influxdata.com/debian $(lsb_release -cs) stable
EOF
Import repo gpg key for installing signed packages:
curl -fsSL https://repos.influxdata.com/influxdata-archive_compat.key|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/influxdata.gpg
Update apt index and install telegraf package:
sudo apt update
sudo apt install telegraf
Start telegraf service:
sudo systemctl enable --now start telegraf
You can check the status to confirm if running using:
sudo systemctl status telegraf
Configuring Telegraf
Now that you have InfluxDB and Telegraf running, you can go through our guide on how to Monitor Linux System with Grafana and Telegraf to learn how to configure Telegraf and use it with Grafana.