Application Insights availability tests (also called web tests or ping tests) are proactive checks that monitor the accessibility and responsiveness of your web application. They work by simulating requests to your app's endpoints at regular intervals from different geographic locations. These tests help you detect downtime or slow responses before your users are affected. When a test fails, Application Insights can trigger alerts so you can investigate immediately.
To set up availability tests in the Azure portal, go to your Application Insights resource's Availability pane and choose a test type. You can select Simple URL ping test to send a basic HTTP request or Standard availability tests for more control over HTTP methods, success criteria, and content checks. For each test, specify the frequency (for example, every 5 minutes) and the test locations around the world. After saving, ensure you enable alerts so failures raise Azure Monitor alert rules.
By default, availability tests include state-based alerts that send one notification when an endpoint goes down and another when it recovers. This behavior prevents alert fatigue by avoiding repeated emails for the same outage. You can customize the alert criteria by editing the rule's evaluation frequency (up to 15 minutes) and adjusting the number of regions that must fail before an alert fires. These settings help you ignore brief or localized disruptions you expect during maintenance.
For advanced scenarios, create custom alert rules on the Alerts tab to gain finer control over availability monitoring. You can choose Metrics as the signal type to alert on X out of Y locations reporting failures, aggregated availability metrics, or custom log queries for any condition you define. Link your rules to action groups so your team receives notifications through email, SMS, or other channels, and automate your incident response for reliable performance protection.
After setting up availability tests, you can view results in the Azure portal using both line graphs and scatter plots. The scatter plot view shows individual test executions, with failures highlighted for easy identification. Drilling into a failed test provides detailed diagnostics, including response details and correlated server-side telemetry, which helps in quickly pinpointing the root cause of issues. For deeper analysis, you can use Log Analytics to query availability results and create custom reports.
Design and Implement Availability Tests
Availability tests in Application Insights are a critical tool for monitoring the health and responsiveness of your web applications. These tests proactively ping your application's endpoints from various locations around the world on a set schedule. They help detect downtime or significant slowdowns early by sending web requests and verifying successful responses. By creating these tests, you ensure that if your app becomes unreachable, an alert is triggered, prompting an investigation into the issue.
Types of Availability Tests
There are several types of availability tests you can configure. The Standard test sends a single HTTP request to a specified URL and checks for a successful response within a timeout period. It includes additional features like validating TLS/SSL certificates, specifying HTTP methods (such as GET, HEAD, or POST), and adding custom headers. If you need more complex testing logic, you can write custom code to run availability checks and use the TrackAvailability() method to send the results to Application Insights. The Multi-step web test allowed playback of a sequence of web requests to simulate user interactions but is being retired and should be replaced with standard tests.
Creating and Configuring Tests
To create an availability test, navigate to the Availability pane in your Application Insights resource in the Azure portal. You can specify the test type, frequency (e.g., every 5 minutes), timeout settings, and multiple geographic locations from which the test will run. Enabling alerts for test failures is crucial, as it ensures that an Azure Monitor alert is generated when an endpoint is down, allowing for quick response to issues.
Best Practices and Security
When setting up availability tests, choose a test frequency that balances timely detection with resource usage. A common practice is testing every 5 minutes with a 120-second timeout. Select test locations that reflect your user base to ensure comprehensive monitoring across different regions. If your application is behind a firewall, you may need to allow traffic from the availability test service IPs or use service tags like ApplicationInsightsAvailability in your network security groups. Additionally, you can add custom headers (e.g., X-Customer-InstanceId) to validate that incoming requests are from your tests.
Alerting and Monitoring
Availability tests integrate seamlessly with Azure Monitor alerts. By default, alerts are state-based, meaning they trigger when an endpoint first becomes unavailable and again when it recovers, avoiding continuous notifications during prolonged outages. You can customize alert criteria, such as the number of locations that must fail before triggering an alert, to reduce noise. For advanced scenarios, you can create custom alert rules based on availability metrics or log queries to get more granular control over alerting logic.
Alert rules in Azure Monitor are the core mechanism for proactively notifying you when specific conditions are met in your application's performance or health. These rules are based on analyzing metrics (like CPU usage or failed requests) or logs from your Application Insights resource. When a rule's defined condition is met, it triggers an action, such as sending an email or starting an automated process.
Enabling and Configuring Alerts
To set up an alert, you first navigate to your Application Insights resource in the Azure portal. Under the Availability section, you can create a test, such as a URL ping test. After saving the test, you can enable alerts by selecting it and choosing Open Rules (Alerts) page. Here, you can edit the alert rule to set its severity level, a descriptive rule description, and link it to an action group. An action group defines who gets notified and how, such as via email, SMS, or a webhook.
Understanding Alert Criteria
It is crucial to understand that availability alerts are state-based. An alert is generated only when the website first becomes unavailable, and you will not receive continuous repeated alerts for the same ongoing issue. You can fine-tune the alert's sensitivity by adjusting the evaluation frequency (how often the rule checks) and the location threshold (how many test locations must report a failure). For instance, you might configure a rule to only trigger if failures occur in at least 3 out of 5 test locations.
Creating Custom Alert Rules
For more advanced control, you can create custom alert rules from the Alerts tab. This approach offers greater flexibility, allowing you to use a wider range of signals, including availability metrics and custom analytics queries. You can define more complex logic using different operators and aggregation types, and set longer aggregation periods up to 24 hours. Custom rules provide the ability to alert on specific test durations or use the Kusto Query Language (KQL) to find unique patterns.
Configuring Notifications with Action Groups
The action group is the component that specifies the notification method. You can create an action group to send alerts via email, SMS, push notifications, or voice calls. More advanced actions can trigger an Azure Function, an Azure Logic App, or a webhook for automated remediation tasks. You link these action groups to your alert rules to ensure the right people or systems are informed when an issue is detected, allowing your system to heal itself without manual intervention.
Evaluate Advanced Availability Test Configurations and Validation Criteria
Standard tests are the modern way to monitor if your application is running correctly from different places around the world. These tests replace the older URL ping tests and offer more advanced features like checking SSL certificate validity and using different HTTP verbs like POST or GET. By setting up these tests, you can ensure your website is responsive and that its security certificates are not about to expire. Regularly monitoring these criteria helps prevent unexpected downtime for your users.
When setting up a test, you must define specific validation criteria to determine if a request is successful. This includes checking for a 200 OK status code to ensure the server is healthy, searching for specific text on the page to confirm the content loaded correctly, and verifying that SSL certificates are valid for a certain number of days. To test applications behind a firewall, you should use custom headers like X-Customer-InstanceId to prove the request is coming from a trusted source, which prevents unauthorized traffic from mimicking your availability tests.
Choosing the right testing locations is vital for getting accurate data about your application's global performance. Azure allows you to select from many multi-regional locations, and it is best practice to choose at least five different spots. This variety helps you distinguish between a local internet problem and an actual failure of your application. Strategic location selection ensures that your monitoring system provides a reliable signal of your app's health.
Alerts notify your team immediately when a test fails based on the criteria you have set. You should configure an alert location threshold, which is the number of regions that must report a failure before an alert is sent. A common recommendation is to set this threshold to three out of five locations to reduce noisy or false alerts. Automating these alerts through templates ensures consistent monitoring across all your Azure resources.
To allow availability tests to reach your server, you may need to update your Network Security Groups. You can use Service Tags, specifically the ApplicationInsightsAvailability tag, to easily permit traffic from Azure's testing agents without managing long lists of IP addresses. If your app is not on the public internet, you can use Azure Private Link to connect your tests securely. Proper network configuration is essential for maintaining security while still allowing for comprehensive monitoring.
Alert Rules in Azure Monitor are used to proactively notify you when issues occur within Application Insights web tests. These rules are often state-based, meaning they trigger once when a problem starts and once when it is resolved. Setting a proper evaluation frequency ensures you are notified quickly without being overwhelmed by repeat messages.
Alert Criteria
You can customize Alert Criteria to match your specific needs by adjusting the location threshold. This allows you to trigger an alert only if your website is down in a specific number of regions. Key settings to configure include the Test Frequency (how often the availability test runs), the Aggregation Period (the timeframe used to calculate the metric), and the Location Threshold (the number of geographic areas that must report a failure). Adjusting these values helps prevent false alarms during brief maintenance windows or minor network blips.
Custom Alert Rules
For more complex scenarios, you can create Custom Alert Rules using Metrics or Log Queries. These rules offer advanced logic, such as alerting on specific test durations or using the Kusto Query Language (KQL) to find unique patterns. Custom rules provide more flexibility than standard availability alerts by allowing longer aggregation periods and specialized operators.
Action Groups
Action Groups are collections of notification preferences that define what happens when an alert triggers. They can send simple notifications like emails or trigger automated responses to fix issues immediately. Common automation tools include Webhooks (sends data to other services), Azure Functions (runs custom code to remediate problems), and Logic Apps (executes complex workflows for incident management). Using these tools for incident remediation allows your system to heal itself without manual intervention.
Smart Detection
Smart Detection uses machine learning to automatically find unusual patterns in your application's failure rates. This feature requires no manual setup and alerts you in near real-time if there is an abnormal rise in failed requests. Integrating these alerts into your release pipeline helps ensure that new deployments do not negatively impact your users.