将动态标签添加到telegraf输入

时间:2017-07-18 07:33:24

标签: telegraf

我们正在使用telegraf从AWS收集CloudWatch数据并将其输出到InfluxDB。

我们需要在输入中添加动态标记,如果"instancId == 12345",则添加标记"user = 3"

有办法做到这一点吗?

2 个答案:

答案 0 :(得分:2)

看看processors。如果您只想使用一组已知值,那么我认为enum是最好的选择。这是为您的情况更新的示例:

[[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

答案 1 :(得分:0)

请参阅CONFIGURATION.md文档:

[[inputs.cpu]]
  percpu = false
  totalcpu = true
  [inputs.cpu.tags]
    tag1 = "foo"
    tag2 = "bar"