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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...