Splunk Search

Splunk rex help

chanukhya
Explorer

I am trying to count the number of 200 response codes from an access log. can you please help in getting me the output.

26/Jan/2017:08:16:33 PST "POST /webservice/services/serviceABC HTTP/1.1" A_Cell/A_node/A_Cluster_jvm 117 118 200
26/Jan/2017:08:16:33 PST "POST /webservice/services/serviceABC HTTP/1.1" B_Cell/B_node/B_Cluster_jvm_2 164 819 200
26/Jan/2017:08:16:33 PST "POST /webservice/services/serviceABC HTTP/1.1" A_Cell/C_node/C_Cluster_jvm_1197 917 200

Log looks like the above. Is it possible to get the output of stats count by each cell, node and and each jvm? I dont need reading the response codes, because i am doing "* * 200" in base search

0 Karma
1 Solution

somesoni2
Revered Legend

Try like this

Updated based on new sample data

your base search | rex "^([^\"]+\"){2}\s+[^\/]+\/(?<node>[^\/]+)\/(?<jvm>\S+)\s+.+(?<response_code>\d+)$" | where response_code=200 | stats count by node jvm

View solution in original post

somesoni2
Revered Legend

Try like this

Updated based on new sample data

your base search | rex "^([^\"]+\"){2}\s+[^\/]+\/(?<node>[^\/]+)\/(?<jvm>\S+)\s+.+(?<response_code>\d+)$" | where response_code=200 | stats count by node jvm

chanukhya
Explorer

Thanks for the response, I also have the date and time in the log. Your regex is picking up "Jan". I dont actually care about method or URI. I just need stats by cell, node and jvm.

0 Karma

somesoni2
Revered Legend

Try the updated answer (original answer updated).

0 Karma

chanukhya
Explorer

Thanks for the answer. Is there a tool or way to get or learn how to use these regex codes?

0 Karma
Get Updates on the Splunk Community!

Index This | What did the zero say to the eight?

June 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this month’s ...

Splunk Observability Cloud's AI Assistant in Action Series: Onboarding New Hires & ...

This is the fifth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...

Now Playing: Splunk Education Summer Learning Premieres

It’s premiere season, and Splunk Education is rolling out new releases you won’t want to miss. Whether you’re ...