Splunk Search

Grouping by user, count by number of countries

n_young
New Member

Using splunk to look at some auth data, and want to get search results that show the number of countries each user has logged in from.

I've gotten as far as adding the iplocation information into the search results, and even getting the reverse of what i want (number of users who have logged into each country), but when i try to do something like a "stats count by Country" it throws an error of: "Error in 'stats' command: The argument 'Country' is invalid."

Any suggestions? Here's the basics of the search so far:

... | iplocation clientLoginIp | stats count values(username) by Country | sort by count DESC

What am i missing?

0 Karma
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

To get the number of countries a user has authenticated from you'll need to juggle your stats around a bit:

... | stats dc(County) by username

That'll give you the distinct count of country values for each user.

View solution in original post

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

To get the number of countries a user has authenticated from you'll need to juggle your stats around a bit:

... | stats dc(County) by username

That'll give you the distinct count of country values for each user.

0 Karma

n_young
New Member

That worked perfectly. Thanks. I figured i was just missing something for the Country parameter.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...