Splunk Search

how to: count(Values) where status=0

deanilol
Explorer

So I have the columns "Values" and "Status" and I only want to count Values where the status is zero. How can I do this?

here is my search:

source="*\\XML\\Example_Result\\Event_meter.xml" | table EventID EventName Value Status | join type=left EventID [search source="*\\XML\\Example_Result\\Event_map.xml" | where  EventType="Transaction" | table EventID EventName] | where EventID!=-1 | chart count(Value where status!=0) AS PASS, count(Value where status=0) AS FAIL by EventID

Thanks!

Tags (3)
0 Karma
1 Solution

aweitzman
Motivator

You want to use the following construction:

chart count(eval(status!=0)) as PASS count(eval(status=0)) as FAIL

(Question: Why the join? You already have EventName in the main search.)

View solution in original post

ngatchasandra
Builder

Hi,
Try, if you want to count only the values where status is 0, you can do this:

source="XMLExample_ResultEvent_meter.xml" | table EventID EventName Value Status | join type=left EventID [search source="XMLExample_ResultEvent_map.xml" | where EventType="Transaction" | table EventID EventName] | where EventID!=-1 OR  status==0 |chart count(Value) AS PASS  by EventID
0 Karma

aweitzman
Motivator

You want to use the following construction:

chart count(eval(status!=0)) as PASS count(eval(status=0)) as FAIL

(Question: Why the join? You already have EventName in the main search.)

Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...