Splunk Search

Search comma surrounded phrase in _raw using rex

sai_shreyashi_p
New Member

In the logged data:

....,en,us,....(one record)
....,en,in,.....(another record)
(Here .... represents string data)

I need to extract 'us' and 'in' from _raw from each log.
rex field = _raw "(?:us?[^,]+)"

This is erroneous but it will be great if someone can help out.

Tags (3)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

This may help.

... | rex "en,(?<country>\w+)"
---
If this reply helps you, Karma would be appreciated.

sai_shreyashi_p
New Member

actually in the data it isn't necessary for the country to be preceded by 'en' which is why I was facing issues.
Is there any way to look for strings like ",us," or ",jp,"? Regex or rex expression for looking in _raw?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

If the sample data above is accurate then this should work:

... | rex ",(?<lang>\w+),(?<country>\w+)"
---
If this reply helps you, Karma would be appreciated.
0 Karma

harsmarvania57
SplunkTrust
SplunkTrust

Hi,

If you provide full sample raw data then community member will able to help on regex side.

0 Karma

sai_shreyashi_p
New Member

Sorry for the vague description of data but actually this data cannot be exposed.
They are mainly comma separated values in the middle of which we have language code,country code.
They are somewhere in the middle of _raw.
Ex: 324724588,nhiden-niuen-jkjl,en,us,6484-47934......,...

0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...