Splunk Search

How to use stats count where OR stats count where on different fields?

vwilson3
Path Finder

Greetings,

I'm pretty new to Splunk. I have to create a search/alert and am having trouble with the syntax. This is what I'm trying to do:
index=myindex field1="AU" field2="L"
|stats count by field3 where count >5 OR count by field4 where count>2

Any help is greatly appreciated.

Tags (1)
0 Karma

vwilson3
Path Finder

Still working on this. Thank you for your suggestions!

0 Karma

woodcock
Esteemed Legend

Be sure to UpVote helpful answers even if you can't Accept one of them.

vwilson3
Path Finder

Thank you, woodcock! I appreciate the guidance. I hope I did it correctly.

0 Karma

woodcock
Esteemed Legend

Maybe this:

index=myindex field1="AU" field2="L"
| fillnull value="N/A" field3 field4
|stats count BY field3 field4
| multireport
[ stats sum(count) AS f3count BY field3 | where f3count>5]
[ stats sum(count) AS f4count BY field4 | where f4count>2]

renjith_nair
SplunkTrust
SplunkTrust

Hi @vwilson3,

Probably you are looking for something similar?

index=myindex field1="AU" field2="L"
|stats dc(field3) as field3,dc(field4) as field4 |where (field3>5 OR field4>2)
Happy Splunking!

richgalloway
SplunkTrust
SplunkTrust

The stats command does not have a where clause and only has a single by clause.

What are you trying to accomplish with your sample query? Once you explain what results you want to get, we may be able to help you get them.

---
If this reply helps you, Karma would be appreciated.

vwilson3
Path Finder

I am trying to find events that match field1 and field2, and match field3 if there are more than 5 or match field4 if there are more than 2.

Thanks for the info.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...