Level 4 · Same user, two countries · Mission 2 of 5 · by Kaushik Saha
Two countries
Alert Impossible travel · Idea dcount · make_set
Commands here where · == · count · summarize · dcount · make_set / make_list · extend · tostring · dot notation · all commands
Briefing
A rule should find this by itself: a user who signs in from two countries in a short time.
One idea: count the countries, but only for sign-ins that worked
First, without a filter: how many users signed in from more than one country?
SigninLogs
| extend Country = tostring(LocationDetails.countryOrRegion)
| summarize Countries = dcount(Country) by UserPrincipalName
| where Countries > 1
| count
Result on the sample · 1 row
| Count |
|---|
| 12 |
All 12. The spray from Germany tried every user, and a failed attempt still records the attacker's country. Keep only the successes:
SigninLogs
| where ResultType == "0"
| extend Country = tostring(LocationDetails.countryOrRegion)
| summarize Countries = dcount(Country), Seen = make_set(Country) by UserPrincipalName
| where Countries > 1
Result on the sample · 1 row
| UserPrincipalName | Countries | Seen |
|---|---|---|
| alex.morgan@contoso.com | 2 | ["NL","US"] |
One user: Alex, in the US and the Netherlands.
Your turn
Find users who signed in successfully from more than one city, with the cities they used.
Write it in the box below and check it. Then compare with one answer; others can be right too.
Show one answer
SigninLogs
| where ResultType == "0"
| extend City = tostring(LocationDetails.city)
| summarize Cities = dcount(City), Seen = make_set(City) by UserPrincipalName
| where Cities > 1
Result on the sample · 1 row
| UserPrincipalName | Cities | Seen |
|---|---|---|
| alex.morgan@contoso.com | 2 | ["Amsterdam","Seattle"] |
Check your own query
Write your query for the task above and check it against the real schema.
Debrief
Two countries in a day can be honest: a business trip, a VPN. What makes it impossible is the time between them.
All data on this page is sample data, made up for this course. The IP addresses come from ranges reserved for documentation, and the people and the company are fictional.
Mission by Kaushik Saha. Every query checked with Microsoft.Azure.Kusto.Language 12.4.1 against schema bundle 2026.10.29; every result computed on the course's sample with Kusto-Loco 1.4.9, an open-source KQL engine (credits). The story's clock reads 12:00 UTC on 10 June 2026.