Splunk Search

How to extract a string from _raw?

avadhutha
Explorer

I have a string like below and unable to extract accuratly with rex command please suggest  any alternative way.

_raw----------------

{lable:harish,message: Say something, location:India, state:TS,qual:xyz}

{message: say nothing,lable:harish, location:India, state:TS,qual:xyz}

{lable:harish, location:India, state:TS,qual:xyz,message: say splunk splunk answers}

 

The message value is randomized location and I need to pick the message value.

 

When I try with below command it is not considering the proper end position. Please suggest

|rex "message:(?<Message_value>.*)[,|}]" |table Message_Value

Labels (2)
Tags (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Field names are case-sensitive, also, you are using a greedy match which may pick up more than you bargained for - try this

|rex "message:(?<Message_Value>.*?)[,|}]" |table Message_Value

 

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Field names are case-sensitive, also, you are using a greedy match which may pick up more than you bargained for - try this

|rex "message:(?<Message_Value>.*?)[,|}]" |table Message_Value

 

0 Karma

avadhutha
Explorer

Thank you so much.., I was trying a lot of thing like field extraction and regex and you helped it well with ?.

0 Karma
Get Updates on the Splunk Community!

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...

Index This | What goes away as soon as you talk about it?

May 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this month’s ...

What's New in Splunk Observability Cloud and Splunk AppDynamics - May 2025

This month, we’re delivering several new innovations in Splunk Observability Cloud and Splunk AppDynamics ...