Splunk Search

Help with an eval statement?

svemurilv
Path Finder

I am trying to build a base search for the field message.device.category , it has 3 values: desktop , mobile and tablet.

Using eval I am trying to divide the field with separate values.

search | eval MobileUsers=if("message.device.category" == "Mobile", "Mobile",NULL) |eval DesktopUsers=if("message.device.category" == "Desktop", "Desktop",NULL) |eval tabUsers=if("message.device.category" == "Tablet", "Tablet",NULL) |event stats count(DesktopUsers) ,count (MobileUsers) ,count(tabUsers)

its not returning any values in the counts.

0 Karma
1 Solution

sbbadri
Motivator

@svemurilv

try this,

your search here | eval result_users = case("message.device.category" == "Mobile", "Mobile","message.device.category" == "Desktop", "Desktop","message.device.category" == "Tablet", "Tablet") | stats count by result_users

View solution in original post

0 Karma

sbbadri
Motivator

@svemurilv

try this,

your search here | eval result_users = case("message.device.category" == "Mobile", "Mobile","message.device.category" == "Desktop", "Desktop","message.device.category" == "Tablet", "Tablet") | stats count by result_users

0 Karma

mwdbhyat
Builder

I can see that you have written eventstats as "event stats" and a space between the count and the (Mobile...).. im guessing thats formatting on this page?

Is the search returning anything without the eventstats section?

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

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