Splunk Search

Multiple where count > in the same string

sanorthrup
Path Finder

We always see some failures in our logs. But when we have an issue, the number of failures goes thru the roof. I'm trying to combine all the failures types and the threshold we've specified into a single search. I can create a bunch of individual searches/alerts, but I'd really like to combine them.
Here's a single/working one:
index=foo "FailureReason=24403" earliest=-30m | stats count by host | where count >20

Here's where I attempted to combine two
index=foo earliest=-30m | stats count by host where count(FailureReason=24403) >20 OR count(FailureReason=22056) > 500

But obviously something is wrong with my search/syntax. Can anyone help please?

Thanks

Tags (1)
0 Karma
1 Solution

Nicolo_Figiani
Path Finder

Hi,
the following one should work:

index=foo earliest=-30m
| stats count(eval(FailureReason=24403)) AS fr_24403, count(eval(FailureReason=22056)) AS fr_22056 by host
| where fr_24403>20 AND fr_22056>500

As you can see stats command can do pretty neat tricks but its syntax is not really straightorward. more info here: stats extended examples

Hope it helps,
regards

View solution in original post

sanorthrup
Path Finder

Sorry guys, neither of the above work. One user recommended that I try:

index=foo earliest=-30m
 | rex field=_raw "FailureReason\=(?[\d]+)"
 | search FailureReason=*
 | stats count by host, FailureReason
 | where (FailureReason=24403 and count > 20) OR (FailureReason=22056 and count > 500)

Which is the only one so far that works

0 Karma

sundareshr
Legend

Try this

index=foo (FailureReason=24403 OR FailureReason=22056) earliest=-30m | chart count over host by FailureReason | where 24403>20 OR 22056>500

Nicolo_Figiani
Path Finder

Hi,
the following one should work:

index=foo earliest=-30m
| stats count(eval(FailureReason=24403)) AS fr_24403, count(eval(FailureReason=22056)) AS fr_22056 by host
| where fr_24403>20 AND fr_22056>500

As you can see stats command can do pretty neat tricks but its syntax is not really straightorward. more info here: stats extended examples

Hope it helps,
regards

Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...