我在 LogZ 中有以下日志訊息,我想在將其作為警報轉發之前對其進行修剪:
[ {
"message" : "{\"level\":\"error\",\"msg\":\"Unexpected error! Contact the administrator!\",\"reason\":\"Error while unmarshalling the incoming data. Likely due to formats mismatch\",\"status\":\"500\",\"success\":false,\"time\":\"2022-02-15T18:47:08Z\"}\n"
}, {
"message" : "{\"level\":\"error\",\"msg\":\"Unexpected error! Contact the administrator!\",\"reason\":\"Error while unmarshalling the incoming data. Likely due to formats mismatch\",\"status\":\"500\",\"success\":false,\"time\":\"2022-02-15T18:47:06Z\"}\n"
}, {
"message" : "{\"level\":\"error\",\"msg\":\"Unexpected error! Contact the administrator!\",\"reason\":\"Error while unmarshalling the incoming data. Likely due to formats mismatch\",\"status\":\"500\",\"success\":false,\"time\":\"2022-02-15T18:47:05Z\"}\n"
} ]
由于 LogZ (Kibana) 支持正則運算式,因此主要想法是洗掉reason欄位以外的所有內容以及它所攜帶的訊息。那么無論如何我可以使用正則運算式以以下訊息結尾嗎?:
reason: Error while unmarshalling the incoming data. Likely due to formats mismatch
uj5u.com熱心網友回復:
當然,您可以使用positive look behindfrom stringreason\":\"并提取其后面的所有字符,直到\.
這里的例子:
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/427087.html
上一篇:正則運算式:與特定長度的數字相反
下一篇:python-如何在Python中將串列元素單獨與AND/ALL/多個模式匹配-list(),re.match()?
