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!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...