Documentation

Get started

After you’ve downloaded and installed Telegraf, you’re ready to begin collecting and sending data. To collect and send data, do the following:

  1. Configure Telegraf
  2. Start Telegraf
  3. Use plugins available in Telegraf to gather, transform, and output data.

Configure Telegraf

Define which plugins Telegraf will use in the configuration file. Each configuration file needs at least one enabled input plugin (where the metrics come from) and at least one enabled output plugin (where the metrics go).

The following example generates a sample configuration file with all available plugins, then uses filter flags to enable specific plugins.

For details on filter and other flags, see Telegraf commands and flags.

  1. Run the following command to create a configuration file:

    telegraf --sample-config > telegraf.conf
    
  2. Locate the configuration file. The location varies depending on your system:

    • macOS Homebrew: /usr/local/etc/telegraf.conf
    • Linux debian and RPM packages: /etc/telegraf/telegraf.conf
    • Standalone Binary: see the next section for how to create a configuration file

    Note: You can also specify a remote URL endpoint to pull a configuration file from. See Configuration file locations.

  3. Edit the configuration file using vim or a text editor. Because this example uses InfluxDB V2 output plugin, we need to add the InfluxDB URL, authentication token, organization, and bucket details to this section of the configuration file.

Note: For more configuration file options, see Configuration options.

  1. For this example, specify two inputs (cpu and mem) with the --input-filter flag. Specify InfluxDB as the output with the --output-filter flag.
telegraf --sample-config --input-filter cpu:mem --output-filter influxdb_v2 > telegraf.conf

The resulting configuration will collect CPU and memory data and sends it to InfluxDB V2.

For an overview of how to configure a plugin, watch the following video:

Set environment variables

Add environment variables anywhere in the configuration file by prepending them with $. For strings, variables must be in quotes (for example, "$STR_VAR"). For numbers and Booleans, variables must be unquoted (for example, $INT_VAR, $BOOL_VAR).

You can also set environment variables using the Linux export command: export password=mypassword

Note: We recommend using environment variables for sensitive information.

Example: Telegraf environment variables

In the Telegraf environment variables file (/etc/default/telegraf):

USER="alice"
INFLUX_URL="http://localhost:8086"
INFLUX_SKIP_DATABASE_CREATION="true"
INFLUX_PASSWORD="monkey123"

In the Telegraf configuration file (/etc/telegraf.conf):

[global_tags]
  user = "${USER}"

[[inputs.mem]]

[[outputs.influxdb]]
  urls = ["${INFLUX_URL}"]
  skip_database_creation = ${INFLUX_SKIP_DATABASE_CREATION}
  password = "${INFLUX_PASSWORD}"

The environment variables above add the following configuration settings to Telegraf:

[global_tags]
  user = "alice"

[[outputs.influxdb]]
  urls = "http://localhost:8086"
  skip_database_creation = true
  password = "monkey123"

Start Telegraf

Next, you need to start the Telegraf service and direct it to your configuration file:

macOS Homebrew

telegraf --config telegraf.conf

Linux (systemd installations)

systemctl start telegraf

Was this page helpful?

Thank you for your feedback!


Introducing InfluxDB Clustered

A highly available InfluxDB 3.0 cluster on your own infrastructure.

InfluxDB Clustered is a highly available InfluxDB 3.0 cluster built for high write and query workloads on your own infrastructure.

InfluxDB Clustered is currently in limited availability and is only available to a limited group of InfluxData customers. If interested in being part of the limited access group, please contact the InfluxData Sales team.

Learn more
Contact InfluxData Sales

The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Flux is going into maintenance mode and will not be supported in InfluxDB 3.0. This was a decision based on the broad demand for SQL and the continued growth and adoption of InfluxQL. We are continuing to support Flux for users in 1.x and 2.x so you can continue using it with no changes to your code. If you are interested in transitioning to InfluxDB 3.0 and want to future-proof your code, we suggest using InfluxQL.

For information about the future of Flux, see the following: