Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kylerw opened this issue Mar 29, 2019 · 9 comments · Fixed by #12608
Closed

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

kylerw opened this issue Mar 29, 2019 · 9 comments · Fixed by #12608
Labels
feature request Requests for new plugin and for new features to existing plugins rfc Request for comment - larger issues that require clarification

Comments

@kylerw
Copy link

kylerw commented Mar 29, 2019

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

@danielnelson
Copy link
Contributor

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 danielnelson added this to the 1.11.0 milestone Mar 29, 2019
@danielnelson danielnelson added feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin feature request Requests for new plugin and for new features to existing plugins and removed feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin labels Mar 29, 2019
@danielnelson danielnelson changed the title Support --config-directory in Docker Use a default location for the --config-directory if unset Mar 29, 2019
@glinton glinton self-assigned this Apr 10, 2019
@russorat russorat modified the milestones: 1.11.0, 1.12.0 Apr 24, 2019
@glinton
Copy link
Contributor

glinton commented Jul 22, 2019

@glinton glinton removed their assignment Jul 22, 2019
@danielnelson danielnelson removed this from the 1.12.0 milestone Aug 5, 2019
@n1nj4888
Copy link

n1nj4888 commented Aug 17, 2019

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!

@danielnelson
Copy link
Contributor

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

@russorat
Copy link
Contributor

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

@gcorgnet
Copy link

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

@danielnelson
Copy link
Contributor

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

@jmmk
Copy link

jmmk commented Jan 31, 2022

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

@Hipska Hipska added the rfc Request for comment - larger issues that require clarification label Feb 25, 2022
@rdxmb
Copy link
Contributor

rdxmb commented Sep 20, 2022

this is a duplicate to influxdata/influxdata-docker#568, where also people have voted ;)

powersj added a commit to powersj/telegraf that referenced this issue Feb 2, 2023
This will add /etc/telegraf/telegraf.d to the list of default
configuration locations to load from. Currently, users need to specify
an empty /etc/telegraf/telegraf.conf file and specify they want to
include the configuraiton directory outside of the RPM and DEB.

A common use case is for Docker where users want to upload an entire
directory of configurations and run telegraf. Right now they have to add
a custom launch command, when in reality we should include this
directory by default.

This also means that /etc/telegraf/telegraf.conf can be ommitted as
well.

fixes: influxdata#5656
powersj added a commit to powersj/telegraf that referenced this issue Feb 3, 2023
This will add /etc/telegraf/telegraf.d to the list of default
configuration locations to load from. Currently, users need to specify
an empty /etc/telegraf/telegraf.conf file and specify they want to
include the configuraiton directory outside of the RPM and DEB.

A common use case is for Docker where users want to upload an entire
directory of configurations and run telegraf. Right now they have to add
a custom launch command, when in reality we should include this
directory by default.

This also means that the --config option can be omitted from the CLI
if a user is only using --config-directory.

fixes: influxdata#5656
fixes: influxdata#5571
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Requests for new plugin and for new features to existing plugins rfc Request for comment - larger issues that require clarification
Projects
None yet
9 participants