Splunk Search

Extracting a field in quotes with regex

mkulicke
Explorer

Hi, I'm having trouble with a regex field extraction. I'm looking to extract the numeric ID after the "x-client-id" key:

.........pp_code":["{IVR-US}. CPC"],"x-client-id":["1234567890"],"x-requested-with":["DA_ONLINE_IV............

This is how that field appears in the event string. This (client-id) is the only field I need in the entire string. The quotes are throwing off all of my normal regex formats.

Any help would be super appreciated.

Labels (4)
0 Karma
1 Solution

ashvinpandey
Contributor

@mkulicke Try using the below rex:

| rex field=_raw "x-client-id\"\:\[\"(?P<client_id>\d+)"

Also, If this reply helps you, an upvote would be appreciated.

View solution in original post

ashvinpandey
Contributor

@mkulicke Try using the below rex:

| rex field=_raw "x-client-id\"\:\[\"(?P<client_id>\d+)"

Also, If this reply helps you, an upvote would be appreciated.

mkulicke
Explorer

Works like a charm, thanks for your help!

0 Karma
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 ...