InfluxDB Docs

Manually configure Telegraf

Use the Telegraf influxdb_v2 output plugin to collect and write metrics into an InfluxDB v2.0 bucket. This article describes how to enable the influxdb_v2 output plugin in new and existing Telegraf configurations, then start Telegraf using the custom configuration file.

View the requirements for using Telegraf with InfluxDB v2.0.

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.

See Telegraf plugins for a complete list of available plugins.

Enable and configure the InfluxDB v2 output plugin

To send data to an InfluxDB v2.0 instance, enable in the influxdb_v2 output plugin in the telegraf.conf.

Specify the following:


An array of URLs for your InfluxDB v2.0 instances. By default, InfluxDB 2.0 OSS runs on port 9999. If using InfluxDB Cloud 2.0, see InfluxDB Cloud URLs for information about which URLs to use. InfluxDB Cloud requires HTTPS.


Your InfluxDB v2.0 authorization token. For information about viewing tokens, see View tokens.

Avoid storing tokens in telegraf.conf

We recommend storing your tokens by setting the INFLUX_TOKEN environment variable and including the environment variable in your configuration file.

export INFLUX_TOKEN=YourAuthenticationToken
$env:INFLUX_TOKEN = "YourAuthenticationToken"
set INFLUX_TOKEN=YourAuthenticationToken
# Make sure to include a space character at the end of this command.

See the example telegraf.conf below.


The name of the organization that owns the target bucket.


The name of the bucket to write data to.

Example influxdb_v2 configuration

The example below illustrates influxdb_v2 configurations that write to InfluxDB OSS or InfluxDB Cloud 2.0.

# ...

  urls = ["http://localhost:9999"]
  token = "$INFLUX_TOKEN"
  organization = "example-org"
  bucket = "example-bucket"

# ...

For the specific URL of your InfluxDB Cloud instance, see InfluxDB Cloud URLs.

# ...

  urls = [""]
  token = "$INFLUX_TOKEN"
  organization = "example-org"
  bucket = "example-bucket"

# ...
Write to InfluxDB v1.x and v2.0

If a Telegraf agent is already writing to an InfluxDB v1.x database, enabling the InfluxDB v2 output plugin will write data to both v1.x and v2.0 instances.

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