How can I have multiple config with only one daemon?

Im trying to have one config file-> telegraf.conf and other in /etc/telegraf/telegraf.d/
named test.conf with one swap metric.

After that i restart the service: systemctl restart telegraf

Using systemctl, what i have to do to read both config files, because using that i only read telegraf.conf.

Documentacion said:

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, in this case, My telegraf should read it test.conf too.

I read the post named “multiple telegraf configs” but i would like to have any daemon and use both configuration together in different files.

Im so confused about iT, what am i missing?

If I run telegraf:
telegraf --config-directory /etc/telegraf
then i combine both im not recording this configuration like by default.

Any suggestions??

I’m not sure what the problem is, I would try getting it to work in the foreground using:

telegraf --config /etc/telegraf/telegraf.conf --config-directory /etc/telegraf/telegraf.d --test

I need to try that in background, if I execute this on command, it combines both .conf files but if i start my daemon i dont have, for example:

telegraf --config /etc/telegraf/telegraf.conf --config-directory /etc/telegraf/telegraf.d
2017-11-16T07:05:58Z I! Starting Telegraf v1.4.1
2017-11-16T07:05:58Z I! Loaded outputs: influxdb influxdb
2017-11-16T07:05:58Z I! Loaded inputs: inputs.mem inputs.mongodb inputs.snmp inputs.disk inputs.diskio inputs.kernel inputs.processes inputs.system inputs.exec inputs.haproxy inputs.cpu inputs.swap

But, checking my daemon executestart (i started with systemctl):

Description=The plugin-driven server agent for reporting metrics into InfluxDB

ExecStart=/usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d ${TELEGRAF_OPTS}
ExecReload=/bin/kill -HUP $MAINPID


But, the real loaded inputs even when I have the execute start with --config-directory /etc/telegraf/telegraf.d, it doesn’t have input.swap and i dont insert anything in influxdb about swap metrics.

So, I dont know what is missing for me, or if it is not possible to have this working properly with systemctl.

I was researching more options and I think that I can use “mmonit” instead the daemon with systemctl because I dont find any solution about it or what im missing.
Its odd because im using the same (telegraf --config /etc/telegraf/telegraf.conf --config-directory /etc/telegraf/telegraf.d) but the first in command line and the second one with systemctl.

When run as a service Telegraf runs as the telegraf user, perhaps the configuration files or directory does not have the right permissions to allow this user to read them?

1 Like

yes!! It’s working properly now.
Thank you so much ,this topic driving me crazy!

1 Like