Possible to add/force a static tag=value pair in /etc/telegraf/telegraf.d?

So I have many conf files in /etc/telegraf/telegraf.d
a.conf
b.conf
c.conf

Am I able to add a static tag = “value” into a.conf which is not impacting all of other conf files?

I’ve tried to use [global_tags] but that literally adds that tag into all measurements being collected by telegraf agent run on that server.

Example of my hypothetical use in which I’d like to force a new tag “url” which is NOT present in the json data:

[[inputs.file]]
  interval = "5m"
  files = ["/tmp/coingecko.json"]
  name_override = "coingecko"
  data_format = "json"
  url = "coingecko.com"

Hi,

Sounds like you want to add tags to a specific input plugin. You can do this by adding the following “tags” to your config above:

[[inputs.file]]
  interval = "5m"
  files = ["/tmp/coingecko.json"]
  name_override = "coingecko"
  data_format = "json"
  url = "coingecko.com"

  [inputs.file.tags]
    tag1 = "foo"
    tag2 = "bar"

There is not a way to do this per-file, as all the files are read in together. Also, note that these tag declarations need to come at the end of the TOML definition.

1 Like

Cool, that might work. But your statement…

There is not a way to do this per-file, as all the files are read in together

…got me worried a lil bit…so let me ask this first:
So in case in file b.conf I have also [[inputs.file]] plugin collecting data completely unrelated to what’s in a.conf
Are the tags defined in a.conf being written in the measurement defined in b.conf?

No - only if you setup global tags.

1 Like