This is archived documentation for InfluxData product versions that are no longer maintained. For newer documentation, see the latest InfluxData documentation.
Getting started with Telegraf
Telegraf is an agent written in Go for collecting metrics and writing them into InfluxDB or other possible outputs. This guide will get you up and running with Telegraf. It walks you through the download, installation, and configuration processes, and it shows how to use Telegraf to get data into InfluxDB.
Download and install Telegraf
Follow the instructions in the Telegraf section on the Downloads page.
Note: Telegraf will start automatically using the default configuration when installed from a deb package.
Configuration file location by installation type
- macOS Homebrew:
- Linux debian and RPM packages:
- Standalone Binary: see the next section for how to create a configuration file
Creating and editing the configuration file
Before starting the Telegraf server you need to edit and/or create an initial configuration that specifies your desired inputs (where the metrics come from) and outputs (where the metrics go). There are several ways to create and edit the configuration file.
Here, we’ll generate a configuration file and simultaneously specify the desired inputs with the
-input-filter flag and the desired output with the
In the example below, we create a configuration file called
telegraf.conf with two inputs:
one that reads metrics about the system’s cpu usage (
cpu) and one that reads metrics about the system’s memory usage (
mem). We specify InfluxDB as the desired output.
telegraf -sample-config -input-filter cpu:mem -output-filter influxdb > telegraf.conf
Start the Telegraf service
Start the Telegraf service and direct it to the relevant configuration file:
telegraf --config telegraf.conf
Linux (sysvinit and upstart installations)
sudo service telegraf start
Linux (systemd installations)
systemctl start telegraf
Once Telegraf is up and running it will start collecting data and writing them to the desired output.
Returning to our sample configuration, we show what the
mem data look like in InfluxDB below.
Note that we used the default input and output configuration settings to get these data.
List all measurements in the
> SHOW MEASUREMENTS name: measurements ------------------ name cpu mem
List all field keys by measurement:
> SHOW FIELD KEYS name: cpu --------- fieldKey fieldType usage_guest float usage_guest_nice float usage_idle float usage_iowait float usage_irq float usage_nice float usage_softirq float usage_steal float usage_system float usage_user float name: mem --------- fieldKey fieldType active integer available integer available_percent float buffered integer cached integer free integer inactive integer total integer used integer used_percent float
Select a sample of the data in the field
usage_idlein the measurement
> SELECT usage_idle FROM cpu WHERE cpu = 'cpu-total' LIMIT 5 name: cpu --------- time usage_idle 2016-01-16T00:03:00Z 97.56189047261816 2016-01-16T00:03:10Z 97.76305923519121 2016-01-16T00:03:20Z 97.32533433320835 2016-01-16T00:03:30Z 95.68857785553611 2016-01-16T00:03:40Z 98.63715928982245
Notice that the timestamps occur at rounded ten second intervals (that is,
:20, and so on) - this is a configurable setting.
That’s it! You now have the foundation for using Telegraf to collect metrics and write them to your output of choice.