Azure Monitor serves as the central platform for collecting and analyzing data from cloud and on-premises resources. It focuses on three main pillars of observability: metrics, logs, and distributed traces. Collecting this data is essential for understanding the health and performance of applications, and it helps teams find and fix issues before they affect end users.
Platform metrics are numerical values that show how a system is performing at a specific time. Azure collects these automatically, and they can be used for near real-time alerting. Activity logs provide a record of subscription-level events, such as when a resource is created or modified. Users can view these logs in the Azure portal or route them to a Log Analytics workspace for deeper analysis.
Resource logs provide detailed information about the internal operations of an Azure service. Unlike platform metrics, these logs are not saved until you create a diagnostic setting. This setting allows you to route telemetry data to specific destinations. Common destinations include Log Analytics workspaces for running complex queries, Azure Storage Accounts for long-term data archiving, and Event Hubs for streaming data to external tools.
To gather data from inside a virtual machine, you must use the Azure Monitor Agent. This agent uses Data Collection Rules (DCRs) to define exactly which events and performance counters should be gathered. DCRs offer great flexibility because they allow you to send different data from different groups of machines to various locations.
Azure Monitor collects data to help you understand how your applications are performing. It focuses on the three pillars of observability, which are metrics, logs, and distributed traces. By gathering this information, developers can ensure their cloud solutions remain reliable and efficient.
Metrics are numerical values that describe a system's performance at a specific point in time. These are collected at regular intervals and stored in a time-series database, making them perfect for detecting real-time issues and bottlenecks. You can use these values to see how your system is performing and compare data over different time periods. Metrics include timestamps, aggregations that provide mathematical summaries of data over time, and alerting capabilities that trigger automatic notifications based on specific conditions.
Distributed tracing is a technique used to visualize the path of a request as it moves through different services. This is especially important for complex cloud architectures where a single user action might trigger many small background tasks. By using the Application Insights SDK, you can track latency and see exactly where a delay is happening within your microservices. This helps you understand the dependencies between different parts of your application.
While metrics show you that a problem exists, logs help you find the root cause of the issue.
Implement and Utilize Application Insights
Application Insights is Azure Monitor's application performance monitoring (APM) service designed to help you monitor and troubleshoot Azure solutions. It collects telemetry data such as metrics, logs, and traces from your applications. You can enable monitoring with minimal changes by using autoinstrumentation or add deeper insights through manual instrumentation and the OpenTelemetry SDK. Autoinstrumentation lets you turn on monitoring in the Azure portal without code modifications, while manual SDK configuration provides full control over what data is collected. If both autoinstrumentation and manual SDK are detected, only manual settings run to prevent duplicate data.
When you instrument your application, Application Insights automatically captures key telemetry items: requests and dependencies show how your app communicates with clients and services; exceptions and traces provide detailed error and debug information; and custom events and metrics offer business-specific insights.
Application Insights supports three metric types, each suited for different scenarios. Standard metrics are preaggregated and offer fast, real-time alerting. Log-based metrics are built from log queries and allow deep diagnostic analysis with all log properties, though sampling and filtering can affect their accuracy. Custom metrics are user-defined via SDK.
To explore telemetry data, use the built-in experiences in the Azure portal. The application map shows a visual overview of components and their interactions. Live Metrics provides near real-time monitoring of CPU, requests, and dependencies. Transaction Search and Logs (Analytics) let you query and filter collected data using Kusto Query Language (KQL).
You can create charts, alerts, and dashboards to track application health. Metrics Explorer and Workbooks provide interactive visualizations. Alerts with static or dynamic thresholds enable proactive notifications. Log queries can correlate events by grouping by operation_Id or InvocationId.
Analyze and Query Telemetry Data Using Kusto Query Language (KQL)
Kusto Query Language (KQL) is a powerful tool used to retrieve and analyze telemetry data stored in Azure Monitor Logs. It allows you to perform read-only requests to process data and return results quickly, even across millions of records. KQL enables you to explore logs, transform and aggregate data, discover patterns, and identify anomalies and outliers in your application's performance.
Log Analytics is the primary tool in the Azure portal for running KQL queries and analyzing their results. It offers two modes: Simple mode for users unfamiliar with KQL, providing an intuitive, spreadsheet-like experience to retrieve data from one or more tables with a single click. For those familiar with KQL, the KQL mode allows you to edit and create complex queries, which can then be used in Azure Monitor features like alerts and workbooks or shared with other users.
You can construct complex KQL queries to filter, aggregate, and join data from multiple tables in Log Analytics workspaces. These queries support advanced analytics through various functions and operators, helping you identify patterns and anomalies in application performance. For example, you can summarize data by specific fields, use time-based aggregations, or apply machine learning algorithms for anomaly detection. The ability to join data from different tables allows for comprehensive correlation of events across your entire system.
The results of your KQL queries can be visualized through various Azure Monitor features. You can pin query results as tables or charts to Azure dashboards for a centralized view. Workbooks allow you to combine multiple sets of data into interactive reports, while Power BI and Grafana enable you to create advanced visualizations and share them with stakeholders outside of Azure.
KQL queries are integral to several Azure Monitor capabilities, including configuring log search alert rules to notify you of specific conditions, using summary rules to aggregate data for custom reports, and detecting anomalies through built-in or custom algorithms.
Analyze Log Data through Kusto Query Language (KQL)
Kusto Query Language (KQL) is used within Azure Monitor Logs to interactively search, analyze, and visualize log data collected in Log Analytics workspaces. It enables you to execute complex queries to extract actionable insights from logs and traces, which is essential for identifying patterns and correlating events across multiple resources to resolve application failures.
Azure Monitor consolidates operational data from various sources, including applications and Azure resources, into a centralized Log Analytics workspace. This data consists of logs, which are timestamped events that can be structured or free-form text. KQL queries are run against this log data to perform deep analysis. You can collect data by configuring diagnostic settings on your resources to route logs to the workspace, ensuring all relevant telemetry is available for querying.
Using KQL, you can write queries to filter, summarize, and join data from multiple tables. For example, you can identify error trends by querying specific event types or calculate performance metrics over time. The Log Analytics interface in the Azure portal provides a user-friendly environment to run these queries, view results as tables or charts, and pin visualizations to dashboards for ongoing monitoring.
KQL supports advanced features like machine learning-based anomaly detection, which can automatically identify unusual patterns in log data. Additionally, you can integrate query results with other Azure Monitor features such as alerts and workbooks. For instance, you can create alert rules that trigger automated actions when query results meet certain conditions, enabling real-time response to critical events.