Splunk Search

User agent string using lookup table

jaibalaraman
Path Finder

Hi Team 

I am trying to extract the OS details from the user agent using the below eval command, however I am not able to see new filed was created (test) after i executed the spl query

index=aws Website="*"
| eval test = case(match(useragent,"Windows .. 5\.1"),"Windows XP",match(useragent,"droid"),"Android",match(useragent,"Windows NT 6.1"),"Windows 7")

Any help please

 

Thank s

Labels (1)
Tags (1)
0 Karma

jaibalaraman
Path Finder

Hi richgalloway 

Thanks for your message

Yes, i tried executing's the SPL command found no error however i am not getting any statistics result 

jaibalaraman_0-1620706992534.png

 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

The query you ran does not have a command that generates statistics so you won't see anything in the Statistics tab.  Look at the results in the Events tab or add commands to the given query.  It was not meant to be complete - just to answer the question asked.

---
If this reply helps you, Karma would be appreciated.
0 Karma

richgalloway
SplunkTrust
SplunkTrust

The case function will return null if none of the expressions are true.  That's why it's a good practice to include as the last expression something that will always evaluate to true (similar to the 'default' case in HLLs).

 

index=aws Website="*"
| eval test = case(match(useragent,"Windows .. 5\.1"),"Windows XP",match(useragent,"droid"),"Android",match(useragent,"Windows NT 6\.1"),"Windows 7", 1==1, "Unknown")

If the field is set to the default value then you know none of the other cases matched and you need to re-evaluate your code.

 

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

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