Splunk Search

How to assign value to a field which is not present in some of the events and compare that value with other values from other events where that field is present?

abhi04
Communicator

How to assign value to a field which is not present in some of the events and compare that value with other values from other events where that field is present?

I have events where field named "SSLProxyEngine" have values "ON" or "OFF" for some of the events but for some events that field is not present. I want to assign value "NONE" to SSlProxyEngine where the field is not present and then compare this value with othere events value.

How can I do that?

Tags (1)
0 Karma

MuS
SplunkTrust
SplunkTrust

Hi abhi04,

first you run your search to get the events and add an eval statement to check if the field exists or not, and if not assign it the value. Try this:

 your search here
 | eval SSLProxyEngine = case(isnull(SSLProxyEngine), "NONE", isnotnull(SSLProxyEngine), SSLProxyEngine, 1=1, "unknown")

the last option is for events that does not match anything 😉

Hope this helps ...

cheers, MuS

Sukisen1981
Champion

| eval yourfield=if(isnull(yourfield),"NONE",yourfield)

0 Karma
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 ...