Splunk Search

Counting values

mkrauss1
Explorer

Hi,
i have a key value pair say FTYPE=VAL1 and FTYPE=VAL2 and create a timechart with

earliest=-1d@d latest=now | timechart
count(eval(FTYPE=VAL1)) as TYPE1, count(eval(FTYPE="VAL2")) as TYPE2

All for sudden i notice that the expected numbers are wrong because some of the FTYPE values are blank like FTYPE=

How can i create the timechart where blank FTYPE values are treated as VAL1? I tried something like
count(eval(FTYPE=VAL1 OR FTYPE="")) as TYPE1

somehow that doesn't work either.

Any ideas? Many thanks ...

Tags (1)
0 Karma
1 Solution

jonuwz
Influencer

You test for null like this : isnull(field)
So your search would be :

FTYPE=VAL1 OR isnull(FTYPE)

or, you could jsut do this beforehand :

... | eval FTYPE=if(isnull(FTYPE),"VAL1",FTYPE) | ...

View solution in original post

0 Karma

jonuwz
Influencer

You test for null like this : isnull(field)
So your search would be :

FTYPE=VAL1 OR isnull(FTYPE)

or, you could jsut do this beforehand :

... | eval FTYPE=if(isnull(FTYPE),"VAL1",FTYPE) | ...
0 Karma
Get Updates on the Splunk Community!

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

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

A Guide To Cloud Migration Success

As enterprises’ rapid expansion to the cloud continues, IT leaders are continuously looking for ways to focus ...