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!

Fastest way to demo Observability

I’ve been having a lot of fun learning about Kubernetes and Observability. I set myself an interesting ...

September Community Champions: A Shoutout to Our Contributors!

As we close the books on another fantastic month, we want to take a moment to celebrate the people who are the ...

Splunk Decoded: Service Maps vs Service Analyzer Tree View vs Flow Maps

It’s Monday morning, and your phone is buzzing with alert escalations – your customer-facing portal is running ...