Use a default location for the --config-directory if unset
Feature Request
Would like an option to use --config-directory in docker rather than one telegraf.conf
Proposal:
Map host/container directory and default config will be stored here and --config-directory used.
Current behavior:
defaults to /etc/telegraf/telegraf.conf
Desired behavior:
Use case: [Why is this important (helps with prioritizing requests)]
allows for cleaner management of plugins and other services
You can of course run the container with --config-directory /etc/telegraf/telegraf.d set, any arguments are passed to Telegraf.
I think this really boils down to deciding if the --config-directory option should have a default directory, which seems like a reasonable thing to me.
According to #5703, this has been "put it on ice until we have time to revamp the config loading in depth."
Hi Guys,
It seems, by default, the /etc/telegraf/telegraf.d/*.conf files are not picked up by the official telegraf docker image, only the /etc/telegraf/telegraf.conf file?
Is there anyway (for example an environment variable configured for the container) to get the telegraf service inside the docker image/container to load the .conf files from /etc/telegraf/telegraf.d/ in addition to the standard /etc/telegraf/telegraf.conf file?
Thanks!
You can run the container with --config-directory /etc/telegraf/telegraf.d.
For anyone else who comes across this while trying to use the --config-directory option with kubernetes (as i did), you need to also pass a dummy config file like so:
spec:
containers:
- name: telegraf
image: telegraf:1.12.3-alpine
volumeMounts:
- name: config-volume
mountPath: /etc/telegraf.d
command: ["telegraf"]
args: ["--config","/etc/telegraf.d/dummy.conf","--config-directory","/etc/telegraf.d/"]
You can of course run the container with
--config-directory /etc/telegraf/telegraf.dset, any arguments are passed to Telegraf.I think this really boils down to deciding if the
--config-directoryoption should have a default directory, which seems like a reasonable thing to me.
Sorry, probably me being stupid but could someone please show an examaple of what the docker run command would look like with this argument? I couldn't get it working..
Thanks
Here it is including volume mount options:
docker run -v /telegraf.conf:/etc/telegraf/telegraf.conf -v /telegraf.d:/etc/telegraf/telegraf.d telegraf --config-directory /etc/telegraf/telegraf.d
Explicitly specifying --config-directory is an easy fix, but the documentation at https://docs.influxdata.com/telegraf/v1.21/administration/configuration/#configuration-file-locations states:
On most systems, the default locations are /etc/telegraf/telegraf.conf for the main configuration file and /etc/telegraf/telegraf.d for the directory of configuration files.
So it is a little unexpected that /etc/telegraf/telegraf.d is not treated as the default
this is a duplicate to https://github.com/influxdata/influxdata-docker/issues/568, where also people have voted ;)