Splunk Search

Finding difficulty in extracting count of browser type from user agent

jaibalaraman
Path Finder

Hi 

I need help in determining the browser that appear in our logs. I believe the simple way to use the app TA - UA parser or an external script but unfortunately i do not have enough access rights to use the tools. 

SPL command - 

index=aws sourcetype = * Website="*" | stats count(eval(match(User_Agent, "Firefox"))) as "Firefox", count(eval(match(User_Agent, "Chrome"))) as "Chrome", count(eval(match(User_Agent, "Safari"))) as "Safari", count(eval(match(User_Agent, "MSIE"))) as "IE", count(eval(match(User_Agent, "Trident"))) as "Trident", count(eval(NOT match(User_Agent, "Chrome|Firefox|Safari|MSIE|Trident"))) as "Other" | transpose | sort by User_Agent

 
 
 

I tried the above command, it gives all data to "Other". Firefox=0, Chrome=0 IE=0

Tags (1)
0 Karma

scelikok
SplunkTrust
SplunkTrust

Hi @jaibalaraman,

Your problem seems that User_Agent field is not exist as it is or there is no event returns from search before stats command.  

1. Run below search to see any results?

index=aws sourcetype = * Website="*"

If there is no results, please check if Website and User_Agent fields are correct in Interesting Fields section. You can try again using correct field names. Please keep in mind that the field names are case sensitive.

2. If above returns results, try below;

index=aws sourcetype = * Website="*" User_Agent=*

 I think there will be no results, please check if  User_Agent field is correct in Interesting Fields section. You can try again using correct field name. Please keep in mind that the field names are case sensitive.

If this reply helps you an upvote and "Accept as Solution" is appreciated.
0 Karma

jaibalaraman
Path Finder

Hi Splunk team 

Please find below image for sample log file 

jaibalaraman_0-1612221570204.png

 

0 Karma

manjunathmeti
Champion

hi, @jaibalaraman,
Regex applied in the match function is case sensitive, try this,

index=aws sourcetype = * Website="*" 
| stats count(eval(match(User_Agent, "(?i)Firefox"))) as "Firefox", count(eval(match(User_Agent, "(?i)Chrome"))) as "Chrome", count(eval(match(User_Agent, "(?i)Safari"))) as "Safari", count(eval(match(User_Agent, "(?i)MSIE"))) as "IE", count(eval(match(User_Agent, "(?i)Trident"))) as "Trident", count(eval(NOT match(User_Agent, "(?i)Chrome|Firefox|Safari|MSIE|Trident"))) as "Other" 
| transpose 

 

If this reply helps you, an upvote/like would be appreciated.

0 Karma

jaibalaraman
Path Finder

Hi 

Yes, i tried the  SPL command and still same issue 

jaibalaraman_0-1611806002584.png

 

0 Karma

manjunathmeti
Champion

Can you post some sample data?

0 Karma

jaibalaraman
Path Finder

Hi, 

Sure 

jaibalaraman_0-1611866300077.png

 

0 Karma

manjunathmeti
Champion

I mean sample raw data.

0 Karma

jaibalaraman
Path Finder

Hi 

I am happy to share but unfortunately i don't have access to the log file.

Sorry 

Thanks 

0 Karma

jaibalaraman
Path Finder

Hi Team 

Can any one help me on this please ??

0 Karma

jaibalaraman
Path Finder

Please find below image 

jaibalaraman_1-1611802401173.png

 

 

 

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...