Splunk Search

Create a new field/column on an event based on another field?

hariivendiran
Engager

I am new to Splunk and I am creating a dashboard with events. I would like to create a new field on the event which will have a value based on another field.

P.S I already included the existing field as part of search .

For example:

When existing field has 'XXX' in it, I need to populate 'ABC' in the new field and 'YYY' as 'CDE'

0 Karma

woodcock
Esteemed Legend

Your sentence can be read 2 ways. @sundareshr has interpreted and answered it one way, here is the other:

... | eval newfield=if(existingfield="XXX", "AAA", null()) | eval YYY=if(existingfield="XXX", "CDE", null()) | ...
0 Karma

sundareshr
Legend

Try this

... | eval newfield=case(existingfield="XXX", "AAA", existingfield="YYY", "CDE", 1=1, null()) | ...
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...