Splunk Search

Field extraction using regex

dinesh001kumar
Engager

 Hi All,

Can anbody help us with the Regex expression to extract the feild of Channel: values will be either APP or Web which was highlighted in Sample logs below.

Sample Log1:

\\\":\\\"8E4B3815425627\\\",\\\"channel\\\":\\\"APP\\\"}\"","call_res_body":{},

Sample Log2:

4GksYUB7HGIfhfvs_iLtSc8EFCzOzbAJBze8wjXSDnwmgdhwjjxjsghqsxvhv\\\",\\\"channel\\\":\\\"web\\\"}\"","call_res_body":{},"additional_fields":{}}

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Firstly, this looks like it might be some sort of JSON, so you might be better of treating it as such.

However, if you wish to proceed with regex, then you could try something like this

| rex "channel[^\w]+(?<channel>APP|web)"

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Firstly, this looks like it might be some sort of JSON, so you might be better of treating it as such.

However, if you wish to proceed with regex, then you could try something like this

| rex "channel[^\w]+(?<channel>APP|web)"
0 Karma

PickleRick
SplunkTrust
SplunkTrust

Actually, it looks like some horribly disfigured json. It's twice escaped "->\"->\\\"

It might be smart to look into the ingestion process and try to optimize it.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

I agree with @PickleRick but sometimes this can be gotten around by reparsing fields with spath, but we can't tell this without seeing the full event.

0 Karma

Thulasinathan_M
Contributor

You can try something like below in rex command

channel[^A-Za-z]+(?<channel_type>[^\\]+)

 

0 Karma
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In November, the Splunk Threat Research Team had one release of new security content via the Enterprise ...

Index This | Divide 100 by half. What do you get?

November 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...

Stay Connected: Your Guide to December Tech Talks, Office Hours, and Webinars!

❄️ Celebrate the season with our December lineup of Community Office Hours, Tech Talks, and Webinars! ...