telegraf icon indicating copy to clipboard operation
telegraf copied to clipboard

Use a default location for the --config-directory if unset

Open kylerw opened this issue 7 years ago • 9 comments

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

kylerw avatar Mar 29 '19 20:03 kylerw

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.

danielnelson avatar Mar 29 '19 21:03 danielnelson

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!

n1nj4888 avatar Aug 17 '19 06:08 n1nj4888

You can run the container with --config-directory /etc/telegraf/telegraf.d.

danielnelson avatar Aug 17 '19 21:08 danielnelson

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/"]

russorat avatar Oct 14 '19 18:10 russorat

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.

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

gcorgnet avatar May 19 '20 05:05 gcorgnet

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

danielnelson avatar May 19 '20 20:05 danielnelson

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

jmmk avatar Jan 31 '22 18:01 jmmk

this is a duplicate to https://github.com/influxdata/influxdata-docker/issues/568, where also people have voted ;)

rdxmb avatar Sep 20 '22 14:09 rdxmb