Splunk Search

How to edit my search to get the counts and eval results for each value of a certain field?

Catie_Carmody
Engager

The below returns the correct results, but I only get the RequestOne, RequestTwo, and meetscriteria fields when field1= test:

sourcetype=application_log field1= test | stats count(eval(match(_raw, "Request 1"))) AS "RequestOne", count(eval(match(_raw, "Request 2"))) AS "RequestTwo" | eval meetscriteria = if(('Request1' >= 100 AND 'Request2' > 0), "OK", "No")

I have many fields for field1 though and want to capture the counts and "meetscriteria" information for each value of field1. How can I capture this information?

I have also saved these using eventtypes and tags, but you can't group on these? Do I need to use a lookup table or a join?

0 Karma
1 Solution

Catie_Carmody
Engager

I resolved it by adding a "by field1" in the second pipe and removing the field1 criteria from the initial search:

sourcetype=application_log | stats count(eval(match(_raw, "Request 1"))) AS "RequestOne", count(eval(match(_raw, "Request 2"))) AS "RequestTwo" by field1| eval meetscriteria = if(('Request1' >= 100 AND 'Request2' > 0), "OK", "No")

I had originally created eventtypes for both "Request 1" and "Request 2", but this seemed limited such that I couldn't run eval against eventtypes or do groupings.

View solution in original post

0 Karma

Catie_Carmody
Engager

I resolved it by adding a "by field1" in the second pipe and removing the field1 criteria from the initial search:

sourcetype=application_log | stats count(eval(match(_raw, "Request 1"))) AS "RequestOne", count(eval(match(_raw, "Request 2"))) AS "RequestTwo" by field1| eval meetscriteria = if(('Request1' >= 100 AND 'Request2' > 0), "OK", "No")

I had originally created eventtypes for both "Request 1" and "Request 2", but this seemed limited such that I couldn't run eval against eventtypes or do groupings.

0 Karma

sundareshr
Legend

Change field1=test to field1=* or remove the field1= criteria altogether.

0 Karma
Get Updates on the Splunk Community!

Machine Learning - Assisted Adaptive Thresholding

Let’s talk thresholding. Have you set up static thresholds? Tired of static thresholds triggering false ...

Observability Unlocked: Kubernetes Monitoring with Splunk Observability Cloud

  Ready to master Kubernetes and cloud monitoring like the pros?Join Splunk’s Growth Engineering team for an ...

Wrapping Up Cybersecurity Awareness Month

October might be wrapping up, but for Splunk Education, cybersecurity awareness never goes out of season. ...