Splunk Search

How to rename extracted values

sb01splunk
Explorer

I have the following data:

Code        Area
1234.1234   ABC
9933.9933   DEF
6611.6611   GHI
8910.8910   ABC
8910.1111   ABC

Search looks like the following:

| inputlookup combined.csv | search Code=* | eval NewArea=case('AREA'="DEF","Opeth",'AREA'="GHI","Danzig") | table Code, NewArea

New output:

Code        Area
1234.1234   ABC
9933.9933   Opeth
6611.6611   Danzig
8910.8910   ABC
8910.1111   ABC

What I also need to do, is if Code equals 8910.* rename it to "Tool" and if Code equals 1234.1234 rename it to "Gojira".

Code        Area
1234.1234   Gojira
9933.9933   Opeth
6611.6611   Danzig
8910.8910   Tool
8910.1111   Tool

Is something like this possible?

1 Solution

richgalloway
SplunkTrust
SplunkTrust

You're almost there with your existing query.

| inputlookup combined.csv | search Code=* 
| eval NewArea=case('AREA'="DEF","Opeth",'AREA'="GHI","Danzig", match(Code,"8910\..*"), "Tool", Code="1234.1234", "Gojira") 
| table Code, NewArea
---
If this reply helps you, Karma would be appreciated.

View solution in original post

sb01splunk
Explorer

Thanks a lot to both of you. I wish I could put Accepted to both replies.

0 Karma

renjith_nair
Legend

@sb01splunk,

Add those conditions to the case statement.

| inputlookup combined.csv| search Code=* 
| eval NewArea=case(Area=="DEF","Opeth",Area=="GHI","Danzig",Code=="1234.1234","Gojira",match(Code,"8910"),"Tool") 
| table Code, NewArea
---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma

richgalloway
SplunkTrust
SplunkTrust

You're almost there with your existing query.

| inputlookup combined.csv | search Code=* 
| eval NewArea=case('AREA'="DEF","Opeth",'AREA'="GHI","Danzig", match(Code,"8910\..*"), "Tool", Code="1234.1234", "Gojira") 
| table Code, NewArea
---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...