Splunk Search

Count occurance of regex.

Nerz
Explorer

I have a data set as such:

id=20121,name=jack,score=60,difficulty= French written exam- LEVEL:hard,class 232
id=20121,name=steve,score=23,difficulty=French written exam-LEVEL:medium,class 234

I wish to count the amount of hard exams and medium exams, i know this seems simple and i have tried with rex fieldname=examtype("hard) but i don't know how to count the occurances of each in one search.

Tags (2)
0 Karma
1 Solution

sdaniels
Splunk Employee
Splunk Employee

If you have a field extracted for the class level then you could do this:

<your search> | stats count by class_level

Use the interactive field extractor to create the class_level field for you or whatever you want to call it. The link below will walk you through it in the docs.

http://docs.splunk.com/Documentation/Splunk/5.0/Knowledge/ExtractfieldsinteractivelywithIFX

video:
http://www.splunk.com/view/SP-CAAADUY

View solution in original post

sdaniels
Splunk Employee
Splunk Employee

If you have a field extracted for the class level then you could do this:

<your search> | stats count by class_level

Use the interactive field extractor to create the class_level field for you or whatever you want to call it. The link below will walk you through it in the docs.

http://docs.splunk.com/Documentation/Splunk/5.0/Knowledge/ExtractfieldsinteractivelywithIFX

video:
http://www.splunk.com/view/SP-CAAADUY

sdaniels
Splunk Employee
Splunk Employee

Glad to help

0 Karma

Nerz
Explorer

Thanks for your answer it provided me with the exact regex i required to count each value! Thanks!

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!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...