【问题标题】:Adding dynamic tags to telegraf input将动态标签添加到电报输入
【发布时间】:2018-11-13 06:11:45
【问题描述】:

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

我们需要在输入中添加动态标签,s.t 如果"instancId == 12345",添加标签"user = 3"

有没有办法做到这一点?

【问题讨论】:

    标签: telegraf


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      请参阅CONFIGURATION.md 文档:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-06-28
        • 2018-05-26
        • 1970-01-01
        • 2020-04-22
        • 1970-01-01
        • 1970-01-01
        • 2016-12-19
        • 1970-01-01
        相关资源
        最近更新 更多