Telegraf doesn't use config files in telegraf.d

Hi there,

I have a telegraf container and an influxdb container running in one docker network. I have one main config file for monitoring the host and another one in telegraf.d for monitoring a router via snmp.
Everything works fine except the fact that telegraf doesn’t use the config files in telegraf.d.

If you go into the command line of the telegraf container and execute the command --config-directory it includes the config files of telegraf.d.

Obviously I don’t want to do this every time I start the container. So is there an option to start the container with docker run… telegraf and tell telegraf to include the files of telegraf.d?

Thank you.

An excerpt from Docker Hub

Using the default configuration

The default configuration requires a running InfluxDB instance as an output plugin. Ensure that InfluxDB is running on port 8086 before starting the Telegraf container.

Minimal example to start an InfluxDB container:

$ docker run -d --name influxdb -p 8086:8086 influxdb

Starting Telegraf using the default config, which connects to InfluxDB at http://localhost:8086/ :

$ docker run --net=container:influxdb telegraf

Using a custom config file

First, generate a sample configuration and save it as telegraf.conf on the host:

$ docker run --rm telegraf telegraf config > telegraf.conf

Once you’ve customized telegraf.conf , you can run the Telegraf container with it mounted in the expected location:

$ docker run -v $PWD/telegraf.conf:/etc/telegraf/telegraf.conf:ro telegraf

Modify $PWD to the directory where you want to store the configuration file.

Actually I found the bug.
After the command “docker run … telegraf” I had to include the following "–config-directory " to include the files in the telegraf.d folder.

1 Like

Can I see your container instructions

they are very simple.
Like: docker run -p : -name = -v : -network = telegraf --config-directory=telegraf.d

for the path on host I would use a docker created volume, which gets created with "docker volume create "

Thank you. I use docker compose Realized :hear_no_evil: