亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Telegraf:如何使用正則表達式處理器從字段中提???

Telegraf:如何使用正則表達式處理器從字段中提取?

Go
慕娘9325324 2023-03-15 15:20:03
我想使用 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"


查看完整回答
反對 回復 2023-03-15
  • 1 回答
  • 0 關注
  • 144 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號