Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Query and analyze data in Azure Data Explorer (Kusto) using KQL for logs and telemetry
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
SKILL.md
1---2name: azure-kusto3description: "Query and analyze data in Azure Data Explorer (Kusto/ADX) using KQL for log analytics, telemetry, and time series analysis. WHEN: KQL queries, Kusto database queries, Azure Data Explorer, ADX clusters, log analytics, time series data, IoT telemetry, anomaly detection."4license: MIT5metadata:6author: Microsoft7version: "1.1.1"8---910# Azure Data Explorer (Kusto) Query & Analytics1112Execute KQL queries and manage Azure Data Explorer resources for fast, scalable big data analytics on log, telemetry, and time series data.1314## Skill Activation Triggers1516**Use this skill immediately when the user asks to:**17- "Query my Kusto database for [data pattern]"18- "Show me events in the last hour from Azure Data Explorer"19- "Analyze logs in my ADX cluster"20- "Run a KQL query on [database]"21- "What tables are in my Kusto database?"22- "Show me the schema for [table]"23- "List my Azure Data Explorer clusters"24- "Aggregate telemetry data by [dimension]"25- "Create a time series chart from my logs"2627**Key Indicators:**28- Mentions "Kusto", "Azure Data Explorer", "ADX", or "KQL"29- Log analytics or telemetry analysis requests30- Time series data exploration31- IoT data analysis queries32- SIEM or security analytics tasks33- Requests for data aggregation on large datasets34- Performance monitoring or APM queries3536## Overview3738This skill enables querying and managing Azure Data Explorer (Kusto), a fast and highly scalable data exploration service optimized for log and telemetry data. Azure Data Explorer provides sub-second query performance on billions of records using the Kusto Query Language (KQL).3940Key capabilities:41- **Query Execution**: Run KQL queries against massive datasets42- **Schema Exploration**: Discover tables, columns, and data types43- **Resource Management**: List clusters and databases44- **Analytics**: Aggregations, time series, anomaly detection, machine learning4546## Core Workflow47481. **Discover Resources**: List available clusters and databases in subscription492. **Explore Schema**: Retrieve table structures to understand data model503. **Query Data**: Execute KQL queries for analysis, filtering, aggregation514. **Analyze Results**: Process query output for insights and reporting5253## Query Patterns5455### Pattern 1: Basic Data Retrieval56Fetch recent records from a table with simple filtering.5758**Example KQL**:59```kql60Events61| where Timestamp > ago(1h)62| take 10063```6465**Use for**: Quick data inspection, recent event retrieval6667### Pattern 2: Aggregation Analysis68Summarize data by dimensions for insights and reporting.6970**Example KQL**:71```kql72Events73| summarize count() by EventType, bin(Timestamp, 1h)74| order by count_ desc75```7677**Use for**: Event counting, distribution analysis, top-N queries7879### Pattern 3: Time Series Analytics80Analyze data over time windows for trends and patterns.8182**Example KQL**:83```kql84Telemetry85| where Timestamp > ago(24h)86| summarize avg(ResponseTime), percentiles(ResponseTime, 50, 95, 99) by bin(Timestamp, 5m)87| render timechart88```8990**Use for**: Performance monitoring, trend analysis, anomaly detection9192### Pattern 4: Join and Correlation93Combine multiple tables for cross-dataset analysis.9495**Example KQL**:96```kql97Events98| where EventType == "Error"99| join kind=inner (100Logs101| where Severity == "Critical"102) on CorrelationId103| project Timestamp, EventType, LogMessage, Severity104```105106**Use for**: Root cause analysis, correlated event tracking107108### Pattern 5: Schema Discovery109Explore table structure before querying.110111**Tools**: `kusto_table_schema_get`112113**Use for**: Understanding data model, query planning114115## Key Data Fields116117When executing queries, common field patterns:118- **Timestamp**: Time of event (datetime) - use `ago()`, `between()`, `bin()` for time filtering119- **EventType/Category**: Classification field for grouping120- **CorrelationId/SessionId**: For tracing related events121- **Severity/Level**: For filtering by importance122- **Dimensions**: Custom properties for grouping and filtering123124## Result Format125126Query results include:127- **Columns**: Field names and data types128- **Rows**: Data records matching query129- **Statistics**: Row count, execution time, resource utilization130- **Visualization**: Chart rendering hints (timechart, barchart, etc.)131132## KQL Best Practices133134**๐ข Performance Optimized:**135- Filter early: Use `where` before joins and aggregations136- Limit result size: Use `take` or `limit` to reduce data transfer137- Time filters: Always filter by time range for time series data138- Indexed columns: Filter on indexed columns first139140**๐ต Query Patterns:**141- Use `summarize` for aggregations instead of `count()` alone142- Use `bin()` for time bucketing in time series143- Use `project` to select only needed columns144- Use `extend` to add calculated fields145146**๐ก Common Functions:**147- `ago(timespan)`: Relative time (ago(1h), ago(7d))148- `between(start .. end)`: Range filtering149- `startswith()`, `contains()`, `matches regex`: String filtering150- `parse`, `extract`: Extract values from strings151- `percentiles()`, `avg()`, `sum()`, `max()`, `min()`: Aggregations152153## Best Practices154155- Always include time range filters to optimize query performance156- Use `take` or `limit` for exploratory queries to avoid large result sets157- Leverage `summarize` for aggregations instead of client-side processing158- Store frequently-used queries as functions in the database159- Use materialized views for repeated aggregations160- Monitor query performance and resource consumption161- Apply data retention policies to manage storage costs162- Use streaming ingestion for real-time analytics (< 1 second latency)163- Integrate with Azure Monitor for operational insights164165## MCP Tools Used166167| Tool | Purpose |168|------|---------|169| `kusto_cluster_list` | List all Azure Data Explorer clusters in a subscription |170| `kusto_database_list` | List all databases in a specific Kusto cluster |171| `kusto_query` | Execute KQL queries against a Kusto database |172| `kusto_table_schema_get` | Retrieve schema information for a specific table |173174**Required Parameters**:175- `subscription`: Azure subscription ID or display name176- `cluster`: Kusto cluster name (e.g., "mycluster")177- `database`: Database name178- `query`: KQL query string (for query operations)179- `table`: Table name (for schema operations)180181**Optional Parameters**:182- `resource-group`: Resource group name (for listing operations)183- `tenant`: Azure AD tenant ID184185## Fallback Strategy: Azure CLI Commands186187If Azure MCP Kusto tools fail, timeout, or are unavailable, use Azure CLI commands as fallback.188189### CLI Command Reference190191| Operation | Azure CLI Command |192|-----------|-------------------|193| List clusters | `az kusto cluster list --resource-group <rg-name>` |194| List databases | `az kusto database list --cluster-name <cluster> --resource-group <rg-name>` |195| Show cluster | `az kusto cluster show --name <cluster> --resource-group <rg-name>` |196| Show database | `az kusto database show --cluster-name <cluster> --database-name <db> --resource-group <rg-name>` |197198### KQL Query via Azure CLI199200For queries, use the Kusto REST API or direct cluster URL:201```bash202az rest --method post \203--url "https://<cluster>.<region>.kusto.windows.net/v1/rest/query" \204--body "{ \"db\": \"<database>\", \"csl\": \"<kql-query>\" }"205```206207### When to Fallback208209Switch to Azure CLI when:210- MCP tool returns timeout error (queries > 60 seconds)211- MCP tool returns "service unavailable" or connection errors212- Authentication failures with MCP tools213- Empty response when database is known to have data214215## Common Issues216217- **Access Denied**: Verify database permissions (Viewer role minimum for queries)218- **Query Timeout**: Optimize query with time filters, reduce result set, or increase timeout219- **Syntax Error**: Validate KQL syntax - common issues: missing pipes, incorrect operators220- **Empty Results**: Check time range filters (may be too restrictive), verify table name221- **Cluster Not Found**: Check cluster name format (exclude ".kusto.windows.net" suffix)222- **High CPU Usage**: Query too broad - add filters, reduce time range, limit aggregations223- **Ingestion Lag**: Streaming data may have 1-30 second delay depending on ingestion method224225## Use Cases226227- **Log Analytics**: Application logs, system logs, audit logs228- **IoT Analytics**: Sensor data, device telemetry, real-time monitoring229- **Security Analytics**: SIEM data, threat detection, security event correlation230- **APM**: Application performance metrics, user behavior, error tracking231- **Business Intelligence**: Clickstream analysis, user analytics, operational KPIs