转换器处理器插件
此插件允许将标签转换为字段或时间戳,并将字段转换为标签或时间戳。此外,该插件还允许更改字段类型。
在将标签转换为字段时,请务必确保系列仍然可以唯一标识。具有相同系列键(度量 + 标签)的字段会相互覆盖。
引入于: Telegraf v1.7.0 标签: transformation 操作系统支持: all
全局配置选项
插件支持其他全局和插件配置设置,用于修改指标、标签和字段,创建别名以及配置插件顺序等任务。更多详情请参阅 CONFIGURATION.md。
配置
# Convert values to another metric value type
[[processors.converter]]
## Tags to convert
##
## The table key determines the target type, and the array of key-values
## select the keys to convert. The array may contain globs.
## <target-type> = [<tag-key>...]
[processors.converter.tags]
measurement = []
string = []
integer = []
unsigned = []
boolean = []
float = []
## Optional tag to use as metric timestamp
# timestamp = []
## Format of the timestamp determined by the tag above. This can be any of
## "unix", "unix_ms", "unix_us", "unix_ns", or a valid Golang time format.
## It is required, when using the timestamp option.
# timestamp_format = ""
## Fields to convert
##
## The table key determines the target type, and the array of key-values
## select the keys to convert. The array may contain globs.
## <target-type> = [<field-key>...]
[processors.converter.fields]
measurement = []
tag = []
string = []
integer = []
unsigned = []
boolean = []
float = []
## Optional field to use for converting base64 encoding of IEEE 754 Float32 values
## (for example, data_json_content_state_openconfig-platform-psu:output-power":"RKeAAA==")
## into a float32 value 1340
# base64_ieee_float32 = []
## Optional field to use as metric timestamp
# timestamp = []
## Format of the timestamp determined by the field above. This can be any
## of "unix", "unix_ms", "unix_us", "unix_ns", or a valid Golang time
## format. It is required, when using the timestamp option.
# timestamp_format = ""转换类型时,无法转换的值将被丢弃。
将字符串值转换为数字类型时,如果数字太大,可能会丢失精度。此插件支持的最大数字类型是 float64,如果字符串“数字”超出其大小限制,可能会丢失精度。
用户可以提供多个标签或字段用作测量名称或时间戳。但请注意,数组中的顺序不保证!
示例
将 port 标签转换为字符串字段
[[processors.converter]]
[processors.converter.tags]
string = ["port"]- apache,port=80,server=debian-stretch-apache BusyWorkers=1,BytesPerReq=0
+ apache,server=debian-stretch-apache port="80",BusyWorkers=1,BytesPerReq=0
将所有 scboard_* 字段转换为整数
[[processors.converter]]
[processors.converter.fields]
integer = ["scboard_*"]- apache scboard_closing=0,scboard_dnslookup=0,scboard_finishing=0,scboard_idle_cleanup=0,scboard_keepalive=0,scboard_logging=0,scboard_open=100,scboard_reading=0,scboard_sending=1,scboard_starting=0,scboard_waiting=49
+ apache scboard_closing=0i,scboard_dnslookup=0i,scboard_finishing=0i,scboard_idle_cleanup=0i,scboard_keepalive=0i,scboard_logging=0i,scboard_open=100i,scboard_reading=0i,scboard_sending=1i,scboard_starting=0i,scboard_waiting=49i
从标签值重命名测量
[[processors.converter]]
[processors.converter.tags]
measurement = ["topic"]- mqtt_consumer,topic=sensor temp=42
+ sensor temp=42
从标签设置度量时间戳
[[processors.converter]]
[processors.converter.tags]
timestamp = ["time"]
timestamp_format = "unix- metric,time="1677610769" temp=42
+ metric temp=42 1677610769
也可以通过字段转换器实现此目的。
此页面是否有帮助?
感谢您的反馈!
支持和反馈
感谢您成为我们社区的一员!我们欢迎并鼓励您对 Telegraf 和本文档提出反馈和 bug 报告。要获取支持,请使用以下资源
具有年度合同或支持合同的客户可以 联系 InfluxData 支持。