KQL (Kusto Query Language) は Microsoft Sentinel の事実上必須スキルです。 Sentinel のすべてのクエリ・Hunting Query・Workbook・Analytics Rule は KQL で記述されます。 本記事では、SOC アナリストが日常業務で即活用できる KQL レシピを 20 パターン以上、解説付きで整理します。
KQL は SQL に似たパイプライン構文 (table | where ... | summarize ...) で、ログ分析・脅威ハンティングに最適化されています。
過去 1 時間に同一 User + IP から 10 回以上の失敗サインインを検出。
SigninLogs | where TimeGenerated > ago(1h) | where ResultType != 0 | summarize FailedCount = count() by UserPrincipalName, IPAddress | where FailedCount > 10 | order by FailedCount desc
失敗多数の後に成功したアカウントを検出 (パスワードスプレー成功の典型パターン)。
SigninLogs
| where TimeGenerated > ago(1h)
| summarize FailedCount = countif(ResultType != 0),
SuccessCount = countif(ResultType == 0)
by UserPrincipalName, IPAddress
| where FailedCount > 5 and SuccessCount > 024 時間以内に複数地理的位置からのサインインを検出。
SigninLogs
| where TimeGenerated > ago(24h)
| where ResultType == 0
| extend Country = tostring(LocationDetails.countryOrRegion)
| summarize CountryList = make_set(Country),
IPList = make_set(IPAddress),
TimeList = make_list(TimeGenerated)
by UserPrincipalName
| where array_length(CountryList) > 1特権ロール (Global Admin・Privileged Role Admin) の付与を検知。
AuditLogs
| where TimeGenerated > ago(7d)
| where OperationName == "Add member to role"
| extend RoleName = tostring(TargetResources[0].modifiedProperties[1].newValue)
| extend AddedUser = tostring(TargetResources[0].userPrincipalName)
| where RoleName in ("Global Administrator", "Privileged Role Administrator")
| project TimeGenerated, AddedUser, RoleName,
InitiatedBy = tostring(InitiatedBy.user.userPrincipalName)Conditional Access でブロックされたサインインの集計。
SigninLogs
| where TimeGenerated > ago(7d)
| where ConditionalAccessStatus == "failure"
| extend BlockedPolicy = tostring(ConditionalAccessPolicies[0].displayName)
| summarize BlockedCount = count()
by UserPrincipalName, BlockedPolicy, ResultDescription
| order by BlockedCount descSecurityAlert | where TimeGenerated > ago(7d) | where AlertSeverity == "High" | extend ResourceId = tostring(parse_json(ExtendedProperties).ResourceId) | summarize HighAlerts = count() by ResourceId, AlertName | order by HighAlerts desc
SecurityEvent | where TimeGenerated > ago(1d) | where EventID == 4624 | where LogonType in (10, 7) // RemoteInteractive, Unlock | summarize LoginCount = count() by Account, IpAddress, Computer | where LoginCount > 50 | order by LoginCount desc
StorageBlobLogs
| where TimeGenerated > ago(1d)
| where StatusCode == 403
| summarize ForbiddenCount = count()
by CallerIpAddress, AccountName, OperationName
| where ForbiddenCount > 100
| order by ForbiddenCount descSigninLogs | where TimeGenerated > ago(1d) | where ResultType != 0 | summarize FailedCount = count() by bin(TimeGenerated, 1h) | render timechart
SigninLogs
| where TimeGenerated > ago(7d)
| where ResultType != 0
| summarize AttackCount = count(), Users = dcount(UserPrincipalName)
by IPAddress
| where AttackCount > 100
| order by AttackCount desc
| take 10Sentinel Analytics Rule は MITRE ATT&CK の Tactics と Techniques をマッピングして登録可能。
| MITRE Technique | 戦術 | Sentinel での検知例 |
|---|---|---|
| T1110 Brute Force | Credential Access | SigninLogs 失敗サインイン大量検知 |
| T1078 Valid Accounts | Initial Access / Persistence | 管理者異常時間サインイン |
| T1098 Account Manipulation | Persistence | AuditLogs Add owner to application |
| T1059 Command and Scripting | Execution | SecurityEvent 異常 PowerShell 実行 |
| T1486 Data Encrypted for Impact | Impact (Ransomware) | SecurityEvent 大量ファイル暗号化検知 |
Microsoft の公式 GitHub (Azure-Sentinel) で 300+ の MITRE マッピング済みクエリが公開されており、コピペベースで活用可能です。
Log Analytics の Query Performance ペインで Time Range・Records Examined を確認しながらチューニング、本番 Analytics Rule では実行時間 5 分以内が目安です。
KQL とは何ですか?
KQL (Kusto Query Language) は Microsoft が開発したクエリ言語で、Azure Monitor Log Analytics・Microsoft Sentinel・Microsoft Defender Advanced Hunting・Microsoft Fabric Real-Time Intelligence など複数の Microsoft 製品で標準採用。SQL に似たパイプライン構文 (table | where ... | summarize ...) で、ログ分析・脅威ハンティング・メトリクス分析に最適化されている。SQL 経験者なら数日でキャッチアップ可能で、Microsoft Sentinel を使う SOC アナリスト・Azure Monitor を使うインフラエンジニア・Fabric Real-Time Intelligence を使うデータエンジニアにとって事実上必須のスキルです。
KQL の基本構文は?
基本パイプライン構文: テーブル名 → 演算子 → 演算子 → ... の順で `|` で連結。代表演算子: project (列選択)・extend (列追加)・summarize (集計)・where (フィルタ)・join (結合)・union (テーブル結合)・parse (文字列パース)・extract (正規表現抽出)・mv-expand (配列展開)・bin (時間バケット化)・ago (過去時間指定)・now (現在時刻)・make-set / make-list (配列集計)・dcount (重複除いた件数)。例: `SigninLogs | where TimeGenerated > ago(1d) | where ResultType != 0 | summarize Count = count() by UserPrincipalName | top 10 by Count desc`。SQL の SELECT/FROM/WHERE/GROUP BY をパイプライン化したイメージで、慣れると SQL より直感的・簡潔に書けるのが KQL の魅力です。
Sentinel の失敗サインインを検知する KQL は?
標準パターン: `SigninLogs | where TimeGenerated > ago(1h) | where ResultType != 0 | summarize FailedCount = count() by UserPrincipalName, IPAddress | where FailedCount > 10 | order by FailedCount desc`。これで過去 1 時間に同一 User + IP から 10 回以上の失敗サインインを検出。応用: 失敗後成功を検知 (パスワードスプレー成功): `SigninLogs | where TimeGenerated > ago(1h) | summarize FailedCount = countif(ResultType != 0), SuccessCount = countif(ResultType == 0) by UserPrincipalName, IPAddress | where FailedCount > 5 and SuccessCount > 0`。Brute Force 検知の基本パターンで、本番 Sentinel Analytics Rule の核となるクエリです。
Impossible Travel を検知する KQL は?
Impossible Travel (短時間に物理的に到達不可能な距離移動) は侵害アカウントの典型パターン。KQL 例: `SigninLogs | where TimeGenerated > ago(24h) | where ResultType == 0 | extend Location = Location | summarize LocationList = make_set(Location), IPList = make_set(IPAddress), TimeList = make_list(TimeGenerated) by UserPrincipalName | where array_length(LocationList) > 1 | mv-expand LocationList`。実運用では Microsoft Entra ID Identity Protection の組み込み Impossible Travel リスクを Sentinel に取り込んで使うのが一般的で、自前 KQL は補完的に活用。Identity Protection リスク信号を Conditional Access で活用するのがゼロトラスト戦略のベストプラクティスです。
MITRE ATT&CK マッピングの KQL は?
Sentinel Analytics Rule は MITRE ATT&CK の Tactics (戦術) と Techniques (技法) をマッピングして登録可能。例: T1110 Brute Force (Credential Access 戦術) は『SigninLogs の失敗サインイン大量検知』、T1078 Valid Accounts (Initial Access / Persistence) は『管理者アカウントの異常時間サインイン』、T1098 Account Manipulation (Persistence) は『AuditLogs の Add owner to application 検知』。組み込みの Sentinel Hunting Query には MITRE ATT&CK タグが付与されており、SOC アナリストはタグでクエリを検索可能。Microsoft の公式 GitHub (Azure-Sentinel) で 300+ の MITRE マッピング済みクエリが公開されており、コピペベースで活用可能です。
Defender for Cloud の脅威を分析する KQL は?
Defender for Cloud の SecurityAlert テーブル分析: SecurityAlert | where TimeGenerated > ago(7d) | summarize AlertCount = count() by AlertSeverity, AlertName | order by AlertCount desc | top 20 by AlertCount。High Severity のみ抽出 + リソース別集計: SecurityAlert | where AlertSeverity == 'High' | extend ResourceId = tostring(parse_json(ExtendedProperties).ResourceId) | summarize HighAlerts = count() by ResourceId | order by HighAlerts desc。応用: 自動応答ルール (Automation Rules) と組み合わせて High Severity アラートで Logic App Playbook 起動 (例: VM 隔離・チケット起票・Slack 通知)。SOC 業務の効率化に直結する重要パターンです。
KQL のパフォーマンス最適化のコツは?
重要な最適化テクニック: 1) 時間範囲を必ず絞る (where TimeGenerated > ago(7d))、これだけで処理量が桁違い、2) where 句は早めに配置 (パイプライン左側で絞る方が後続処理が軽い)、3) project で必要な列だけ選択 (不要列を早めに切る)、4) summarize は最後 (大量データ集計より絞ってから集計)、5) join より union + summarize のほうが高速なケースあり、6) parse は正規表現より文字列演算が速い、7) take / top で結果数を制限、8) materialize() でサブクエリを物理化してリユース。Log Analytics の Query Performance ペインで Time Range・Records Examined を確認しながらチューニング、本番 Analytics Rule では実行時間 5 分以内が目安です。
関連認定試験は?
SC-200 (Security Operations Analyst Associate) で KQL が深く問われる、本領域の本命認定。AZ-104 (Administrator) のドメイン 5 で Azure Monitor + KQL 基礎、SC-100 (Cybersecurity Architect Expert) で SOC アーキテクチャ設計、DP-700 (Fabric Data Engineer) で Fabric Real-Time Intelligence (KQL Database) 文脈、MS-102 (Microsoft 365 Administrator Expert) のドメイン 3 で Defender XDR + Advanced Hunting (KQL ベース)。KQL は Microsoft 製品全般で標準採用されており、Azure / Microsoft 365 / Fabric を扱うすべてのエンジニアにとって必須スキルです。
関連記事・技術深掘り
SC-200 完全ガイド|Microsoft Security Operations Analyst Associate 出題範囲・学習リソース・合格戦略【2026 年版】
Microsoft Certified: Security Operations Analyst Associate (SC-200) の完全ガイド。4 ドメインの出題範囲、Microsoft Sentinel / Defender XDR (Endpoint / Cloud / Identity / Office 365 / Cloud Apps) の運用スキル、KQL Hunting Query、3-4 ヶ月の合格ロードマップ、SC-300 / SC-100 / SC-500 への展開ルートを日本語で網羅。
Microsoft Defender for Cloud 完全ガイド|CSPM・CWPP・Just-in-Time VM・マルチクラウド保護【2026 年版】
Microsoft Defender for Cloud (旧 Azure Security Center) の完全ガイド。Free Tier vs Defender Plans 選定、Microsoft Secure Score・Just-in-Time VM Access・Vulnerability Assessment・マルチクラウド (AWS/GCP) 対応・Microsoft Sentinel との連携・関連認定試験 (SC-200 / SC-100 / SC-500) を日本語で網羅。
Azure セキュリティエンジニア キャリアロードマップ|SC-900 → SC-200/300/400 → SC-100 シニアへの道【2026 年版】
Azure セキュリティエンジニアになるための認定取得ロードマップ完全版。SC-900 → SC-200/300/400 のいずれか → SC-100 / SC-500 の王道ルート、ロール別の優先順序、CISSP との二刀流戦略、SC-500 (旧 AZ-500 後継、2026-09 GA 予定) の動向、10-15 ヶ月の学習プラン、年収レンジまで日本語で網羅。
SC-900 完全ガイド|Microsoft Security, Compliance, and Identity Fundamentals 出題範囲・学習リソース・合格戦略
Microsoft Certified: Security, Compliance, and Identity Fundamentals (SC-900) の完全ガイド。Zero Trust・Microsoft Entra・Defender スイート・Purview の出題範囲、無料 Virtual Training Day バウチャー、4 週間合格ロードマップ、SC-200 / SC-300 / SC-500 / SC-100 へのキャリアパスを日本語で網羅。
本記事の技術情報は Microsoft Sentinel Documentation およびKusto Query Language Documentation に基づいています。 本記事は Microsoft Corporation の公式商品ではなく、いかなる提携・後援関係もありません。 Microsoft、Azure、Microsoft Sentinel、Microsoft Defender、Microsoft Entra は Microsoft group of companies の商標です。MITRE ATT&CK は MITRE Corporation の登録商標です。 情報は 2026 年 5 月 24 日時点の公式公開資料に基づきます。最新情報は必ず公式ページをご確認ください。
NicheeLab編集部
データエンジニアリング・クラウド資格の専門家。Databricks・Snowflake等の認定資格を保有し、実務経験に基づいた問題作成・解説を行っています。NicheeLab運営。
AZ-900 完全ガイド|Microsoft Azure Fundamentals 出題範囲・学習リソース・合格戦略
Microsoft Azure Fundamentals (AZ-900) の 2026 年 1 月 14 日改訂版に対...
Azure 認定資格ロードマップ 2026 完全版|全 26 試験の体系と大型再編 (AI-901/AI-103/SC-500)
Microsoft Azure 認定資格 全 26 試験 (現行 23 + 退役 3) の 2026 年版ロードマップ。...
AI-901 完全ガイド|Azure AI Fundamentals 新試験
Microsoft Certified: Azure AI Fundamentals (AI-901) の出題範囲・Mi...
Microsoft Entra ID 入門|旧 Azure AD から学ぶ ID 管理 (AZ-900/SC-900/AZ-104 必須知識)
Microsoft Entra ID (旧 Azure Active Directory) の入門解説。2023 年 7...
DP-900 完全ガイド|Azure Data Fundamentals 出題範囲・学習リソース・合格戦略
Microsoft Azure Data Fundamentals (DP-900) の完全ガイド。4 ドメインの出題範...