Log queries in Azure Monitor - Azure Monitor (2024)

  • Article

Azure Monitor Logs is based on Azure Data Explorer, and log queries are written by using the same Kusto Query Language (KQL). This rich language is designed to be easy to read and author, so you should be able to start writing queries with some basic guidance.

Areas in Azure Monitor where you'll use queries include:

  • Log Analytics: Use this primary tool in the Azure portal to edit log queries and interactively analyze their results. Even if you intend to use a log query elsewhere in Azure Monitor, you'll typically write and test it in Log Analytics before you copy it to its final location.
  • Log search alert rules: Proactively identify issues from data in your workspace. Each alert rule is based on a log query that's automatically run at regular intervals. The results are inspected to determine if an alert should be created.
  • Workbooks: Include the results of log queries by using different visualizations in interactive visual reports in the Azure portal.
  • Azure dashboards: Pin the results of any query into an Azure dashboard, which allows you to visualize log and metric data together and optionally share with other Azure users.
  • Azure Logic Apps: Use the results of a log query in an automated workflow by using a logic app workflow.
  • PowerShell: Use the results of a log query in a PowerShell script from a command line or an Azure Automation runbook that uses Invoke-AzOperationalInsightsQuery.
  • Log Analytics Query API: Retrieve log data from the workspace from any REST API client. The API request includes a query that's run against Azure Monitor to determine the data to retrieve.
  • Azure Monitor Query client libraries: Retrieve log data from the workspace via an idiomatic client library for the following ecosystems:

Get started

The best way to get started learning to write log queries by using KQL is to use available tutorials and samples:

  • Log Analytics tutorial: Tutorial on using the features of Log Analytics, which is the tool that you'll use in the Azure portal to edit and run queries. It also allows you to write simple queries without directly working with the query language. If you haven't used Log Analytics before, start here so that you understand the tool you'll use with the other tutorials and samples.
  • KQL tutorial: Guided walk through basic KQL concepts and common operators. This is the best place to start to come up to speed with the language itself and the structure of log queries.
  • Example queries: Description of the example queries available in Log Analytics. You can use the queries without modification or use them as samples to learn KQL.

Reference documentation

Documentation for KQL, including the reference for all commands and operators, is available in the Azure Data Explorer documentation. Even as you get proficient at using KQL, you'll still regularly use the reference to investigate new commands and scenarios that you haven't used before.

Language differences

Although Azure Monitor uses the same KQL as Azure Data Explorer, there are some differences. The KQL documentation will specify those operators that aren't supported by Azure Monitor or that have different functionality. Operators specific to Azure Monitor are documented in the Azure Monitor content. The following sections list the differences between versions of the language for quick reference.

Statements not supported in Azure Monitor

Functions not supported in Azure Monitor

Operator not supported in Azure Monitor

Cross-Cluster Join

Plug-ins not supported in Azure Monitor

Other operators in Azure Monitor

The following operators support specific Azure Monitor features and aren't available outside of Azure Monitor:

Next steps

Log queries in Azure Monitor - Azure Monitor (2024)

FAQs

How to check logs in Azure Monitor? ›

To view activity log insights at the resource group or subscription level:
  1. In the Azure portal, select Monitor > Workbooks.
  2. In the Insights section, select Activity Logs Insights.
  3. At the top of the Activity Logs Insights page, select: One or more subscriptions from the Subscriptions dropdown.
Feb 29, 2024

How does Azure Monitor organize log data for queries? ›

How does Azure Monitor organize log data for queries? Azure Monitor organizes log data into tables. Azure Monitor organizes log data in tables, each composed of multiple columns. Every query contains data that's organized into a hierarchy similar to SQL (databases, tables, and columns).

What is log queries in Azure? ›

Azure Monitor Logs is based on Azure Data Explorer, and log queries are written by using the same Kusto Query Language (KQL). This rich language is designed to be easy to read and author, so you should be able to start writing queries with some basic guidance.

What is the difference between Azure Monitor and logs? ›

In conclusion, Azure Monitor and Log Analytics collectively offer a robust solution for monitoring Azure resources. While Azure Monitor provides a lot of features including aggregation of logs, real-time insights and performance metrics, Log Analytics allows advanced query capabilities and extensive log data analysis.

How long does Azure Monitor keep logs? ›

Azure Monitor Logs archive provides up to 12 years of retention.

How do I send logs to Azure Monitor? ›

Create new table in Log Analytics workspace
  1. Go to the Log Analytics workspaces menu in the Azure portal and select Tables. ...
  2. Specify a name for the table. ...
  3. Select Create a new data collection rule to create the DCR that will be used to send data to this table. ...
  4. Select the DCR that you created, and then select Next.
Jan 2, 2024

Does Azure Monitor allow you to create alerts from log queries? ›

Azure Monitor alerts proactively notify you when important conditions are found in your monitoring data. Log search alert rules create an alert when a log query returns a particular result.

Does Azure Monitor use Log Analytics? ›

Log Analytics is a tool in the Azure portal to edit and run log queries from data collected by Azure Monitor logs and interactively analyze their results. You can use Log Analytics queries to retrieve records that match particular criteria, identify trends, analyze patterns, and provide various insights into your data.

What language does Azure log query use? ›

Kusto Query Language (KQL) overview - Azure Data Explorer & Real-Time Analytics | Microsoft Learn.

What is a log query? ›

All LogQL queries contain a log stream selector. Optionally, the log stream selector can be followed by a log pipeline. A log pipeline is a set of stage expressions that are chained together and applied to the selected log streams.

How many types of logs are there in Azure? ›

Azure logs are categorized into the following types: Control/management logs provide information about Azure Resource Manager CREATE, UPDATE, and DELETE operations. For more information, see Azure activity logs. Data plane logs provide information about events raised as part of Azure resource usage.

What data does Azure Monitor collect? ›

Azure Monitor collects and aggregates the data from every layer and component of your system across multiple Azure and non-Azure subscriptions and tenants. It stores it in a common data platform for consumption by a common set of tools that can correlate, analyze, visualize, and/or respond to the data.

How do I monitor Azure function logs? ›

To view a near real time stream of application log files generated by your function running in Azure, you can connect to Application Insights and use Live Metrics Stream. Or, you can use the App Service platform built-in log streaming to view a stream of application log files.

How to do a query in Azure? ›

To run any query, expand a folder and choose the title of the query. The view opens to display the query Results. You can also run a query by using the Azure DevOps command line interface. The Queries page, as with other web portal pages, remembers the view you last went to and returns you to that view.

How do I Monitor Azure function logs? ›

To view a near real time stream of application log files generated by your function running in Azure, you can connect to Application Insights and use Live Metrics Stream. Or, you can use the App Service platform built-in log streaming to view a stream of application log files.

Where is the log data that is viewed by Azure Monitor stored? ›

Azure Monitor Logs stores the data that it collects in one or more Log Analytics workspaces. You must create at least one workspace to use Azure Monitor Logs. For a description of Log Analytics workspaces, see Log Analytics workspace overview.

How do I check my telemetry logs in Azure? ›

Viewing ILogger Telemetry

In the Azure Portal: Go to the Azure Portal and access your Application Insights resource. Click on the "Logs" section inside Application Insights. Use Kusto Query Language (KQL) to query ILogger messages, usually stored in the traces table.

How do I check my Azure app logs? ›

In the Azure portal, navigate to your App Service and click on “App Service logs” under the Monitoring section. Under “Application Logging (File System)”, select “Azure Blob Storage” as the destination. Choose an existing storage account or create a new one.

Top Articles
Latest Posts
Article information

Author: Golda Nolan II

Last Updated:

Views: 5655

Rating: 4.8 / 5 (58 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Golda Nolan II

Birthday: 1998-05-14

Address: Suite 369 9754 Roberts Pines, West Benitaburgh, NM 69180-7958

Phone: +522993866487

Job: Sales Executive

Hobby: Worldbuilding, Shopping, Quilting, Cooking, Homebrewing, Leather crafting, Pet

Introduction: My name is Golda Nolan II, I am a thoughtful, clever, cute, jolly, brave, powerful, splendid person who loves writing and wants to share my knowledge and understanding with you.