Splunk Search

Set Field=Value when Field not present in some logs

bcarr12
Path Finder

Hi all,

I am running a search that in some cases has:
Field=Values

In other cases, Field is completely missing from logs (this is expected).

What would be the best way to set Field equal to the Value when one is present, but if the Field does not exist in a given log line, Field should be set to the word "none"?

I've tried the coalesce command, but it doesn't seem to be working - maybe it is just being used incorrectly?
eval NewField=coalesce(Field,"none")

In the above example, NewField is always equal to "none" - even when Field includes a value.

Tags (1)
0 Karma
1 Solution

alemarzu
Motivator

Heya, or try this.

... | fillnull value=none field1,field2,field3

View solution in original post

0 Karma

bcarr12
Path Finder

Thank you both for your suggestions! alemarzu, fillnull worked great for this!

0 Karma

alemarzu
Motivator

Heya, or try this.

... | fillnull value=none field1,field2,field3
0 Karma

cmerriman
Super Champion

try this:

|eval Field=if(isnull(Field),"none",Field)
0 Karma
Get Updates on the Splunk Community!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk on November 6 at 11AM PT, and empower your SOC to reach new heights! Duration: ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...