Path: Made a unique telegraf.conf with multiples files


I would path differents “[input.X] block” file inside telegraf.conf ? is it possible ?


Inside telegraf.conf:

include /etc/telegraf/file_name_input

file name_input:
–beginning of file –

agents = [ “” ]
version = 2
community = “public”

name = “hostname”
oid = “RFC1213-MIB::sysName.0”
is_tag = true

name = “uptime”
oid = “DISMAN-EXPRESSION-MIB::sysUpTimeInstance”

IF-MIB::ifTable contains counters on input and output traffic as well as errors and discards.
name = “interface”
inherit_tags = [ “hostname” ]
oid = “IF-MIB::ifTable”
–end of file –

Thanks for your help

Good day,
You don’t need to include another file, just add multiple valid input blocks to your main telegraf.conf.

Example telegraf.conf:

  servers = ["root:telegraf@tcp(mysql:3306)/"]

  servers = ["root:telegraf@tcp(maria:3306)/"]
  gather_user_statistics = false

  servers = ["root:telegraf@tcp(percona:3306)/"]

  files = ["stdout"]

Sorry, maybe I wasn’t being clear in my demand

I would be able to manege my configuration file (telegraf.conf) thanks to different files.

a file for each " valid input blocks ". Like this I will be able to change my configuration without modifying directly in telegraf.conf

is Telegraf able to go read in an other file a part of its configuration?

Example telegraf.conf:

#To have this go read file /etc/telegraf/mysql_file instead to read and write it directly in telegraf.conf

servers = [“root:telegraf@tcp(mysql:3306)/”]

servers = [“root:telegraf@tcp(maria:3306)/”]
gather_user_statistics = false

servers = [“root:telegraf@tcp(percona:3306)/”]

#To have this go read file /etc/telegraf/outfile_file
files = [“stdout”]

–inside telegraf.conf –

It will be more easy to change my configuration file and avoid corruption of it

Yes, you can have Telegraf read from a directory and import all the .conf files there. From the documentation on configuration file locations:

The location of the configuration file can be set via the --config command line flag.

When the --config-directory command line flag is used files ending with .conf in the specified directory will also be included in the Telegraf configuration.

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.

1 Like

It works !
Thanks you very much for your answer !