VeriKQL by Kaushik Saha

Level 4 · Same user, two countries · Mission 4 of 5 · by Kaushik Saha

Impossible travel

Alert Impossible travel · Idea geo_distance_2points · todouble

Commands here project · where · == · and / or · summarize · arg_max · extend · let · join · kind=inner · dot notation · all commands

Briefing

An impossible-travel rule asks one question: could a person have travelled between these two sign-ins in the time between them?

One idea: distance from the coordinates, then speed

LocationDetails.geoCoordinates holds the latitude and longitude. todouble makes them numbers, and geo_distance_2points gives the distance in metres. arg_max keeps the last sign-in at home and arg_min the first one away, each with its coordinates:

let Home = SigninLogs
    | where ResultType == "0" and Location == "US"
    | summarize arg_max(TimeGenerated, LocationDetails) by UserPrincipalName
    | project UserPrincipalName, HomeTime = TimeGenerated, HomeLat = todouble(LocationDetails.geoCoordinates.latitude),
        HomeLon = todouble(LocationDetails.geoCoordinates.longitude);
let Away = SigninLogs
    | where ResultType == "0" and Location == "NL"
    | summarize arg_min(TimeGenerated, LocationDetails) by UserPrincipalName
    | project UserPrincipalName, AwayTime = TimeGenerated, AwayLat = todouble(LocationDetails.geoCoordinates.latitude),
        AwayLon = todouble(LocationDetails.geoCoordinates.longitude);
Home
| join kind=inner Away on UserPrincipalName
| extend Km = round(geo_distance_2points(HomeLon, HomeLat, AwayLon, AwayLat) / 1000),
    Minutes = round((AwayTime - HomeTime) / 1m)
| extend KmPerHour = round(Km / Minutes * 60)
| project UserPrincipalName, HomeTime, AwayTime, Km, Minutes, KmPerHour
✓ Verified by VeriKQLKusto.Language 12.4.1 · bundle 2026.10.29

Result on the sample · 1 row

UserPrincipalNameHomeTimeAwayTimeKmMinutesKmPerHour
alex.morgan@contoso.com2026-06-10 08:12:332026-06-10 08:20:367826858695

7,826 km in 8 minutes: about 58,700 km/h. An airliner flies at about 900. Nobody travelled; someone else signed in.

Your turn

Using the same two halves, show only the distance in kilometres between Alex's home and away sign-ins.

Write it in the box below and check it. Then compare with one answer; others can be right too.

Show one answer
let Home = SigninLogs
    | where ResultType == "0" and Location == "US"
    | summarize arg_max(TimeGenerated, LocationDetails) by UserPrincipalName
    | project UserPrincipalName, HomeLat = todouble(LocationDetails.geoCoordinates.latitude),
        HomeLon = todouble(LocationDetails.geoCoordinates.longitude);
let Away = SigninLogs
    | where ResultType == "0" and Location == "NL"
    | summarize arg_min(TimeGenerated, LocationDetails) by UserPrincipalName
    | project UserPrincipalName, AwayLat = todouble(LocationDetails.geoCoordinates.latitude),
        AwayLon = todouble(LocationDetails.geoCoordinates.longitude);
Home
| join kind=inner Away on UserPrincipalName
| extend Km = round(geo_distance_2points(HomeLon, HomeLat, AwayLon, AwayLat) / 1000)
| project UserPrincipalName, Km
✓ Verified by VeriKQLKusto.Language 12.4.1 · bundle 2026.10.29

Result on the sample · 1 row

UserPrincipalNameKm
alex.morgan@contoso.com7826

Check your own query

Write your query for the task above and check it against the real schema.

Debrief

This query names the two countries; a production rule pairs every sign-in with the one before it, for any country. Microsoft Entra ID Protection already flags this as "atypical travel", and the idea is the same. One bug hunt left.

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.