我想使用 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
1 回答

繁星coding
TA贡献1797条经验 获得超4个赞
replacement 配置选项指定您要为任何匹配项替换的内容。
我想你想要更接近于此的东西:
[[processors.regex.fields]]
key = "message"
pattern = '.*Relayed.{3}(?P<UPSTREAM>\d{1,4}\W.B),.*$'
replacement = "${1}"
result_key = "upstream"
要得到:
upstream="60 MB"
- 1 回答
- 0 关注
- 159 浏览
添加回答
举报
0/150
提交
取消