Splunk Search

Why am I unable to return the correct count of all events with FieldA that contain ValueA?

kabiraj
Path Finder

Hi All,

I am facing some problem with my below search:

sourcetype="clientevents" event_error_code=RB_VOD_BUFFER_UNDERFLOW eventItemID="*" | stats count(eval(eventItemID="*BT*")) as "BT_VOD_buffer_underrun_count" count(eval(eventItemID!="")) as "Total_VOD_buffer_underrun_count" 

Here the "BT_VOD_buffer_underrun_count" is always returning zero. The problem lies with count(eval(eventItemID="*BT*")). I have also tried searchmatch, but every time it returns an error.

I want to count all events with "eventItemID" field containing "BT" in its value.

Please help.
Please help.

Tags (3)
0 Karma
1 Solution

laserval
Communicator

You should be able to use like() in the eval expression to match with wildcards:

sourcetype="clientevents" event_error_code=RB_VOD_BUFFER_UNDERFLOW eventItemID="*" | stats count(eval(like(eventItemID,"%BT%"))) as "BT_VOD_buffer_underrun_count" count(eval(!like(eventItemID, "%BT%"))) as "Total_VOD_buffer_underrun_count" 

But it would be less verbose to eval a field first, and do the stats on that, something like:

sourcetype="clientevents" event_error_code=RB_VOD_BUFFER_UNDERFLOW eventItemID="*" | eval eventItemIdType=if(like(eventItemID,"%BT%"), "BT_VOD_buffer_underrun_count", "Total_VOD_buffer_underrun_count") | stats count by eventItemIdType

View solution in original post

laserval
Communicator

You should be able to use like() in the eval expression to match with wildcards:

sourcetype="clientevents" event_error_code=RB_VOD_BUFFER_UNDERFLOW eventItemID="*" | stats count(eval(like(eventItemID,"%BT%"))) as "BT_VOD_buffer_underrun_count" count(eval(!like(eventItemID, "%BT%"))) as "Total_VOD_buffer_underrun_count" 

But it would be less verbose to eval a field first, and do the stats on that, something like:

sourcetype="clientevents" event_error_code=RB_VOD_BUFFER_UNDERFLOW eventItemID="*" | eval eventItemIdType=if(like(eventItemID,"%BT%"), "BT_VOD_buffer_underrun_count", "Total_VOD_buffer_underrun_count") | stats count by eventItemIdType

laserval
Communicator

Note that the second search gives a different result, so you probably want to modify it.

0 Karma

kabiraj
Path Finder

Thanks laserval!

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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...