Splunk Search

Create new fields based on value of another fields.

paragvidhi
Engager

Hi All,
In my log, I have one field called ServerName. Below are some values of that field.

DAAPP2aBANG2
DFAPP20bLON2
UATSER1aUS1
UATSER1bUS2

We differentiate the above server with node A and node B based on the first character we got after the first occurrence of one or more digit.

DAAPP2aBANG2 -- its node a
DFAPP20bLON2 --- its node b
UATSER1aUS1 --- its node a
UATSER1bUS2 --- its node b

Here I want to create two fields called NodeA, and NodeB

In NodeA it should contain DAAPP2aBANG2 ,UATSER1aUS1
In NodeB it should contain DFAPP20bLON2, UATSER1bUS2

Tags (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @paragvidhi,
you could try something like this:

index=your_index
| rex field=ServerName "\w+\d(?<Node>a|b)"
| eval Node="Node ".Node
| table ServerName Node

You can test the regex at https://regex101.com/r/jLeU1f/1

Ciao.
Giuseppe

0 Karma
Get Updates on the Splunk Community!

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

New Release | Splunk Cloud Platform 10.1.2507

Hello Splunk Community!We are thrilled to announce the General Availability of Splunk Cloud Platform 10.1.2507 ...

🌟 From Audit Chaos to Clarity: Welcoming Audit Trail v2

&#x1f5e3; You Spoke, We Listened  Audit Trail v2 wasn’t written in isolation—it was shaped by your voices.  In ...