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
Esteemed Legend

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
Esteemed Legend

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!

Splunk Cloud | Empowering Splunk Administrators with Admin Config Service (ACS)

Greetings, Splunk Cloud Admins and Splunk enthusiasts! The Admin Configuration Service (ACS) team is excited ...

Tech Talk | One Log to Rule Them All

One log to rule them all: how you can centralize your troubleshooting with Splunk logs We know how important ...

Splunk Security Content for Threat Detection & Response, Q1 Roundup

Join Principal Threat Researcher, Michael Haag, as he walks through:An introduction to the Splunk Threat ...