Splunk Search

How to get a Stats count of field values by country

Hildoceras
New Member

Hi

I am looking at access log data with the fields src_ip and method (get, post, head)

I have been running the search src_ip="*" | iplocation src_ip | stats count by country

this gives me an event count by country.

I would like to take this further and also get a count of total events by country and a split per country of get, post and head

any help appreciated

Tags (1)
0 Karma

MuS
Legend

Hi Hildoceras,

something like this should get you there:

 ... | stats count(eval(method="POST")) AS post count(eval(method="GET")) AS get count(eval(method="HEAD")) AS head by country | addtotals 

hope this helps ...

cheers, MuS

MuS
Legend

feel free to accept the answer, thanks 😉

0 Karma

Hildoceras
New Member

Worked like a charm many thanks

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...