Skip to content
Skills Library
Data & analytics · Building & coding

kql

/kql

Kusto Query Language authoring, debugging, optimization, translation, and tooling for Azure Monitor, Sentinel, ADX, and Application Insights. USE WHEN user mentions 'KQL', 'Kusto', 'Log Analytics query', 'Sentinel query', 'hunting query', 'ADX query', 'Application Insights query', 'translate SQL to KQL', 'Splunk to KQL', 'optimize query', 'KQL performance', '.kql file', 'detection rule', 'analytics rule', 'threat hunting', 'Azure monitor query', 'log query', 'summarize operator', 'where TimeGenerated', OR any request involving querying Azure log/telemetry data. Even if the user doesn't say "KQ

Licence
MIT
Last repository change
14.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
16
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 14.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Kusto Query Language authoring, debugging, optimization, translation, and tooling for Azure Monitor, Sentinel, ADX, and Application Insights. USE WHEN user mentions 'KQL', 'Kusto', 'Log Analytics query', 'Sentinel query', 'hunting query', 'ADX query', 'Application Insights query', 'translate SQL to KQL', 'Splunk to KQL', 'optimize query', 'KQL performance', '.kql file', 'detection rule', 'analytics rule', 'threat hunting', 'Azure monitor query', 'log query', 'summarize operator', 'where TimeGenerated', OR any request involving querying Azure log/telemetry data. Even if the user doesn't say "KQ

Triggers from the description

KQLKustoLog Analytics querySentinel queryhunting queryADX queryApplication Insights querytranslate SQL to KQL
Original author description

Kusto Query Language authoring, debugging, optimization, translation, and tooling for Azure Monitor, Sentinel, ADX, and Application Insights. USE WHEN user mentions 'KQL', 'Kusto', 'Log Analytics query', 'Sentinel query', 'hunting query', 'ADX query', 'Application Insights query', 'translate SQL to KQL', 'Splunk to KQL', 'optimize query', 'KQL performance', '.kql file', 'detection rule', 'analytics rule', 'threat hunting', 'Azure monitor query', 'log query', 'summarize operator', 'where TimeGenerated', OR any request involving querying Azure log/telemetry data. Even if the user doesn't say "KQ

How it works

  1. Workflow Routing
  2. Reference Files
  3. Sample Queries
  4. Output Format
  5. File Naming
  6. Core Principles
  7. Service-Specific Notes
  8. Examples
  9. Gotchas
Original SKILL.md headings · 97 lines, 808 words
SKILL.md preview
---
name: kql
description: Kusto Query Language authoring, debugging, optimization, translation, and tooling for Azure Monitor, Sentinel, ADX, and Application Insights. USE WHEN user mentions 'KQL', 'Kusto', 'Log Analytics query', 'Sentinel query', 'hunting query', 'ADX query', 'Application Insights query', 'translate SQL to KQL', 'Splunk to KQL', 'optimize query', 'KQL performance', '.kql file', 'detection rule', 'analytics rule', 'threat hunting', 'Azure monitor query', 'log query', 'summarize operator', 'where TimeGenerated', OR any request involving querying Azure log/telemetry data. Even if the user doesn't say "KQL" explicitly — if they're asking about querying Azure logs, security events, or telemetry data, this skill applies.
---

# KQL Skill

Write, debug, optimize, translate, and automate KQL queries across Azure data platforms.

## Workflow Routing

| Workflow | Trigger | File |
|----------|---------|------|
| WriteQuery | "write a query", "create KQL", "query for", "find events where", "show me" | `workflows/WriteQuery.md` |
| DebugOptimize | "optimize", "slow query", "fix this KQL", "improve performance", "debug query" | `workflows/DebugOptimize.md` |
| Translate | "SQL to KQL", "Splunk to KQL", "SPL to KQL", "convert this query" | `workflows/Translate.md` |
| Tooling | "validate KQL", "run query via CLI", "automate query", "schedule alert", "REST API" | `workflows/Tooling.md` |

If no specific workflow matches, default to **WriteQuery**.

## Reference Files

Read these as needed — don't load everything upfront:

| Reference | When to Read | File |
|-----------|-------------|------|
| Operators & Functions | Writing or reviewing any query | `references/operators.md` |
| Service Tables | Need to know available tables for a specific service | `references/service-tables.md` |
| Patterns & Anti-patterns | Optimizing queries or reviewing for best practices | `references/patterns.md` |
| SQL-to-KQL Map | Translating from SQL | `references/sql-to-kql.md` |

## Sample Queries

The `samples/` directory contains production-ready `.kql` files organized by service. Reference these when writing similar queries — they demonstrate the expected file format and conventions.

## Output Format

Every generated query MUST use this `.kql` file format:

```kql
// ============================================================
// Title: <descriptive title>
// Service: <Log Analytics | Sentinel | ADX | App Insights>
// Tables: <comma-separated list of tables used>
// Description: <what this query does and when to use it>
// Parameters: <any variables the user should customize>
// Complexity: <Beginner | Intermediate | Advanced>
// ============================================================

// <the query, with inline comments for non-obvious logic>
```

## File Naming

Use kebab-case: `failed-sign-ins-by-location.kql`, `high-cpu-vms-last-24h.kql`

## Core Principles

1. **Always specify the target service** — KQL varies across Azure services. A query for Sentinel won't necessarily work in ADX.
2. **Time-bound by default** — Include `TimeGenerated` filters (or equivalent) to prevent full-table scans. Default to last 24 hours unless the user specifies otherwise.
3. **Performance first** — Filter early (`where` before `join`/`summarize`), use `has` over `contains` for string matching, avoid `*` projections on wide tables.
4. **Parameterize** — Use `let` statements for values the user will customize (time ranges, thresholds, resource names).
5. **Explain the query** — Add inline comments for non-trivial logic, especially `mv-expand`, `parse`, regex, and complex `summarize` expressions.

## Service-Specific Notes

- **Log Analytics**: No management commands (`.create`, `.alter`). Tables like `Heartbeat`, `Perf`, `Event`, `Syslog`, `AzureActivity`.
- **Sentinel**: Extends Log Analytics with `SecurityEvent`, `SecurityAlert`, `SigninLogs`, `ThreatIntelligenceIndicator`, plus custom analytics rule functions.
- **ADX**: Full KQL engine — supports management commands, materialized views, continuous exports, external tables. Most powerful but queries may not be portable.
- **Application Insights**: Shares Log Analytics engine. Key tables: `requests`, `dependencies`, `exceptions`, `traces`, `customEvents`, `performanceCounters`.

## Examples

**Example 1 — Write Query:**
> "Write a KQL query to find failed sign-ins from outside the US in the last 7 days"
> Routes to: `workflows/WriteQuery.md` → targets Sentinel/Log Analytics, uses `SigninLogs`

**Example 2 — Optimize:**
> "This query takes forever to run, can you make it faster?" (pastes KQL)
> Routes to: `workflows/DebugOptimize.md`

**Example 3 — Translate:**
> "Convert this SQL query to KQL: SELECT * FROM events WHERE severity > 3 GROUP BY source"
> Routes to: `workflows/Translate.md`

**Example 4 — Tooling:**
> "How do I run this query from Azure CLI and export to CSV?"
> Routes to: `workflows/Tooling.md`

---

## Gotchas

- **`ago()` is evaluated at query parse time, not row time** — `where TimeGenerated > ago(1h)` and `| extend Age = now() - TimeGenerated` use different `now()` snapshots by milliseconds. Cache the value in a `let now_ = now();` if comparison matters.
- **`contains` is case-insensitive AND non-indexed; `has` is indexed but token-boundary only:** `where Message has "error"` won't match `errors` (different token). For substring matches use `contains_cs` / `contains` knowing they full-scan.
- **`summarize` without `by` returns one row, hiding all grouping bugs** — if you forgot the `by` clause and got 1 row, that's why. Always project at least one dimension during dev.
- **Cross-cluster `join` is fine; cross-workspace `join` silently truncates** to the first workspace's data set if the table name collides. Use `workspace("foo").Table` aliases on both sides.
- **`extend` is evaluated lazily** — a `where` after it filters BEFORE the extend computes, which is fast but means columns referenced in `where` must already exist. Reorder: `where` first, then `extend`.
- **`SigninLogs` and `AADSignInEventsBeta` are different tables with different schemas** in Sentinel — queries built for one fail on the other with cryptic "column not found" errors. Check `print Tables = "<expected>"` against `getschema`.
- **Sentinel analytics rules cap at 10,000 results per run** silently — your hunting query that returned 50K rows interactively will alert on only 10K. Use `| take 10000` explicitly to surface the limit during testing.
Files in this package (16)
  • SKILL.md 6 KB
  • evals/evals.json 5 KB
  • references/operators.md 8 KB
  • references/patterns.md 8 KB
  • references/service-tables.md 7 KB
  • references/sql-to-kql.md 5 KB
  • samples/adx/iot-anomaly-detection.kql 2 KB
  • samples/app-insights/slow-dependency-calls.kql 2 KB
  • samples/log-analytics/container-restart-analysis.kql 2 KB
  • samples/log-analytics/high-cpu-virtual-machines.kql 1 KB
  • samples/sentinel/failed-sign-ins-by-location.kql 1 KB
  • samples/sentinel/suspicious-powershell-execution.kql 2 KB
  • workflows/DebugOptimize.md 2 KB
  • workflows/Tooling.md 4 KB
  • workflows/Translate.md 2 KB
  • workflows/WriteQuery.md 2 KB

Versions

RepositoryScoreLicence
This page · julianobarbosa/claude-code-skills100MIT
microsoft/skills100MIT
fabioc-aloha/Alex_Skill_Mall100MIT

Identical content appears in 1 other GitHub folders. We show one copy with the highest score.

Database snapshot: 13.11.2026 · package version 2d3d48fc0782 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100azure-kusto
    Query and analyze data in Azure Data Explorer (Kusto/ADX) using KQL for log analytics, telemetry, and time series analysis. USE FOR: KQL queries, Kusto database queries, Azure Data Explorer, ADX clusters, log analytics, time series data, IoT telemetry, anomaly detection DO NOT…
  • 100siem-microsoft-sentinel-kql-analytics
    Use this skill when develop Kusto Query Language (KQL) detection analytics and hunting queries in Microsoft Sentinel.
  • 100azure-observability
    Azure Observability Services including Azure Monitor, Application Insights, Log Analytics, Alerts, and Workbooks. Provides metrics, APM, distributed tracing, KQL queries, and interactive reports. USE FOR: Azure Monitor, Application Insights, Log Analytics, Alerts, Workbooks,…
  • 90kql-authoring
    Use when the user asks to write, tune, explain, debug, optimize, or convert KQL for Intune device query, Log Analytics, Sentinel, sign-in, audit, or compliance data.
  • 95kql-expert
    KQL expert for Microsoft Sentinel, Azure Monitor, and M365 Defender. Use proactively when the user works with any .kql file, writes or reviews KQL queries, develops analytics or detection rules, performs threat hunting, needs DCR transformation KQL, or asks to optimise,…
  • 100kql-query-authoring
    Use this skill when asked to write, create, or help with KQL (Kusto Query Language) queries for Microsoft Sentinel, Defender XDR, or Azure Data Explorer. Triggers on keywords like "write KQL", "create KQL query", "help with KQL", "query [table]", "KQL for [scenario]", or when a…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.