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!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...