Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding dynamic tags to telegraf input

Tags:

telegraf

We're using telegraf to collect CloudWatch data from AWS and output it to InfluxDB.

We need to add dynamic tags to the input, s.t if "instancId == 12345", add tag "user = 3"

Is there a way to do this?

like image 765
Yossale Avatar asked Jul 18 '17 07:07

Yossale


2 Answers

Take a look at the processors. If you have just a set of known values that you want to work with, I think enum would be the best option. Here is the example updated for your case:

[[processors.enum]]
  [[processors.enum.mapping]]
    ## Name of the field to map
    field = "instancId"

    ## Destination field to be used for the mapped value.  By default the source
    ## field is used, overwriting the original value.
    dest = "user"

    ## Default value to be used for all values not contained in the mapping
    ## table.  When unset, the unmodified value for the field will be used if no
    ## match is found.
    default = 0

    ## Table of mappings
    [processors.enum.mapping.value_mappings]
      123 = 1
      1234 = 2
      12345 = 3
like image 161
Stoinov Avatar answered Oct 03 '22 21:10

Stoinov


See the CONFIGURATION.md docs:

[[inputs.cpu]]
  percpu = false
  totalcpu = true
  [inputs.cpu.tags]
    tag1 = "foo"
    tag2 = "bar"
like image 33
Olivier Avatar answered Oct 03 '22 21:10

Olivier