Splunk Search

Feed output back into search to show more data

alexlomas
Path Finder

Fairly new to Splunk so forgive the, what must be, fairly obvious question.

We have an alert setup to email us if we see logins from a user from more than one country in the last 24 hours. The search looks like:

authtype=Login.Success | iplocation sourceip | search | stats dedup_splitvals=t dc("Country") AS countrycount by "username" | where countrycount > 1

For which the output will be something like:

username countrycount
joebloggs 3
aant 2

In the email alert we can click through to the job then click on the username to review all the events, which is great, but I'd perhaps like a bit more information in the initial email alert so they can be triaged.

How can I add more fields to the output, i.e. how can I group it by username and the country name too?

Tags (2)
0 Karma
1 Solution

maciep
Champion

Not sure exactly what your data looks like or what you want the output to look like, but maybe one of these

Add country to the by clause. I'm guessing then all of your country counts might become 1.

stats dedup_splitvals=t dc("Country") AS countrycount by "username" Country | where countrycount > 1

Or maybe instead, just add a list of the countries to the output?

stats dedup_splitvals=t values(Country) AS "countries" dc("Country") AS countrycount by "username" | where countrycount > 1

View solution in original post

0 Karma

alexlomas
Path Finder

The latter works perfectly, thanks so much!

0 Karma

maciep
Champion

Not sure exactly what your data looks like or what you want the output to look like, but maybe one of these

Add country to the by clause. I'm guessing then all of your country counts might become 1.

stats dedup_splitvals=t dc("Country") AS countrycount by "username" Country | where countrycount > 1

Or maybe instead, just add a list of the countries to the output?

stats dedup_splitvals=t values(Country) AS "countries" dc("Country") AS countrycount by "username" | where countrycount > 1
0 Karma
Get Updates on the Splunk Community!

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Community Feedback

We Want to Hear from You! Share Your Feedback on the Splunk Community   The Splunk Community is built for you ...

Manual Instrumentation with Splunk Observability Cloud: Implementing the ...

In our observability journey so far, we've built comprehensive instrumentation for our Worms in Space ...