Перейти к основному содержимому
Microsoft Sentinel & Kusto Query Language (KQL) Triage
Урок 6 из 13

Microsoft Sentinel & Kusto Query Language (KQL) Triage

Navigate Microsoft Sentinel tables and write Kusto Query Language (KQL) queries to hunt suspicious sign-ins, pivot into directory audit logs, and triage cloud identity incidents.

Средний 28 мин Blue Team / SOC
Этого урока пока нет на выбранном языке — показана версия на другом языке. Перевод готовится.

Цели обучения

  • Identify the core Microsoft Sentinel tables used to investigate cloud identity and host incidents
  • Write KQL pipelines using where, extend, summarize, project, and order by for rapid triage
  • Optimize KQL queries by filtering TimeGenerated first and choosing token-indexed operators like has
  • Pivot from suspicious SigninLogs matches into AuditLogs and SecurityEvent to confirm account compromise

Рекомендуется заранее: SIEM Architecture, Normalization & Correlation RulesSplunk (SPL) & Elastic Security (KQL/EQL) Operations

#Why this matters

Many organizations pair on-premises servers with cloud identity providers like Microsoft Entra ID. Microsoft Sentinel ingests both cloud and endpoint telemetry into an Azure Monitor Log Analytics workspace, giving analysts one place to correlate sign-ins, directory changes, and host activity.

When an alert fires for an unfamiliar sign-in or impossible travel, opening the incident in Sentinel is only step one. To decide in minutes whether an employee simply connected over a hotel Wi-Fi hotspot or an attacker hijacked their account, you need fluent Kusto Query Language (KQL) skills to inspect the raw evidence and pivot across tables.

#Sentinel architecture and key tables

Data Connectors stream telemetry into structured tables inside a Log Analytics workspace. Scheduled Analytics Rules run KQL queries over those tables and group matching alerts and entities (users, hosts, IP addresses) into incidents.

Note the naming trap: Azure KQL (Kusto Query Language) is a full piped analytics language similar in power to Splunk SPL, whereas Kibana's KQL (covered in the previous lesson) is a filter-only search bar syntax.

Sentinel table Telemetry source Key columns for triage
SigninLogs Entra ID user sign-ins TimeGenerated, UserPrincipalName, IPAddress, ResultType, LocationDetails, AppDisplayName
AuditLogs Entra ID directory changes TimeGenerated, OperationName, Category, InitiatedBy, TargetResources
SecurityEvent Windows Security Event Log TimeGenerated, EventID, Account, Computer, IpAddress, LogonType
Syslog Linux and network appliances TimeGenerated, Computer, ProcessName, SyslogMessage
CommonSecurityLog CEF firewalls and proxies TimeGenerated, SourceIP, DestinationIP, DeviceAction, RequestURL

#Triage queries in Kusto Query Language

Every KQL query starts with a table name and pipes data downward through tabular operators (|). Filtering on TimeGenerated first shrinks the scanned partitions immediately, keeping triage queries fast.

Essential KQL habits for SOC triage:

  • Use has instead of contains: has looks up whole indexed words (tokens) and runs orders of magnitude faster than contains, which scans every character of a string.
  • Know case sensitivity: == and has differ in case behavior (== is case-sensitive in KQL, while =~ is case-insensitive; has is case-insensitive). For usernames or hostnames, prefer =~ or tolower().
  • Extract nested JSON with extend: fields like LocationDetails are dynamic objects, so extend Country = tostring(LocationDetails.countryOrRegion) pulls out a flat string column for grouping.

The KQL query below hunts Entra ID accounts experiencing multiple failed sign-ins followed by at least one success in the past 24 hours. In SigninLogs, ResultType == "0" indicates success, while "50126" indicates an invalid username or password:

kql
SigninLogs
| where TimeGenerated > ago(24h)
| extend Country = tostring(LocationDetails.countryOrRegion)
| summarize
    TotalAttempts = count(),
    FailedCount = countif(ResultType != "0"),
    SuccessCount = countif(ResultType == "0"),
    Countries = make_set(Country),
    IPs = make_set(IPAddress)
  by UserPrincipalName, AppDisplayName
| where FailedCount >= 5 and SuccessCount >= 1
| order by FailedCount desc

Here countif() counts successes and failures inside a single pass, and make_set() builds a deduplicated array of countries and source IPs for quick analyst inspection.

#Pivoting from alert to incident scope

A suspicious sign-in in SigninLogs rarely tells the whole story on its own. Once you spot a questionable login, pivot by UserPrincipalName or IPAddress into AuditLogs to check whether the actor established persistence (for example, registering a new MFA method or adding an application credential), and into SecurityEvent if the user also accesses on-premises servers.

Pivoting across Sentinel tables during sign-in triagePivoting across Sentinel tables during sign-in triageAnalystSigninLogsAuditLogsSecurityEventSummarize 24h sign-ins for bob@example.test14 failures (50126) then 1 success from 203.0.113.88Check directory changes for bob@example.testNew security info registered 4 minutes laterCheck EventID 4624/4625 on hybrid hostsNo lateral on-prem logons observedConfirmed cloud account takeover - revoke sessions and remove MFA device

#Common mistakes

  • Scanning without a time filter: omitting where TimeGenerated > ago(...) forces Log Analytics to scan the full retention period, slowing down triage and risking query timeouts.
  • Using contains on high-volume tables: where SyslogMessage contains "failed" bypasses token indexes. Use has (where SyslogMessage has "failed") whenever matching complete words or IP tokens.
  • Case-sensitive == mismatches: comparing UserPrincipalName == "Alice@example.test" misses "alice@example.test". Use =~ for case-insensitive exact comparisons.
  • Stopping at SigninLogs: assuming a successful MFA prompt means an alert is benign ignores cases where attackers steal session cookies or register their own MFA device immediately after first access. Always verify AuditLogs.

#Summary

  • Microsoft Sentinel stores normalized cloud and endpoint logs inside Log Analytics tables such as SigninLogs, AuditLogs, SecurityEvent, Syslog, and CommonSecurityLog.
  • Kusto Query Language (KQL) pipes data from early where TimeGenerated filters through extend, summarize (countif, dcount, make_set), project, and order by.
  • Token-indexed operators (has) and case-aware equality (=~) keep queries fast and accurate under pressure.
  • Effective cloud triage always pivots from suspicious SigninLogs events into AuditLogs to uncover persistence actions like unauthorized MFA registrations.

Проверка знаний

Войдите, чтобы проходить тест, завершать уроки и сохранять прогресс. Войти в систему