K0.1 Three Questions You Cannot Answer Without KQL
Question 1: historical scope — “Has this ever happened before?”
Rachel receives a DE4-002 alert: j.morrison authenticated from 185.220.101.42, a Tor exit node. The immediate question is not “is this bad?” — the Tor exit node makes that obvious. The investigation question is: has j.morrison EVER authenticated from this IP before? If yes: this might be a recurring VPN or proxy pattern. If no: this is definitively a new, anomalous event.
The Sentinel portal shows j.morrison’s recent sign-ins — the last 30 days in the default investigation view. But “ever” means the full retention period: 90 days, 180 days, or 2 years depending on the workspace configuration. The portal does not provide a “search all history for this specific IP” button.
| |
This query runs in 12 seconds across 90 days of SigninLogs. The answer is binary and definitive. No portal clicking, no scrolling through pages, no ambiguity. The query answers the question the investigation demands.
Why the portal cannot do this: The portal’s sign-in investigation view filters by USER and shows recent events. It does not provide a combined USER + IP + FULL HISTORY filter. The workbook “Sign-in Analysis” shows aggregated IP statistics but not per-user IP history. Only a direct query against the raw SigninLogs table answers: “Has THIS user EVER authenticated from THIS IP?”
Figure K0.1 — Three categories of security questions that require KQL. Each category represents a ceiling the portal UI cannot breach.
Question 2: cross-table correlation — “Did event A cause event B?”
NE’s SOC receives two alerts within 40 minutes: DE4-002 (AiTM token theft for j.morrison at 08:14) and DE5-001 (inbox rule creation by j.morrison at 08:47). Individually, each alert has an investigation path. But the CRITICAL question is: are these two events part of the same attack?
The Sentinel incident queue may group them — if the alert grouping rules are configured to correlate by entity. But if they are separate incidents, the analyst must manually determine whether the AiTM token theft LED TO the inbox rule creation. This requires joining two different data sources: SigninLogs (where the token theft occurred) and OfficeActivity (where the inbox rule was created).
| |
This query proves CAUSATION, not just correlation. The inbox rule was created from the same IP address as the stolen token — the attacker used the stolen session to create the persistence mechanism. Without this cross-table join, the analyst has two separate alerts and a SUSPICION of connection. With the query, the analyst has PROOF.
Why the portal cannot do this: The Sentinel investigation graph shows entities connected to a single incident. It does not perform cross-incident, cross-table joins. The analyst cannot ask: “show me all OfficeActivity from the same IP as this SigninLogs event” through the portal UI. Only a KQL join connects data across tables.
Question 3: statistical baseline — “Is this normal for this user?”
s.chen downloaded 52 .dwg files from SharePoint in 28 minutes. DE7-002 fires (threshold: 50 files in 30 minutes). Is this an attack or a legitimate project? The alert does not answer the question. The investigation question is: what is s.chen’s NORMAL download volume?
| |
The percentile analysis transforms a binary alert (“above threshold / below threshold”) into a CONTEXTUAL assessment (“this is at the 99th percentile of this user’s historical pattern”). The analyst now knows: 52 downloads is unusual for s.chen but not unprecedented — it happened once before (the 55-download day, likely a previous project deadline). Without this query, the analyst classifies based on gut feel. With it, the analyst classifies based on data.
Why the portal cannot do this: The Sentinel portal shows OfficeActivity events but does not calculate per-user percentile baselines. No workbook provides “show me this user’s download volume compared to their own historical pattern.” Only a KQL summarize with percentile() answers this question.
The pattern: KQL answers questions the portal cannot express
These three questions represent three categories that recur throughout security operations:
Historical scope (Question 1): “Has this entity appeared in our data before, and when?” — requires full-retention searches filtered to specific field combinations that the portal does not support.
Cross-table correlation (Question 2): “Did event A in Table X cause event B in Table Y?” — requires joins between tables that the portal treats as separate data sources.
Statistical baseline (Question 3): “Is this volume/frequency/pattern normal for this entity?” — requires aggregation, percentile calculation, and comparison that the portal’s pre-built views cannot express.
Every module in this course teaches KQL operators that answer these three question categories. By KQ13, the learner can answer ANY security question their investigation demands — not just the questions the portal designers anticipated.
The myth: Microsoft invested billions in the Sentinel and Defender XDR portal UIs. They are designed for security analysts. If the portal cannot answer a question, the question probably does not need answering.
The reality: The portal is designed for the 80% of routine triage that follows predictable patterns. The remaining 20% — the investigations that determine whether an alert is a sophisticated attack or a benign anomaly — requires questions that portal designers could not anticipate. Every environment is different. Every investigation has unique questions. KQL is the tool that answers the questions your specific investigation demands, not the generic questions the portal was designed to handle. The portal is the starting point. KQL is where the real investigation happens.
Try it yourself
Exercise: Identify a question your portal cannot answer
Think about your last 3 security investigations. For each: was there a moment where you wanted to know something specific but the portal could not show you? Write that question down. By the end of this course, you will be able to write the KQL query that answers it.
Check your understanding
An analyst receives an alert for "unusual sign-in from new country" for a user. The portal shows the sign-in occurred from Brazil. The analyst needs to determine: (a) has ANY NE user ever signed in from Brazil before, and (b) did the user access any SharePoint files after this sign-in. Which question categories do (a) and (b) represent?
Answer: (a) is a HISTORICAL SCOPE question — searching the full SigninLogs retention for any UserPrincipalName where Location contains "Brazil". The portal shows individual user history but cannot search ALL users for a specific location. (b) is a CROSS-TABLE CORRELATION question — joining SigninLogs (the Brazil sign-in) with OfficeActivity (SharePoint file access) to determine if the suspicious session led to data access. Both require KQL queries that the portal UI cannot express.
Troubleshooting
“I do not have access to the Sentinel Logs blade.” You need at least the Microsoft Sentinel Reader role or Log Analytics Reader role to run KQL queries. Contact your Azure AD administrator. In Defender XDR, you need access to Advanced Hunting — this is available with Microsoft 365 E5 or Defender for Endpoint P2 licensing.
References used in this subsection
- Detection Engineering DE4-002 (AiTM token theft — the investigation that requires Question 1)
- Detection Engineering DE7-002 (SharePoint bulk download — the investigation that requires Question 3)
You're reading the free modules of Mastering KQL
The full course continues with advanced topics, production detection rules, worked investigation scenarios, and deployable artifacts. Premium subscribers get access to all courses.