Splunk Search

extract http response code

praveenvvn
Explorer

I have events consisting of a msg field with data like below:

dev.scurry.com - [2020-01-05T19:08:10.7658789Z] "PUT /case-pst/msging/eith/TNT/2020-01-05/blob/tenthouse.txt HTTP/1.1" 200 0 61814 "-" "-" "182.236.164.11:25412" "182.236.0.0:12001" x_forwarded_for:"182.236.164.11, 182.236.164.11" x_forwarded_proto:"https" vcap_request_id:"asdf098a0-j453-8asdf8-876-8907asdf9087" response_time:0.079841 gorouter_time:0.000152 app_id:"asdf098a0-j453-8asdf8-876-8907asdf9087" app_index:"0" x_cf_routererror:"-" x_b3_traceid:"asdf098as78987" x_b3_spanid:"7a7sad9898d90khjk" x_b3_parentspanid:"-" q3:"7asdf987987asdf9-78968asfdklj"

I need to extract the http status code and only for PUT requests.

Am new to regex. Any advise or pointers.

Thanks.

Labels (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

This should do it.

| rex field=msg "\\\"PUT [^\\\"]+\\\" (?<errorCode>\d+)"
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

This should do it.

| rex field=msg "\\\"PUT [^\\\"]+\\\" (?<errorCode>\d+)"
---
If this reply helps you, Karma would be appreciated.
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...