Splunk Search

Can i rename row values

NS
Explorer

from the table output, i want to rename row values for few fields, say for eg:

Column 1 Column 2
1 AAA
2 C
3 D
4 MMM
5 MMM
6 DDD

 

I want the result to look like below:

Coulmn 1 Column 2
1 Apple
2 Carrot
3 Drumstick
4 Mango
5 Mango
6 Drumstick

 

Basically, I have a list for mapping, Any letter begins with A to be renamed as Apple, and the ones with D to be renamed as Drumstick, and so on.

Can someone please help me? I am quite new to Splunk.

Thanks in advance.

Labels (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Here's one way to do that.  There may be others, perhaps including one that uses a lookup table.

| eval Column2 = case(Column2=="AAA", "Apple", Column2=="C", "Carrot", Column2=="D" OR Column2=="DDD", "Drumstick", Column2=="MMM", "Mango", 1==1, Column2)
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Here's one way to do that.  There may be others, perhaps including one that uses a lookup table.

| eval Column2 = case(Column2=="AAA", "Apple", Column2=="C", "Carrot", Column2=="D" OR Column2=="DDD", "Drumstick", Column2=="MMM", "Mango", 1==1, Column2)
---
If this reply helps you, Karma would be appreciated.

NS
Explorer

This worked perfectly, thank you.

Can you also let me know if i can categorize all the fruits in Column 2 and add a column with the total number of fruits.

I expect the result to be like this:

CategoryColumn 2
FruitApple
VegCarrot
VegDrumstick
FruitMango
FruitMango
VegDrumstick

 

Your help is much appreciated.

0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...