我想使用 telegraf 正则表达式处理器插件从此输入中提取连接、上游和下游的值:
2022/11/16 22:38:48 In the last 1h0m0s, there were 10 connections. Traffic Relayed ↑ 60 MB, ↓ 4 MB.
使用此配置,结果键“upstream”是初始消息的副本,但没有“regexed”内容的一部分。
[[processors.regex]]
tagpass = ["snowflake-proxy"]
[[processors.regex.fields]]
## Field to change
key = "message"
## All the power of the Go regular expressions available here
## For example, named subgroups
pattern = 'Relayed.{3}(?P<UPSTREAM>\d{1,4}\W.B),'
replacement = "${UPSTREAM}"
## If result_key is present, a new field will be created
## instead of changing existing field
result_key = "upstream"
当前输出:
2022/11/17 10:38:48 In the last 1h0m0s, there were 1 connections. Traffic 3 MB ↓ 5 MB.
我如何获得小数?
我对如何在这里使用正则表达式感到有点困惑,因为在网络上的几个例子中它应该像这样工作。参见示例:http ://wiki.webperfect.ch/index.php?title=Telegraf:_Processor_Plugins
繁星coding
相关分类