VeriKQL by Kaushik Saha

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

CommandWhat it doesShape
countHow many rows. On its own as | count, or count() inside summarizeT | count
summarizeGroups rows and works out one row per groupT | summarize count() by Col
countifCounts only the rows that matchcountif(Col != "0")
dcountHow many different valuesdcount(Col)
min / maxThe smallest / largest value, such as the first and last timemin(TimeGenerated)
arg_maxThe whole row with the largest value, such as each user's latest sign-inarg_max(TimeGenerated, *) by User
make_set / make_listCollects the values into a list: each once / all of themmake_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
✓ Verified by VeriKQLKusto.Language 12.4.1 · bundle 2026.10.29

Result on the sample · 7 rows

IPAddressTotalFailedUsersFirstLast
198.51.100.231212122026-06-10 07:40:112026-06-10 07:46:58
203.0.113.4511812026-06-10 08:14:022026-06-10 09:02:41
192.0.2.2042342026-06-10 07:53:262026-06-10 11:02:40
192.0.2.1056262026-06-10 07:46:262026-06-10 11:47:01
192.0.2.349012026-06-10 08:10:262026-06-10 10:28:30
203.0.113.772012026-06-10 09:08:192026-06-10 09:58:44
192.0.2.419012026-06-10 08:08:102026-06-10 10:27:32

Every app one user reached, each once:

SigninLogs
| where UserPrincipalName == "alex.morgan@contoso.com"
| summarize Apps = make_set(AppDisplayName)
✓ Verified by VeriKQLKusto.Language 12.4.1 · bundle 2026.10.29

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
✓ Verified by VeriKQLKusto.Language 12.4.1 · bundle 2026.10.29

Result on the sample · 4 rows

UserPrincipalNameTimeGeneratedIPAddressAppDisplayName
alex.morgan@contoso.com2026-06-10 09:58:44203.0.113.77Azure Storage
ben.carter@contoso.com2026-06-10 10:11:38192.0.2.20Microsoft Teams
it.admin@contoso.com2026-06-10 11:47:01192.0.2.10Azure Portal
julia.santos@contoso.com2026-06-10 10:21:24192.0.2.10Office 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
✓ Verified by VeriKQLKusto.Language 12.4.1 · bundle 2026.10.29

Result on the sample · 12 rows

UserPrincipalNameSignInsFailures
alex.morgan@contoso.com169
mei.chen@contoso.com122
priya.nair@contoso.com122
ben.carter@contoso.com122
sara.lind@contoso.com122
tom.becker@contoso.com122
raj.patel@contoso.com101
omar.haddad@contoso.com101
julia.santos@contoso.com101
lena.fischer@contoso.com101
it.admin@contoso.com151
sam.okafor@contoso.com101

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.