Splunk Search

How to split user agent details

jaibalaraman
Path Finder

Hi 

I am new to splunk, and I need some help with SPL query to execute the below user agent

Log File

" Mozilla/5.0 (Linux; Android 9; SAMSUNG SM-J330G) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/12.1 Chrome/79.0.3945.136 Mobile Safari/537.3

Expecting output - 

Operating SystemMobile Device InfoDevice ModelBrowser Browser version
Android / IOSSamsung/ IphoneSm -J330G / I phone SEChrome / Mozilla79.0.3945

 

Thanks 

Labels (1)
0 Karma

jaibalaraman
Path Finder

Hi 

I am sorry , i am new to splunk. If you can guide how do I get the requested detail in code block.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

When you reply, open a code block with this symbol

ITWhisperer_0-1603317269692.png

and paste some same events so we can see exactly what the events look like

0 Karma

jaibalaraman
Path Finder

Hi

Log File 

" Mozilla/5.0 (Linux; Android 9; SAMSUNG SM-J330G) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/12.1 Chrome/79.0.3945.136 Mobile Safari/537.3

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Please can you provide more examples, with different operating systems, mobile device infos, device models, browsers, browser versions, etc

" Mozilla/5.0 (Linux; Android 9; SAMSUNG SM-J330G) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/12.1 Chrome/79.0.3945.136 Mobile Safari/537.36 
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Can you provide more examples, preferably in a code block </>, so we can see the correct formatting. User agent information varies quite a lot depending on device used.

0 Karma

jaibalaraman
Path Finder
Mozilla/5.0 (Linux; Android 5.1; HUAWEI LYO-L02) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.101 Mobile Safari/537.36
Mozilla/5.0 (Linux; Android 10; SAMSUNG SM-G975F) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/12.1 Chrome/79.0.3945.136 Mobile Safari/537.36
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15 (Applebot/0.1; +http://www.apple.com/go/applebot)
 Mozilla/5.0 (Linux; U; Android 8.1.0; zh-cn; OPPO R11s Build/OPM1.171019.011) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/70.0.3538.80 Mobile Safari/537.36 HeyTapBrowser/10.7.5.5
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You could start with this

rex field=useragentdetails "(?<useragent>\S+)\s+\((?<OSinfo>[^\)]+)\)\s+(?<platform>\S+)\s+\((?<platformdetails>[^\)]+)\)\s+(?<extensions>.+)"

You could then use rex or split to separate the different parts of the OSinfo and extensions to extract the information you feel is important.

0 Karma

jaibalaraman
Path Finder

Hi 

Thanks for the information 

 I tried searching the below query , " no result found". However I am not sure am I doing it correctly.

Could you please guide me on this 

rex field=useragentdetails "(?<useragent>\S+)\s+\((?<OSinfo>[^\)]+)\)\s+(?<platform>\S+)\s+\((?<platformdetails>[^\)]+)\)\s+(?<extensions>.+)"

Capture.JPG

 

0 Karma

jaibalaraman
Path Finder

Hi 

Sorry I managed to run rex spl query , please ignore my previous message .

Capture.JPG

Could you please guide me what spl command i should use to get as dashboard panel or visualization.

Thanks 

 

0 Karma

kennetkline
Path Finder

based on your second post looks like you got results

get a stats table as desired 

your search with| rex
|table useragent, OSinfo, platform, platformdetails, extensions



Right above Search;  You can  "save  as" your search as a report or a  "dashboard panel".  as a "statistics table"

Capture.PNG

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

The rex specifies a field to operate on - I assumed you had already extracted this (and called it useragentdetails. If it has been extracted to a different field then use that instead. Having said that, the event shown in your latest screenshot does not include any of the data you are interested in. Do you have any events that do? Can you paste them into a code block so we can see what you are dealing with?

0 Karma
Get Updates on the Splunk Community!

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...

Index This | What goes away as soon as you talk about it?

May 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this month’s ...

What's New in Splunk Observability Cloud and Splunk AppDynamics - May 2025

This month, we’re delivering several new innovations in Splunk Observability Cloud and Splunk AppDynamics ...