![](/img/trans.png)
[英]Splunk query using “rex” fails with Error in 'SearchParser': Missing a search command before '^' on REST API
[英]splunk rex command to search exception and count the error codes
我有看起來像這樣的原始數據:
[6/24/22 6:45:20:277 IST] 000005d4 Output O abcd-ddd-dd.ppp1.ttttttt.net sys 2022-06-24T06:45:20,277 WARN [Server.BatchProcess] Limoc Input : Exception occurred: 100 COMPRESS 'success' EEEE08EE.ERROR-TEXT(1) null
[6/24/22 6:45:20:277 IST] 000005d4 Output O abcd-ddd-dd.ppp1.ttttttt.net sys 2022-06-24T06:45:20,277 WARN [Server.BatchProcess] Limoc Input : Exception occurred: 101 COMPRESS 'success' EEEE08EE.ERROR-TEXT(2) null
我需要 rex 命令的幫助,該命令可以過濾所有帶有“ Limoc Input : Exception occurred: 100
” “ Limoc Input : Exception occurred: 101
” 和類似的消息,並對它們進行計數並打印下面的消息“ COMPRESS 'success' EEEE08EE.ERROR-TEXT(1) null
”。 例如:
100 COMPRESS 'success' EEEE08EE.ERROR-TEXT(1) null 2
101 COMPRESS 'success' EEEE08EE.ERROR-TEXT(2) null 3
看看這個到處跑的搜索是否能讓你朝着正確的方向前進。
| makeresults
| eval data="[6/24/22 6:45:20:277 IST] 000005d4 Output O abcd-ddd-dd.ppp1.ttttttt.net sys 2022-06-24T06:45:20,277 WARN [Server.BatchProcess] Limoc Input : Exception occurred: 100 COMPRESS 'success' EEEE08EE.ERROR-TEXT(1) null
[6/24/22 6:45:20:277 IST] 000005d4 Output O abcd-ddd-dd.ppp1.ttttttt.net sys 2022-06-24T06:45:20,277 WARN [Server.BatchProcess] Limoc Input : Exception occurred: 101 COMPRESS 'success' EEEE08EE.ERROR-TEXT(2) null"
| eval data=split(data,"
")
| mvexpand data
| eval _raw=data
| fields - data
```Everything above just sets up test data. Omit IRL```
```Extract the exception number and text which follows```
| rex "Limoc Input : Exception occurred: (?<Exception>10[01]) (?<DisplayText>.*)"
```Count the occurrences. Copy the text.```
| stats values(DisplayText) as DisplayText, count by Exception
```Display the results```
| table DisplayText count
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.