Splunk Search

How to extract desired data from search result?

sneha03
New Member

Hi Team,

We are trying below search:

 

index=index_123 host=xyz source="/sys_apps_01/pqr/logs/xyz/mapper_xyz.log" ContextKeyMatch: Context Field Value 

 

which gives below results with multiple rows as below:

sneha03_0-1652269980209.png

Now we want to extract data after Context Filed Value. The string having "Context Filed Value" is of variable string length

We have multiple rows like above and we need to extract such data from each row. like : 005436213114023275.

Once we have the extracted data we need to fetch only  last 12 digits

Could you please suggest regarding this?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

| rex "Context Field Value\s+\d*(?<value>\d{12})"
0 Karma

PickleRick
SplunkTrust
SplunkTrust

Ideally, you should have this defined as an automatically extracted field so you don't have to do it ad-hoc every time. But for a one-off extraction you can do it with the rex command. Something like this:

<your search>
| rex "Context Filed Value.*(?<my_field>\d{12})$"

 

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

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...

Introduction to Splunk AI

How are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. Lucky for ...