Reputation: 373
I have a splunk log
LOG: "TOTAL NUMBER OF RECORDS IS:0"
I need to Query it in a way that it find a log message if the number of records turn out to be more than 0
I have tried the following
sourcetype=mylogs | rex "\d+:\d+:\d+\s(?<TOTAL NUMBER OF RECORDS IS:>\d+)$" | where TOTAL NUMBER OF RECORDS IS:>=25
It gives a terminator Error
Upvotes: 5
Views: 31470
Reputation: 33
This did not work for me, may be different splunk versions. I wanted to get "An event at a delay of 102" log for values greater than 100.
Below query worked.
index="***" sourcetype="***" "An event" | rex "An event at a delay of (?<delay>[0-9]+)" | where delay > 100
Upvotes: 3
Reputation: 9916
There are a few things wrong with that query.
TOTAL NUMBER OF RECORDS IS:(?<field>\d+)
. You may even get by with :(?<field>\d+)
.TotalNumberOfRecords
.Try this query:
sourcetype=mylogs | rex ":\d+(?<TotalNumberOfRecords>\d+)" | where TotalNumberOfRecords>=25
Upvotes: 4
Reputation: 556
Here's an example SPL to suit your requirement:
| makeresults
| eval _raw="TOTAL NUMBER OF RECORDS IS:10"
| rex field=_raw "TOTAL NUMBER OF RECORDS IS:(?<record_num>.\d+)"
| where record_num > 0
Line-by-line Explanation:
_raw
and store it in record_num
field.where
clause to filter results.Upvotes: 0