Configure Telegraf to write to InfluxDB 3 Enterprise

Use the Telegraf influxdb_v3 output plugin to collect and write metrics to InfluxDB 3 Enterprise. This plugin uses the InfluxDB 3 Enterprise native HTTP API /api/v3/write_lp endpoint and requires Telegraf 1.38 or greater. Learn how to enable and configure the influxdb_v3 output plugin to write data to InfluxDB 3 Enterprise.

If you use an earlier version of Telegraf or bring an existing Telegraf configuration from InfluxDB v1 or v2, you can use the influxdb_v2 or influxdb (v1) output plugins to write to InfluxDB 3 Enterprise compatibility APIs.

View the requirements for using Telegraf with InfluxDB 3 Enterprise.

Configure Telegraf input and output plugins

Configure Telegraf input and output plugins in the Telegraf configuration file (typically named telegraf.conf). Input plugins collect metrics. Output plugins define destinations where metrics are sent.

This guide assumes you have already installed InfluxDB 3 Enterprise and have been through the getting started guide.

Add Telegraf plugins

To add any of the available Telegraf plugins, follow the steps below.

  1. Find the plugin you want to enable from the complete list of available Telegraf plugins.
  2. Click View to the right of the plugin name to open the plugin page on GitHub. For example, view the MQTT plugin GitHub page.
  3. Copy and paste the example configuration into your Telegraf configuration file (typically named telegraf.conf).

Enable and configure the InfluxDB v3 output plugin

To send data to InfluxDB 3 Enterprise, enable the influxdb_v3 output plugin in the telegraf.conf.

[[outputs.influxdb_v3]]
  urls = ["http://localhost:8181"]
  token = "
AUTH_TOKEN
"
database = "
DATABASE_NAME
"

Replace the following:

  • DATABASE_NAME: the name of the database to write data to
  • AUTH_TOKEN: your InfluxDB 3 Enterprise token . Store this in a secret store or environment variable to avoid exposing the raw token string.

The InfluxDB v3 output plugin configuration contains the following options:

urls

An array of URL strings. To write to InfluxDB 3 Enterprise, include your InfluxDB 3 Enterprise URL:

["http://localhost:8181"]

If you specify multiple URLs, Telegraf randomly selects one of them for each write interval and fails over to another if the write doesn’t succeed.

token

Your InfluxDB 3 Enterprise authorization token.

Store your authorization token as an environment variable

To prevent a plain text token in your Telegraf configuration file, we recommend that you store the token as an environment variable and then reference the environment variable in your configuration file using string interpolation. For example:

[[outputs.influxdb_v3]]
  urls = ["http://localhost:8181"]
  token = "${INFLUX_TOKEN}"
  # ...

database

The name of the InfluxDB 3 Enterprise database to write data to.

Additional plugin options

The plugin provides additional options for controlling write behavior, including:

  • database_tag: the metric tag to use to determine the destination database, overriding database.
  • sync: set to false to acknowledge writes before WAL persistence completes, which reduces write latency but increases the risk of data loss. Default is true. See Use no_sync for immediate write responses.
  • content_encoding: the plugin compresses write request bodies with gzip by default.

For all plugin options, see the influxdb_v3 output plugin reference.

Use the InfluxDB v2 output plugin

If you bring an existing InfluxDB v2 write workload or use a Telegraf version earlier than 1.38, use the influxdb_v2 output plugin to write to InfluxDB 3 Enterprise through the InfluxDB v2 compatibility API.

[[outputs.influxdb_v2]]
  urls = ["http://localhost:8181"]
  token = "
AUTH_TOKEN
"
organization = "" bucket = "
DATABASE_NAME
"

Replace the following:

  • DATABASE_NAME: the name of the database to write data to
  • AUTH_TOKEN: your InfluxDB 3 Enterprise token

For InfluxDB 3 Enterprise, set the following v2-specific options:

  • organization: set to an empty string ("").
  • bucket: the name of the database to write data to.

An InfluxDB v2 bucket is synonymous with an InfluxDB 3 Enterprise database.

Use the InfluxDB v1 output plugin

If you bring an existing InfluxDB v1 write workload, use the influxdb output plugin to write to InfluxDB 3 Enterprise through the InfluxDB v1 compatibility API.

[[outputs.influxdb]]
  urls = ["http://localhost:8181"]
  database = "
DATABASE_NAME
"
skip_database_creation = true username = "ignored" password = "
AUTH_TOKEN
"

Replace the following:

  • DATABASE_NAME: the name of the database to write data to
  • AUTH_TOKEN: your InfluxDB 3 Enterprise token

For InfluxDB 3 Enterprise, set the following v1-specific options:

  • skip_database_creation: set to true. InfluxDB 3 Enterprise doesn’t support creating databases through the v1 API.
  • password: your authorization token. The v1 compatibility API authenticates with the token passed as the password credential and ignores username.

Other Telegraf configuration options

For more plugin configuration options, see the influxdb_v3, influxdb_v2, and influxdb (v1) output plugin references.

Start Telegraf

Start the Telegraf service using the --config flag to specify the location of your telegraf.conf.

telegraf --config /path/to/custom/telegraf.conf

Was this page helpful?

Thank you for your feedback!