Splunk Search

want to extract field values from log and perform stats on it.

nhatode
Engager

Hi,

Below is my Log:

"{"log":"{'URI': '/api/**/***/search?', 'METHOD': 'POST', 'FINISH_TIME': '2021-Dec-15 12:15:04 CST', 'PROTOCOL': 'http', 'RESPONSE_CODE': 202, 'RESPONSE_STATUS': '202 ACCEPTED', 'RESPONSE_TIME': 4.114464243873954} ","service_name":"Digdug/digdug","container":"Digdug-digdug-2","environment":"PROD"}"

 

Want to extract "RESPONSE_CODE" value 

And show like below
  

RESPONSE_CODECount
2021
2006



Thanks

Labels (1)
0 Karma
1 Solution

johnhuang
Motivator

| rex "RESPONSE_CODE\'\:\s(?<RESPONSE_CODE>\d+)"
| stats count as Count by RESPONSE_CODE

edit: looks like @richgalloway beat me to it. 

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Here's one way.

<your search for Log>
| rex "RESPONSE_CODE':\s*(?<RESPONSE_CODE>\d+)"
| stats count by RESPONSE_CODE
---
If this reply helps you, Karma would be appreciated.

johnhuang
Motivator

| rex "RESPONSE_CODE\'\:\s(?<RESPONSE_CODE>\d+)"
| stats count as Count by RESPONSE_CODE

edit: looks like @richgalloway beat me to it. 

Get Updates on the Splunk Community!

Index This | Why did the turkey cross the road?

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

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...