Splunk Search

How do I edit my regex to extract this field from my sample event?

athorat
Communicator

Want to extract only /ubi-v2/api/scoresummary from the below mentioned event in a field.
Rex used:

`| rex "(?<remote_addr>[^\s]*) -(| ) (| )- \[(?<time_local>[^\]]*)\] \"(?<request>[^\"]*)\" (?<status>[^\s]*) (?<body_bytes_sent>[^\s]*)"

Event:

172.26.129.10 - - [16/Feb/2016:23:59:55 -0700] "GET /ubi-v1/api/ubidevicestatus?vin=1N4AL3AP3DC114528 HTTP/1.1" 500 1696

Don't need the entire "GET" Request,Tried using (GET[^\?]*) but that does not get any results
Thanks for looking into this.

0 Karma
1 Solution

somesoni2
Revered Legend

Try like this (run anywhere sample, first two lines are only to generate data, replace that with your base search)

| gentimes start=-1 | eval _raw="172.26.129.10 - - [16/Feb/2016:23:59:55 -0700] \"GET /ubi-v1/api/ubidevicestatus?vin=1N4AL3AP3DC114528  HTTP/1.1\" 500 1696" | table _raw
| rex "(?<remote_addr>[^\s]*)\s+\S+\s+\S+\s+\[(?<time_local>[^\]]*)\] \"(?<method>\S+)\s+(?<request>[^?\"\s]*).*\" (?<status>[^\s]*) (?<body_bytes_sent>[^\s]*)"

View solution in original post

0 Karma

somesoni2
Revered Legend

Try like this (run anywhere sample, first two lines are only to generate data, replace that with your base search)

| gentimes start=-1 | eval _raw="172.26.129.10 - - [16/Feb/2016:23:59:55 -0700] \"GET /ubi-v1/api/ubidevicestatus?vin=1N4AL3AP3DC114528  HTTP/1.1\" 500 1696" | table _raw
| rex "(?<remote_addr>[^\s]*)\s+\S+\s+\S+\s+\[(?<time_local>[^\]]*)\] \"(?<method>\S+)\s+(?<request>[^?\"\s]*).*\" (?<status>[^\s]*) (?<body_bytes_sent>[^\s]*)"
0 Karma
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...