content/shared/influxdb3-write-guides/use-telegraf/configure.md
Use the Telegraf influxdb_v2 output plugin
to collect and write metrics to {{< product-name >}}.
This plugin uses the InfluxDB v2 HTTP API write endpoint available with
{{% product-name %}}.
Learn how to enable and configure the influxdb_v2 output plugin to write data
to {{% product-name %}}.
<!-- TOC -->[!Note] View the requirements for using Telegraf with {{< product-name >}}.
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 {{% product-name %}} and have been through the getting started guide.
To add any of the available Telegraf plugins, follow the steps below.
telegraf.conf).To send data to {{< product-name >}}, enable the
influxdb_v2 output plugin
in the telegraf.conf.
{{% code-placeholders "AUTH_TOKEN|DATABASE_NAME" %}}
[[outputs.influxdb_v2]]
urls = ["http://{{< influxdb/host >}}"]
token = "AUTH_TOKEN"
organization = ""
bucket = "DATABASE_NAME"
{{% /code-placeholders %}}
Replace the following:
DATABASE_NAME{{% /code-placeholder-key %}}:
the name of the database to write data toAUTH_TOKEN{{% /code-placeholder-key %}}:
your {{< product-name >}} {{% token-link %}}.
Store this in a secret store or environment variable to avoid exposing the raw token string.The InfluxDB output plugin configuration contains the following options:
An array of URL strings. To write to {{% product-name %}}, include your {{% product-name %}} URL:
["http://{{< influxdb/host >}}"]
Your {{% product-name %}} authorization token.
[!Tip]
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:
toml[[outputs.influxdb_v2]] urls = ["http://{{< influxdb/host >}}"] token = "${INFLUX_TOKEN}" # ...
For {{% product-name %}}, set this to an empty string ("").
The name of the {{% product-name %}} database to write data to.
[!Note] An InfluxDB v2 bucket is synonymous with an {{% product-name %}} database.
For more plugin configuration options, see the
influxdb_v2 output plugin README
on GitHub.
Start the Telegraf service using the --config flag to specify the location of
your telegraf.conf.
telegraf --config /path/to/custom/telegraf.conf