Level 0 · Your toolkit · Card 6 of 9 · by Kaushik Saha
Count and group
Commands count · summarize · countif · dcount · arg_max · make_set
What these commands do
| Command | What it does | Shape |
|---|---|---|
count | How many rows. On its own as | count, or count() inside summarize | T | count |
summarize | Groups rows and works out one row per group | T | summarize count() by Col |
countif | Counts only the rows that match | countif(Col != "0") |
dcount | How many different values | dcount(Col) |
min / max | The smallest / largest value, such as the first and last time | min(TimeGenerated) |
arg_max | The whole row with the largest value, such as each user's latest sign-in | arg_max(TimeGenerated, *) by User |
make_set / make_list | Collects the values into a list: each once / all of them | make_set(Col) |
See them work
One row per address: how many sign-ins, how many failed, how many different users, and when it was first and last seen. The two attackers stand out at once:
SigninLogs
| summarize Total = count(), Failed = countif(ResultType != "0"), Users = dcount(UserPrincipalName),
First = min(TimeGenerated), Last = max(TimeGenerated) by IPAddress
| sort by Failed desc
Result on the sample · 7 rows
| IPAddress | Total | Failed | Users | First | Last |
|---|---|---|---|---|---|
| 198.51.100.23 | 12 | 12 | 12 | 2026-06-10 07:40:11 | 2026-06-10 07:46:58 |
| 203.0.113.45 | 11 | 8 | 1 | 2026-06-10 08:14:02 | 2026-06-10 09:02:41 |
| 192.0.2.20 | 42 | 3 | 4 | 2026-06-10 07:53:26 | 2026-06-10 11:02:40 |
| 192.0.2.10 | 56 | 2 | 6 | 2026-06-10 07:46:26 | 2026-06-10 11:47:01 |
| 192.0.2.34 | 9 | 0 | 1 | 2026-06-10 08:10:26 | 2026-06-10 10:28:30 |
| 203.0.113.77 | 2 | 0 | 1 | 2026-06-10 09:08:19 | 2026-06-10 09:58:44 |
| 192.0.2.41 | 9 | 0 | 1 | 2026-06-10 08:08:10 | 2026-06-10 10:27:32 |
Every app one user reached, each once:
SigninLogs
| where UserPrincipalName == "alex.morgan@contoso.com"
| summarize Apps = make_set(AppDisplayName)
Result on the sample · 1 row
| Apps |
|---|
| ["Azure Storage","Office 365 Exchange Online","Office 365 SharePoint Online","Microsoft Graph PowerShell","Microsoft Teams","Azure Portal"] |
Each user's latest sign-in, with arg_max:
SigninLogs
| summarize arg_max(TimeGenerated, IPAddress, AppDisplayName) by UserPrincipalName
| sort by UserPrincipalName asc
| take 4
Result on the sample · 4 rows
| UserPrincipalName | TimeGenerated | IPAddress | AppDisplayName |
|---|---|---|---|
| alex.morgan@contoso.com | 2026-06-10 09:58:44 | 203.0.113.77 | Azure Storage |
| ben.carter@contoso.com | 2026-06-10 10:11:38 | 192.0.2.20 | Microsoft Teams |
| it.admin@contoso.com | 2026-06-10 11:47:01 | 192.0.2.10 | Azure Portal |
| julia.santos@contoso.com | 2026-06-10 10:21:24 | 192.0.2.10 | Office 365 SharePoint Online |
Your turn
For each user, count their sign-ins and their failures, and show the users with the most failures first.
Write it in the box below and check it. Then compare with one answer; others can be right too.
Show one answer
SigninLogs
| summarize SignIns = count(), Failures = countif(ResultType != "0") by UserPrincipalName
| sort by Failures desc
Result on the sample · 12 rows
| UserPrincipalName | SignIns | Failures |
|---|---|---|
| alex.morgan@contoso.com | 16 | 9 |
| mei.chen@contoso.com | 12 | 2 |
| priya.nair@contoso.com | 12 | 2 |
| ben.carter@contoso.com | 12 | 2 |
| sara.lind@contoso.com | 12 | 2 |
| tom.becker@contoso.com | 12 | 2 |
| raj.patel@contoso.com | 10 | 1 |
| omar.haddad@contoso.com | 10 | 1 |
| julia.santos@contoso.com | 10 | 1 |
| lena.fischer@contoso.com | 10 | 1 |
| it.admin@contoso.com | 15 | 1 |
| sam.okafor@contoso.com | 10 | 1 |
Check your own query
Write your query for the task above and check it against the real schema.
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.
Card 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.