Splunk Search

SPL-Search based on mutiple values

srs20
New Member

Hello,

i'm searching for a certain condition and wrote the query below .It works but not quite what I'm looking for

index="xyz" earliest=-18h (pidId=1 OR pidId=2 ) | stats count(eval(value>22)) AS count_status BY pidId | where count_status>=3

What I'm looking for is
pidId=1 and value >22 and occurs 3 or more times in 18 hours
AND
pidId=2 and value >37 and occurs 3 or more times in 18 hours

How can I do this?
Thanks,

0 Karma

woodcock
Esteemed Legend

Like this:

index="xyz" earliest=-18h (pidId=1 OR pidId=2 )
| stats count(eval(value>22)) AS count22plus count(eval(value>33)) AS count33plus BY pidId
| where (pidId==1 AND count22plus>=3) OR (pidId==2 AND count33plus>=3)
0 Karma

srs20
New Member

Thanks for the response.This returns null values for the first eval command and correct values for the second stats eval ..so in this case count22plus is null and count37plus is null. If I change the sequence i.e.

| stats count(eval(value>37)) as count37plus count(eval(value>22)) AS count22plus BY pidId

The command above gets the value of count22 but not count37. So,it always the second eval returning results but never the first

0 Karma

woodcock
Esteemed Legend

That is because it is never true (there are none to count)!

0 Karma

sumanssah
Communicator

Try this

index="xyz" ((pidId=1 AND value >22) OR (pidId=2 AND value >37))
| stats dc(value) as dc_value by pidId
| where dc_value > 3

srs20
New Member

Thanks,this returns results. Will need more time to validate.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

If I understand what you're looking for, this may help.

index="xyz" earliest=-18h (pidId=1 OR pidId=2 ) 
| stats count(eval(value>22)) AS count22, count(eval(value>37)) as count37 BY pidId
| where (pidId=1 AND count22>=3) OR (pidId=2 AND count37>=3)
---
If this reply helps you, Karma would be appreciated.
0 Karma

srs20
New Member

Thanks for the response.This returns null values for the first eval command and correct values for the second stats eval ..so in this case count22 is null and count37 is null. If I change the sequence i.e.

| stats count(eval(value>37)) as count37 count(eval(value>22)) AS count22 BY pidId

The command above gets the value of count22 but not count37. So,it always the second eval returnign results but never the first

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...