Build KQL queries for Azure Log Analytics with saved searches and alert rules.
Last verified: May 2026
Output will appear here...Azure Log Analytics workspaces are the central repository for log data in Azure Monitor, storing data from Azure resources, applications, agents, and custom sources. Querying this data uses Kusto Query Language (KQL), a powerful language for filtering, aggregating, joining, and visualizing log data. Building effective KQL queries requires understanding table schemas, time-range filtering, summarize operators, and join patterns. The Log Analytics Query Builder helps you construct KQL queries with proper syntax, common table references, and alert rule configurations for operational monitoring scenarios.
Your team's Azure Monitor bill jumped 3x last month. Investigation reveals an alert rule running every minute against 90 days of AppRequests data (~500 GB scanned per execution × 43,200 executions/month). The builder helps rewrite: query restricted to last 15 minutes, aggregated via summarize, evaluated every 5 minutes. New monthly scan volume drops from 21 PB to 50 GB. Bill returns to baseline; alert latency increases by 4 minutes (acceptable trade-off for 99.99% cost reduction).
Always tighten the time range BEFORE filtering. KQL evaluates queries left-to-right, so `Heartbeat | where Computer == 'X' | where TimeGenerated > ago(1h)` scans ALL data first then filters. The right pattern: `Heartbeat | where TimeGenerated > ago(1h) | where Computer == 'X'`. The cost difference at 30-day data scale can be 100x.
summarize is the most-impactful KQL operator for cost. Aggregating raw data to time buckets (`summarize count() by bin(TimeGenerated, 5m)`) returns 288 rows for a day instead of millions. Almost any query feeding a dashboard or alert should end with summarize.
Use `take` instead of `limit` for ad-hoc exploration — `take 100` returns 100 rows fast without sorting. `top 100 by X` requires a full sort, which is slow on large datasets. For 'show me 10 random examples' queries, take is dramatically faster.
The builder generates KQL queries with proper structure: source table, time-range filter (TimeGenerated > ago(...)), additional where filters, projection (project), aggregation (summarize with operators like count, avg, percentile, dcount), grouping (by ... bin(TimeGenerated, ...)), sorting (order by), and visualization hint (render). Output also generates Azure log alert rule configurations (frequency, evaluation window, threshold, action group) and saved search definitions.
Was this tool helpful?
Disclaimer: This tool runs entirely in your browser. No data is sent to our servers. Always verify outputs before using them in production. AWS, Azure, and GCP are trademarks of their respective owners.