Splunk Search

How to make substring using rex

splunkkid
Path Finder

Hello,

 

I am currently confront some problem here.

I want to substring data in specific column using rex.

 

The column's data looks like below(All same or similar style).

"****-****-**POD4-***"

 

In above case, all  I need is the number after the word POD. ( * means some alphabets)

 

Any ideas? 

Thank you.

 

Labels (1)
0 Karma
1 Solution

thambisetty
SplunkTrust
SplunkTrust

replace <choosefield> with field name from which you want to extract number after word POD. number will be extracted to new field called "podnumber"

| rex field=<choosefield> "POD(?<podnumber>\d+)"
————————————
If this helps, give a like below.

View solution in original post

thambisetty
SplunkTrust
SplunkTrust

replace <choosefield> with field name from which you want to extract number after word POD. number will be extracted to new field called "podnumber"

| rex field=<choosefield> "POD(?<podnumber>\d+)"
————————————
If this helps, give a like below.

splunkkid
Path Finder

@thambisetty 

 

Thanks! This worked exactly how I want.

Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex field=column "POD(?<number>\d+)\-"

where column is the field name your data is in.

Is it always POD? If not, is it always ****-****-**POD4-***  4 letters "-" 4 letters "-" 2 letters 3 characters number (at least 1 digit) "-" 3 letters?

splunkkid
Path Finder

@ITWhisperer 

First, Thanks for your answer.

 

And I tried like below

MYSEARCH | rex field=pod "pod(?<number>\d+)" | sort podnumber | table pod podnumber

 

Erased the part "\-" because that makes no results, although i don't know why.

 

And * part could be different by row, so it doesn't really helpful I guess.

 

 

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...