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!

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...

Weezer at .conf25? Say it ain’t so!

Hello Splunkers, The countdown to .conf25 is on-and we've just turned up the volume! We're thrilled to ...

How SC4S Makes Suricata Logs Ingestion Simple

Network security monitoring has become increasingly critical for organizations of all sizes. Splunk has ...