All Apps and Add-ons

Regular expression in Splunk

saradachelluboy
Explorer

Hi All,

I want to read the string from specific location 34 till it reaches | line

I tried wrote regex as (?<=^.{34})\w+\S\d executed in https://regex101.com/ for the provided String
INFO | 2016-07-11 00:03:00,380 | jmsListenerA-9 |

But when I tried to execute the same in splunk
rex thread=_raw "(?<=^.{34})\w+-\d"

I am getting error : Error in 'rex' command: The regex '(?<=^.{34})\w+-\d' does not extract anything. It should specify at least one named group. Format: (?...).

Could some one pls help

0 Karma
1 Solution

rakesh_498115
Motivator

Hi sarada,

Try something like this.

rex "(?<=38)(?<WORD>[^|]+)"

View solution in original post

0 Karma

premraj_vs
Path Finder

You can try this

index=XXX 
| rex field=_raw ".+\[(?P<FIELD1>.+)]\s+(?P<FIELD2>.+)\s+for\s+(?P<FIELD3>.+)\/(?P<FIELD4>.+)"

This worked for me

0 Karma

hardik_splunk
Splunk Employee
Splunk Employee

You need to add capturing group in the rex command. This will be the name of the field, which will have extracted value.

for ex
index=_internal | eval data= "INFO | 2016-07-11 00:03:00,380 | jmsListenerA-9 |" | table data | rex field=data "(?<=^.{34})(?.*)|" | table thread

0 Karma

rakesh_498115
Motivator

Hi sarada,

Try something like this.

rex "(?<=38)(?<WORD>[^|]+)"
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, ...