Correlate and Evaluate Resource Metrics
Monitoring
To inspect infrastructure performance, you start by collecting data on CPU, memory, disk, and network usage. Azure Monitor gathers these metrics from all your Azure resources, such as virtual machines, databases, and app services. By watching CPU load, you can spot when a server is working too hard. Memory metrics help you find leaks or insufficient RAM. Disk I/O (input/output) speeds and operation counts reveal storage bottlenecks, and network traffic rates show potential congestion or connectivity problems. Azure Monitor stores this data as time-series metrics and logs, giving you a historical view of how each resource behaves.
Raw metrics alone are not enough; you need to correlate them with what your application code is doing. Application Insights Profiler captures detailed performance traces from your running application and links them to the infrastructure metrics. For example, it can show that a spike in CPU usage corresponds to a specific method call in your code. The Code Optimizations feature then analyzes those traces and suggests fixes, such as rewriting a slow database query or caching repeated data. This relationship between infrastructure metrics and application code is what turns raw numbers into actionable insights.
Alerting
Once you understand normal utilization patterns, you set up threshold-based alerts in Azure Monitor. For instance, you can create an alert that fires when CPU usage stays above 90% for five minutes, or when disk queue length exceeds a critical value. When an alert triggers, it can automatically scale out resources, send a notification to an operations team, or run a remediation script. This proactive approach prevents performance issues from reaching end users and keeps your application responsive.
Optimizations
The insights from monitoring, analysis, and alerting drive optimization decisions. If memory usage is consistently high, you might increase the size of your virtual machines or add more instances behind a load balancer. If disk I/O is a bottleneck, you could switch to a faster storage tier or move frequently accessed data to a cache. Code-level improvements, such as reducing unnecessary loops or optimizing database queries, also reduce CPU and memory pressure. By continuously correlating the four key metrics—CPU, memory, disk, and network—you can make data-driven choices that improve reliability, reduce latency, and lower costs.
What Application Insights Collects
Understanding how your application behaves in production requires collecting and analyzing telemetry data. Application Insights gathers two main types of data: telemetry from your server-side code and telemetry from client-side web pages. On the server, it captures HTTP requests that come into your application, information about external services your code calls (like databases or storage), error logs called exceptions, and performance measurements like CPU and memory usage. It also allows developers to create custom events and metrics that track business-specific information, plus detailed trace logs that record what the code is doing step by step. From the client side, Application Insights captures uncaught exceptions that occur in the user's browser, network requests the webpage makes, and information about the users themselves including their devices and browsing sessions. This combined view lets you see the full picture of how your application performs from the user's perspective.
Using Live Metrics and Application Map
Once you enable Application Insights, two tools help you monitor your application in real time. Live metrics show what's happening right now, updating continuously so you can diagnose problems as they occur. The Application Map provides a visual representation of your application's structure, showing all the components and services that make up your system. This map highlights where bottlenecks or failures are happening, making it easier to identify which part of your application needs attention. By studying this data, you can spot problems before they affect users and make informed decisions about improvements.
To keep your application running smoothly, you need to track several key performance indicators. Request rates tell you how many users are accessing your application at any given time, while response times show how quickly the application answers those requests. Failure rates reveal how often requests result in errors. By comparing these metrics, you can identify when usage peaks coincide with performance problems, helping you understand whether increased traffic is causing slowdowns or failures. You should also monitor dependency performance, which measures how long external services take to respond. If a database or API call is slow, it can drag down your entire application's performance. Finally, examining exceptions and logs helps you understand what specific errors are occurring and why, giving you the details needed to fix bugs and improve reliability.
Working with Trace Logs
Trace logs provide a breadcrumb trail of your application's activities, which is invaluable when investigating problems. To get the most from traces, integrate Application Insights with your logging framework (such as ILogger in .NET) so that trace messages flow automatically into your telemetry data. When analyzing traces, look at them alongside exception data to gain context about what was happening when an error occurred. Each log entry should include contextual identifiers like operation IDs, which link related log entries together and make it easier to follow the sequence of events leading to a problem. The goal is to maintain service-level objectives, which are promises about how fast and reliable your application should be.
Setting Up Availability Tests
To ensure your application remains accessible to users, configure availability tests that periodically check whether your endpoints are responding correctly. These tests run automatically from different geographic locations and alert you when an endpoint becomes unavailable or responds too slowly. By monitoring critical endpoints this way, you can detect and fix outages before most users even notice them.
Correlate End-to-End Requests
Configuring Application Insights SDK
Distributed tracing in Application Insights works by attaching an operation identifier to every request and passing that identifier from one service to the next. To enable this, you must configure the Application Insights SDK in each microservice of your application. For .NET services, you integrate the SDK with the logging framework, such as ILogger. For services written in other languages, you use the appropriate Azure Monitor exporter or the OpenTelemetry SDK to send trace telemetry. Once configured, the SDK automatically propagates the operation identifier so that all parts of a single request are linked together, even when the request crosses multiple services. This automatic propagation is what makes distributed tracing possible across a complex system.