How to put multiple telegraf config files in telegraf.service?

I have multiple telegraf conf files to schedule using systemd (/usr/lib/systemd/system/telegraf.service)
but i did not find any provision to put multiple config in one - i mean how to put telegraf1.conf telegraf2.conf, telegraf3.conf in below arguments

ExecStart=/usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d $TELEGRAF_OPTS

Any inputs here?

The preferred way to have multiple configuration files is to store them all under /etc/telegraf/telegraf.d. That configuration folder will get read and everything under there loaded when Telegraf runs.

Thanks!

(post deleted by author)

thanks @jpowers for your inputs.
just got curious to know, whether if this works only with influxdb? but my database is postgres. when i check the status of the service, it mentions influxDB explicitely. any insights here?

[root@h0012345 telegraf.d]# systemctl status telegraf
● telegraf.service - The plugin-driven server agent for reporting metrics into InfluxDB
Loaded: loaded (/usr/lib/systemd/system/telegraf.service; enabled; vendor preset: disabled)
Active: failed (Result: start-limit) since Thu 2021-10-21 12:18:38 CDT; 1s ago
Docs: GitHub - influxdata/telegraf: The plugin-driven server agent for collecting & reporting metrics.
Process: 68859 ExecStart=/usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d $TELEGRAF_OPTS (code=exited, status=1/FAILURE)
Main PID: 68859 (code=exited, status=1/FAILURE)

Oct 21 12:18:38 h0012345.associatesys.local systemd[1]: Unit telegraf.service entered failed state.
Oct 21 12:18:38 h0012345.associatesys.local systemd[1]: telegraf.service failed.
Oct 21 12:18:38 h0012345.associatesys.local systemd[1]: telegraf.service holdoff time over, scheduling restart.
Oct 21 12:18:38 h0012345.associatesys.local systemd[1]: Stopped The plugin-driven server agent for reporting met…xDB.
Oct 21 12:18:38 h0012345.associatesys.local systemd[1]: start request repeated too quickly for telegraf.service
Oct 21 12:18:38 h0012345.associatesys.local systemd[1]: Failed to start The plugin-driven server agent for repor…xDB.
Oct 21 12:18:38 h0012345.associatesys.local systemd[1]: Unit telegraf.service entered failed state.
Oct 21 12:18:38 h0012345.associatesys.local systemd[1]: telegraf.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

Your status output shows that Telegraf is looking in the telegraf.conf.d directory and for the telegraf.conf file. I would check to make sure that the /etc/telegraf/telegraf.conf file does not have the InfluxDB output enabled.

Also to get the full un-clipped telegraf logs I like to run: journalctl -xe --no-pager -u telegraf

1 Like