将动态标签添加到 telegraf 输入
Adding dynamic tags to telegraf input
我们正在使用 telegraf 从 AWS 收集 CloudWatch 数据并将其输出到 InfluxDB。
我们需要给输入添加动态标签,s.t如果"instancId == 12345"
,添加标签"user = 3"
有办法吗?
请参阅 CONFIGURATION.md 文档:
[[inputs.cpu]]
percpu = false
totalcpu = true
[inputs.cpu.tags]
tag1 = "foo"
tag2 = "bar"
看看 processors
. If you have just a set of known values that you want to work with, I think 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
我们正在使用 telegraf 从 AWS 收集 CloudWatch 数据并将其输出到 InfluxDB。
我们需要给输入添加动态标签,s.t如果"instancId == 12345"
,添加标签"user = 3"
有办法吗?
请参阅 CONFIGURATION.md 文档:
[[inputs.cpu]]
percpu = false
totalcpu = true
[inputs.cpu.tags]
tag1 = "foo"
tag2 = "bar"
看看 processors
. If you have just a set of known values that you want to work with, I think 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