我想使用 telegraf 正則表達(dá)式處理器插件從此輸入中提取連接、上游和下游的值:2022/11/16 22:38:48 In the last 1h0m0s, there were 10 connections. Traffic Relayed ↑ 60 MB, ↓ 4 MB.使用此配置,結(jié)果鍵“upstream”是初始消息的副本,但沒有“regexed”內(nèi)容的一部分。[[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"當(dāng)前輸出:2022/11/17 10:38:48 In the last 1h0m0s, there were 1 connections. Traffic 3 MB ↓ 5 MB.我如何獲得小數(shù)?我對如何在這里使用正則表達(dá)式感到有點(diǎn)困惑,因?yàn)樵诰W(wǎng)絡(luò)上的幾個(gè)例子中它應(yīng)該像這樣工作。參見示例:http ://wiki.webperfect.ch/index.php?title=Telegraf:_Processor_Plugins
1 回答

繁星coding
TA貢獻(xiàn)1797條經(jīng)驗(yàn) 獲得超4個(gè)贊
replacement 配置選項(xiàng)指定您要為任何匹配項(xiàng)替換的內(nèi)容。
我想你想要更接近于此的東西:
[[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 關(guān)注
- 155 瀏覽
添加回答
舉報(bào)
0/150
提交
取消