Stage 00 · Setup — Get a dataset you can actually practise on
The problem this solves: Almost every KQL tutorial says "run this against
SigninLogs" — but a new or quiet Microsoft Sentinel workspace has little or no data, so those queries return nothing and you can't learn. This stage gives you a realistic, deterministic dataset without waiting for connectors to ingest anything.
You only do this once. Pick the path that matches your situation:
| Your situation | Use | Cost |
|---|---|---|
| You have a Sentinel / Log Analytics workspace (even empty) | Method 1 — Seed a function | Free |
| You have no Azure subscription at all | Method 2 — Azure Data Explorer free cluster + CSV | Free, no subscription/credit card |
Both methods create the same object — a queryable thing called DemoIdentityLogs — so every later lab works identically regardless of which path you chose.
The dataset
5 users · 2 event types · 64 records spread across ~6½ days, so hourly and daily charts in the labs have real shape. The same story runs through every example so you build intuition instead of memorising disconnected snippets.
| User | What they do in the data |
|---|---|
alexw@contoso.com |
Routine US sign-ins, then a compromise narrative: two days of repeated failures from a Netherlands IP (185.220.101.2), an account lockout, a risky success from that same IP, then failed admin role assignments |
meganb@contoso.com |
Clean successful sign-ins from the UK all week (Exchange/Teams) |
sophial@contoso.com |
Expired-password and disabled-account failures from Germany → password reset by itadmin → successful sign-ins |
jamest@contoso.com |
A failed-then-succeeded login (typo, then success 2 minutes later); consents to an application |
itadmin@contoso.com |
Legitimate admin operations from India (group/user management, the password reset, an unlock) |
Columns: TimeGenerated, EventType (Signin/Audit), UserPrincipalName, IPAddress, AppDisplayName, ResultType, ResultDescription, RiskLevelDuringSignIn, Location, OperationName, AuditResult, Category.
⚠️ One thing to know up front: in this demo dataset
ResultTypeis an integer (0= success). In the realSigninLogstable it's a string ("0"= success). So you'll useResultType != 0here andResultType != "0"in production. This is a deliberate teaching scaffold — the integer reads naturally in the firstwhereexamples — and Stage 03 switches you to the real string form, so it's not an accident to "fix." It's also the single most common beginner trip-up — see../reference/schema-gotchas.md. Confirmed in the SigninLogs table reference.
Method 1 — Seed a function in Sentinel / Log Analytics
This creates a saved function from a datatable(). No ingestion, no waiting.
- Open Microsoft Sentinel → Logs (or Log Analytics → Logs), and make sure the editor is in KQL mode.
- Open
seed-DemoIdentityLogs.kql, copy Method A (the wholedatatable(...)block), paste it into the query editor, and select Run. You'll see 64 rows. - In the results pane, select Save → Save as function. (The Save control is on the query toolbar, top-left of the Logs editor; Save as function opens a small right-hand dialog — not Save as query.)
- Fill in the dialog:
- Function name:
DemoIdentityLogs - Legacy category:
Functions - Leave Save as computer group unchecked and Function parameters empty.
- Function name:
- Select Save. (The function now appears under Functions in the left-hand schema pane — type
DemoIdentityLogsin a new tab and it autocompletes.)
Verify — open a new query tab and run:
DemoIdentityLogs
| take 10
You should immediately see demo sign-in and audit records. Keep the Time range at Last 7 days for all later labs.
Why the data is always "recent": the seed query ends with
extend TimeGenerated = now() - Offset.now()re-evaluates on every run, so the rows always cover the last ~6½ days — comfortably inside anyago(7d)filter.Reference: Save a query as a function · datatable operator
🔒 No permission to save a function? Save as function needs write access to the workspace (e.g. Log Analytics Contributor) — in shared or training tenants you often only have Reader. Use
let-DemoIdentityLogs.kqlinstead: paste itsletblock above each lab query and run. Same dataset, nothing saved, zero permissions needed — and it works in ADX too.
Method 2 — Azure Data Explorer free cluster + CSV
No Azure subscription? Azure Data Explorer (ADX) gives anyone with a Microsoft account a free cluster — no subscription, no credit card, ~100 GB storage, valid for a year (auto-extends). It speaks the same KQL as Sentinel. Source: What is a free Azure Data Explorer cluster?
2a. Create your free cluster (one time, ~2 minutes)
- Go to https://aka.ms/kustofree and sign in with a Microsoft account or Entra identity.
- Create the free cluster — it provisions a cluster and a database for you. Reference: Create a free cluster (web UI)
2b. Load the CSV (UI path — easiest)
- In the ADX web UI, select Query in the left pane. (Your cluster and database show in the left tree; if it's empty, finish 2a first.)
- Right-click your database → Get data. (The database node, not the cluster — the context menu lists Get data.)
- Source = Local file. Target = + New table named
DemoIdentityLogsRaw. - Browse and select
csv/demo_identity_logs.csv→ Next. - On the Inspect tab, tick First row header so the column names map correctly → Finish. (The preview grid should now show
Offset,EventType,UserPrincipalName… as column headers, not as a data row — that's how you know the toggle worked.)
Reference: Get data from a local file
2c. Create the time-rebasing function
The CSV stores an Offset (e.g. 06:00:00) instead of a timestamp, so the data never goes stale. Turn it into the same DemoIdentityLogs the labs expect by pasting this control command (csv/load-into-adx.kql has it too):
.create-or-alter function DemoIdentityLogs() {
DemoIdentityLogsRaw
| extend TimeGenerated = now() - totimespan(Offset)
| project-away Offset
}
Verify:
DemoIdentityLogs
| take 10
Prefer commands over clicking?
csv/load-into-adx.kqlcreates the table, ingests, and builds the function end-to-end.
Done — what's next
You now have DemoIdentityLogs. Continue to Stage 01 · Basics.
When you eventually have real data flowing into Sentinel, Stages 03–04 switch to the real tables (SigninLogs, AuditLogs, DeviceProcessEvents, …) — and you'll already know the operators cold.
Check your own query
Write a variation of this lesson's queries, on the practice table DemoIdentityLogs or a real table, and check it against the real schema.
Course by Kaushik Saha. Source: sentinel/kql/00-setup/README.md at ea5adab001fa. Queries checked with Microsoft.Azure.Kusto.Language 12.4.1 against schema bundle 2026.10.29.