我想使用 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 關注
- 144 瀏覽
添加回答
舉報
0/150
提交
取消