VeriKQL by Kaushik Saha

Level 0 · Your toolkit · Card 5 of 9 · by Kaushik Saha

Work with time

Commands ago · now · between · bin

What these commands do

CommandWhat it doesShape
agoA moment in the past, counted back from nowTimeGenerated > ago(1h)
nowThe current timenow()
betweenInside a range, both ends includedCol between (A .. B)
binRounds times down into buckets, so you can count per hour or per daybin(TimeGenerated, 1h)

Times are written like 1h (an hour), 30m, 7d or 90s.

See them work

The sign-ins of the last hour, by the story's clock:

SigninLogs
| where TimeGenerated > ago(1h)
| project TimeGenerated, UserPrincipalName, AppDisplayName
✓ Verified by VeriKQLKusto.Language 12.4.1 · bundle 2026.10.29

Result on the sample · 6 rows

TimeGeneratedUserPrincipalNameAppDisplayName
2026-06-10 11:32:04it.admin@contoso.comMy Apps
2026-06-10 11:47:01it.admin@contoso.comAzure Portal
2026-06-10 11:02:40sara.lind@contoso.comOffice 365 Exchange Online
2026-06-10 11:12:27it.admin@contoso.comOffice 365 SharePoint Online
2026-06-10 11:06:28it.admin@contoso.comOffice 365 Exchange Online
2026-06-10 11:02:00sara.lind@contoso.comOffice 365 Exchange Online

now() is the current time, so this is the same as "the last 30 minutes":

SigninLogs
| where TimeGenerated > now() - 30m
| project TimeGenerated, UserPrincipalName, AppDisplayName
✓ Verified by VeriKQLKusto.Language 12.4.1 · bundle 2026.10.29

Result on the sample · 2 rows

TimeGeneratedUserPrincipalNameAppDisplayName
2026-06-10 11:32:04it.admin@contoso.comMy Apps
2026-06-10 11:47:01it.admin@contoso.comAzure Portal

The seven minutes around Alex's break-in, using between:

SigninLogs
| where TimeGenerated between (datetime(2026-06-10T08:14:00Z) .. datetime(2026-06-10T08:21:00Z))
| project TimeGenerated, UserPrincipalName, IPAddress, ResultType
✓ Verified by VeriKQLKusto.Language 12.4.1 · bundle 2026.10.29

Result on the sample · 11 rows

TimeGeneratedUserPrincipalNameIPAddressResultType
2026-06-10 08:19:36sara.lind@contoso.com192.0.2.200
2026-06-10 08:17:05alex.morgan@contoso.com203.0.113.4550126
2026-06-10 08:20:36alex.morgan@contoso.com203.0.113.450
2026-06-10 08:19:44alex.morgan@contoso.com203.0.113.45500121
2026-06-10 08:15:10alex.morgan@contoso.com203.0.113.4550126
2026-06-10 08:14:02alex.morgan@contoso.com203.0.113.4550126
2026-06-10 08:19:12alex.morgan@contoso.com203.0.113.4550126
2026-06-10 08:15:49ben.carter@contoso.com192.0.2.200
2026-06-10 08:16:31alex.morgan@contoso.com203.0.113.4550126
2026-06-10 08:18:41alex.morgan@contoso.com203.0.113.4550126
2026-06-10 08:20:09alex.morgan@contoso.com203.0.113.45500121

bin buckets the morning into hours (summarize is the next card):

SigninLogs
| summarize SignIns = count() by bin(TimeGenerated, 1h)
| sort by TimeGenerated asc
✓ Verified by VeriKQLKusto.Language 12.4.1 · bundle 2026.10.29

Result on the sample · 5 rows

TimeGeneratedSignIns
2026-06-10 07:00:0018
2026-06-10 08:00:0051
2026-06-10 09:00:0046
2026-06-10 10:00:0020
2026-06-10 11:00:006

Your turn

Count the sign-ins in each 30-minute bucket, oldest 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() by bin(TimeGenerated, 30m)
| sort by TimeGenerated asc
✓ Verified by VeriKQLKusto.Language 12.4.1 · bundle 2026.10.29

Result on the sample · 9 rows

TimeGeneratedSignIns
2026-06-10 07:30:0018
2026-06-10 08:00:0030
2026-06-10 08:30:0021
2026-06-10 09:00:0023
2026-06-10 09:30:0023
2026-06-10 10:00:0019
2026-06-10 10:30:001
2026-06-10 11:00:004
2026-06-10 11:30:002

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.