How to run kql query in azure
Content on WhatAnswers is provided "as is" for informational purposes. While we strive for accuracy, we make no guarantees. Content is AI-assisted and should not be used as professional advice.
Last updated: April 4, 2026
Key Facts
- Azure Data Explorer (ADX) is a fully managed, high-performance data analytics service for real-time data analytics on big data.
- Azure Monitor Logs (Log Analytics) collects and analyzes telemetry data from Azure and on-premises environments.
- Azure Sentinel is a cloud-native Security Information and Event Management (SIEM) and Security Orchestration, Automation, and Response (SOAR) solution.
- KQL is designed for data exploration and is optimized for analyzing large volumes of data quickly.
- Common KQL operators include `where`, `project`, `summarize`, `take`, and `sort`.
Overview
Running Kusto Query Language (KQL) queries in Azure is a fundamental skill for anyone working with Azure's data analytics, monitoring, and security services. KQL is a powerful and flexible language designed for exploring data and discovering patterns, anomalies, and trends. Azure provides several integrated environments where you can write and execute KQL queries against your data.
Azure Data Explorer (ADX)
Azure Data Explorer is a fast, fully managed data analytics service for real-time analytics on large datasets. It's ideal for log and telemetry analytics, time-series analytics, and general-purpose big data analytics. The primary interface for interacting with ADX is the Azure Data Explorer web UI. Here's how you can use it:
- Access the Web UI: Navigate to the Azure Data Explorer web UI (dataexplorer.azure.com).
- Connect to Cluster: Sign in and connect to your ADX cluster.
- Write Queries: In the query editor, you can write your KQL queries. The editor provides IntelliSense, syntax highlighting, and error checking to assist you.
- Execute Queries: Run your query by clicking the 'Run' button or pressing Shift+Enter.
- Visualize Results: ADX offers various charting options to visualize your query results directly within the UI.
ADX is particularly useful when you need high-performance query execution and advanced analytics capabilities on massive datasets.
Azure Monitor Logs (Log Analytics)
Azure Monitor Logs is a service that collects, aggregates, and analyzes telemetry data from Azure and on-premises environments. It's a core component for monitoring the health, performance, and availability of your applications and infrastructure. Log Analytics provides a dedicated workspace where logs and metrics are stored, and KQL is the query language used to analyze this data.
Steps to run KQL in Log Analytics:
- Access Log Analytics: Go to the Azure portal and navigate to your Log Analytics workspace.
- Open Logs: Within the workspace, click on 'Logs' in the left-hand navigation pane.
- Write KQL: The Logs query editor will open. You can start typing your KQL queries here. The available tables (representing different log sources) are listed in the 'Tables' pane on the left.
- Execute and Analyze: Run your queries and use the built-in charting tools to visualize the data. Log Analytics is excellent for operational troubleshooting, security analysis, and understanding application behavior.
You can ingest data from various sources into Log Analytics, including Azure resources, virtual machines, containers, and custom applications.
Azure Sentinel
Azure Sentinel is Microsoft's cloud-native Security Information and Event Management (SIEM) and Security Orchestration, Automation, and Response (SOAR) solution. It provides intelligent security analytics and threat intelligence across your enterprise. KQL is the backbone for querying security data, hunting for threats, and creating detection rules within Azure Sentinel.
How to use KQL in Azure Sentinel:
- Access Azure Sentinel: Navigate to your Azure Sentinel instance in the Azure portal.
- Threat Hunting: Go to the 'Threat hunting' section. Here, you can write KQL queries to proactively search for security threats in your data.
- Workbooks: Use KQL within 'Workbooks' to create custom dashboards and visualizations for security data.
- Analytics Rules: Define detection logic for security alerts using KQL in 'Analytics rules'.
Sentinel leverages KQL to make sense of vast amounts of security-related logs and events, enabling faster threat detection and response.
Key KQL Concepts and Operators
Regardless of the Azure service you use, understanding basic KQL syntax is crucial:
- Tables: Data is organized into tables (e.g., `Heartbeat`, `Perf`, `SecurityEvent` in Log Analytics).
- Operators: These are keywords that transform or manipulate data. Common ones include:
- `take`: Returns a specified number of rows.
- `where`: Filters rows based on a condition.
- `project`: Selects specific columns.
- `summarize`: Aggregates data using functions like `count()`, `avg()`, `sum()`.
- `sort by`: Orders the results.
- `extend`: Adds new calculated columns.
- Pipes (`|`): Operators are chained together using the pipe symbol, allowing for sequential data processing.
Example Query (Log Analytics): Find the top 10 most frequent IP addresses that accessed a web server in the last hour:
AzureActivity| where TimeGenerated > ago(1h)| summarize count() by Caller| top 10 by count_Choosing the Right Tool
The choice of where to run your KQL queries depends on your specific needs:
- Use Azure Data Explorer for high-performance, large-scale data analytics and exploration.
- Use Azure Monitor Logs (Log Analytics) for operational monitoring, troubleshooting, and analyzing telemetry data from your Azure and hybrid environments.
- Use Azure Sentinel for security-specific threat hunting, incident investigation, and automated response.
All these services leverage the power and flexibility of KQL, making it a versatile language for data analysis within the Azure ecosystem.
More How To in Daily Life
Also in Daily Life
More "How To" Questions
Trending on WhatAnswers
Browse by Topic
Browse by Question Type
Sources
Missing an answer?
Suggest a question and we'll generate an answer for it.