Splunk Search

How to write count of (SUM(X,Y,Z)) instead of count of (X OR Y OR Z) ?

achetreanu
New Member

How can I change this query to count the SUM of my events/sec instead of the count of (X OR Y OR Z)/sec :

host=myhost "X" OR "Y" OR "Z" | bucket _time span=1s | chart count over _time

Thank you!- A.C.

Tags (1)
0 Karma
1 Solution

DalJeanis
Legend

Try this for the hour that you had the problem -

host=myhost "Received INVITE" OR "Sent Invite" OR "Sent re-Invite" 
| eval XCount= if(match(_raw,"Received INVITE"),1,0)
| eval YCount= if(match(_raw,"Sent Invite" ),1,0)
| eval ZCount= if(match(_raw,"Sent re-Invite"),1,0)
| eval TCount= 1
| eval UCount=XCount+YCount+ZCount
| search Tcount!=UCount

If that gets no individual events that count as more than one type, then remove the last line and continue with this -

| bucket _time span=1h 
| eventstats 
    count as CountSum, sum(TCount) as TSum, sum(UCount) as USum,
    sum(XCount) as XSum, sum(YCount) as YSum, sum(ZCount) as ZSum 
    by _time
| where TSum != USum

That will return only the events that are in an hour where the two sums do not match, for further review.

View solution in original post

Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...