(Last Updated On: June 7, 2018)

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:

  1. Telegraf agent is installed on all servers ( Ubuntu, Debian, Windows, CentOS e.t.c). It is the configured to collect metrics you want
  2. Metrics collected are pushed to InfluxDB
  3. InfluxDB data source is then added to Grafana
  4. Grafana Graphs are created – They get data from an influxdb data source

I recently covered the installation of Grafana and InfluxDB on Linux; Install InfluxDB on Ubuntu 18.04 and Debian 9, Install Grafana and InfluxDB on CentOS 7, and How to Install Grafana on Ubuntu 18.04 and Debian 9.

How to Install Telegraf on Ubuntu 18.04

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 /etc/apt/sources.list.d/influxdata.list
deb https://repos.influxdata.com/ubuntu bionic stable

Import apt key:

$ sudo curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -

Update apt index and install telegraf

$ sudo apt-get update

Install telegraf:

$ sudo apt-get install telegraf
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 9669 kB of archives.
After this operation, 29.2 MB of additional disk space will be used.
Get:1 https://repos.influxdata.com/ubuntu bionic/stable amd64 telegraf amd64 1.6.4-1 [9669 kB]
Fetched 9669 kB in 0s (35.4 MB/s)
Selecting previously unselected package telegraf.
(Reading database ... 67631 files and directories currently installed.)
Preparing to unpack .../telegraf_1.6.4-1_amd64.deb ...
Unpacking telegraf (1.6.4-1) ...
Setting up telegraf (1.6.4-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 start telegraf
$ sudo  systemctl enable telegraf
$ sudo systemctl is-enabled telegraf

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 Thu 2018-06-07 11:07:22 UTC; 2min 11s ago
Docs: https://github.com/influxdata/telegraf
Main PID: 31175 (telegraf)
Tasks: 10 (limit: 4704)
CGroup: /system.slice/telegraf.service
└─31175 /usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.dInstall InfluxDB on Debian 9

Install Telegraf on Debian 9

Add influxdata repository using the following command:

$ cat /etc/apt/sources.list.d/influxdata.list
deb https://repos.influxdata.com/debian stretch stable

Import repo gpg key for installing signed packages:

$ sudo curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -

Update apt index and install telegraf package:

$ sudo apt-get update
$ sudo apt-get install telegraf

Start telegraf service:

$ sudo systemctl start telegraf
$ sudo systemctl enable 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.