Splunk Search

How to extract data for a portion of the field?

CodingMaestro
Path Finder

Hello Splunk Community, 

So I have a table that has results like below 

 Name               

Tom01

Tom02

Tom03

Tom04

Quin01

Yonah01

Yonah02

 

I want a query that if the text matches before the numeric' s it will only select the 01 and ignore the other ones.

For example: IF Yonah01 and Yonah02 exist this is a pair so it will exclude Yonah02 and just have Yonah01 

or another one, if there is Tom01, Tom02, Tom03, Tom04 it will exclude everything except for the Tom01.

Thank you. 

 

Labels (3)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @CodingMaestro,

if the field structure is chars and two digit at the end, you could use something like this:

 

<your_search>
| rex field=Name "^(?<subfield>[a-zA-Z]+)"
| stats first(Name) AS Name BY subfield
| table Name

 

You can test the regex to extract subfield at https://regex101.com/r/D3P9mA/1

Ciao.

Giuseppe

View solution in original post

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @CodingMaestro,

if the field structure is chars and two digit at the end, you could use something like this:

 

<your_search>
| rex field=Name "^(?<subfield>[a-zA-Z]+)"
| stats first(Name) AS Name BY subfield
| table Name

 

You can test the regex to extract subfield at https://regex101.com/r/D3P9mA/1

Ciao.

Giuseppe

0 Karma

CodingMaestro
Path Finder

Thank You

0 Karma
Get Updates on the Splunk Community!

CX Day is Coming!

Customer Experience (CX) Day is on October 7th!! We're so excited to bring back another day full of wonderful ...

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...