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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...