Connect apt installed Telegraf to Telegraf configuration

I have installed Telegraf on Debian using apt. (To make sure it starts at system startup.)

How do I connect it to a Telegraf configuration on my InfluxDB server?

Hello @AndreKR,
Have you followed these docs to get started?

Youll need to use this command:

telegraf --sample-config > telegraf.conf

Or you can specify which plugins you want with:

telegraf --sample-config --input-filter cpu:mem --output-filter influxdb_v2 > telegraf.conf

Then you’ll need to configure the output portion of the config with your:

  • org ID
  • token
  • bucket
  • url

I’m assuming you’re using v2 here.
Otherwise you’ll use the influxdb output plugin for 1.x.

The easiest way to configure all of this in v2 is through the UI.

1 Like

Yes, that is what I want to do.

In the last step it will show this screen which shows commands to start a new Telegraf process and connect it to the configuration I just set up. Instead, I want to configure the existing Telegraf process (that I installed according to these instructions) to fetch the configuration from the UI.

@AndreKR not 100% sure if your goal is to configure your systemd service to get the config from InfluxDB or if you really want to change the configuration of the already running Telegraf.

For the former, you can adapt the service command line by editing /etc/default/telegraf and add the options via TELEGRAF_OPTS = "--config <the URL shown in your screenshot>" and export the token in the same file… Please do not forget to restart the service.

For the latter, this is not possible. You cannot modify the configuration source after Telegraf being started.

Yes, the former. Your solution works. :+1:

Actually I’m not sure if in your second point you meant changing the URL of a running Telegraf, overriding options in the fetched config of a running Telegraf or simply reloading the config of a running Telegraf.

Indeed I expected Telegraf to reload its config when the config is changed in InfluxDB but it seems that isn’t implemented. Without it, managing configs in InfluxDB isn’t all that useful because you still have to connect to the host to restart Telegraf.

As a workaround I can use cron to send SIGHUP to Telegraf every 5 minutes or so. Not ideal, but seems to work.

You are absolutely right and we have this on our table but no solution so far… Sorry!