When running enterprise APIs in production, waiting for your users to report an outage or performance lag is a recipe for disaster. To maintain high availability and deliver a seamless user experience, you need automated surveillance that detects anomalies the moment they occur and notifies your engineering team instantly.
By configuring Azure Monitor alert rules backed by your Application Insights telemetry, you can establish automated thresholds for HTTP failure rates and high response times, ensuring proactive incident response before critical thresholds are breached.
In this comprehensive guide, we will walk through setting up metric alert rules, configuring threshold conditions, and attaching action groups for instant notifications.
Why Proactive Alerting Matters
Infrastructure monitoring alone only tells you if a server is running—it doesn't tell you if your API clients are receiving 500 Internal Server Errors or experiencing sluggish database queries. Setting up targeted alert rules ensures:
Immediate Awareness: Engineers are paged or emailed the moment error rates spike.
SLA Compliance: Performance degradation (such as P95 response times exceeding threshold limits) is caught early.
Reduced MTTR (Mean Time to Resolution): Proactive notifications shorten the window between failure and remediation.
Step 1: Navigating to Application Insights Alerts
Before creating rules, ensure your telemetry is flowing smoothly into Azure.
Open the Azure Portal.
Locate and open your Application Insights resource.
In the left-hand navigation menu under the Monitoring section, click on Alerts.
Click Create and select Alert rule.
Step 2: Configuring the API Failure Rate Condition
The first rule you should establish tracks incoming HTTP failures (such as 4xx and 5xx status codes or unhandled exceptions captured by your Global Exception Handler).
Under the Condition tab, click Select condition.
Search for and select the Failed requests signal.
Configure your threshold logic:
Aggregation type: Total count or Percentage.
Operator: Greater than.
Threshold Value: (e.g.,
5failed requests or5%error rate).Evaluation period: Over the last 5 minutes (evaluated every 1 minute).
Click Done.
Step 3: Setting Up High Response Time Thresholds
Performance degradation is often an early indicator of database lockups, network bottlenecks, or resource exhaustion.
Add a second condition (or create a separate rule) by selecting the Server response time signal.
Configure your latency criteria:
Aggregation type: Percentile (e.g., 95th percentile / P95 is recommended over average, as averages mask intermittent spikes).
Operator: Greater than.
Threshold Value: (e.g.,
500milliseconds).
Click Done.
Step 4: Attaching an Action Group for Notifications
An alert rule is only as good as its notification mechanism. Action groups define who gets notified and how when an alert fires.
Proceed to the Actions tab in the alert creation wizard.
Click Create action group.
Provide an Action group name and short name (e.g.,
DevOps-OnCall).Under the Notifications tab, select your preferred notification type:
Email/SMS/Push/Voice: Add developer email addresses or phone numbers.
Webhook / Logic App: Integrate with tools like PagerDuty, Slack, or Microsoft Teams webhooks for automated incident management.
Review and create the action group.
Step 5: Finalizing and Naming Your Alert Rule
Navigate to the Details tab.
Enter a descriptive Alert rule name (e.g.,
API-High-Failure-Rate-And-Latency).Select your target Resource group and set the appropriate Severity level (e.g., Severity 2 for critical production outages).
Click Create alert rule.
Summary
By combining Azure Monitor alert rules with your ASP.NET Core API's Application Insights telemetry, you transform your monitoring stack from a passive dashboard into an active guardian. You gain the confidence to ship updates quickly, knowing that any unexpected failure or performance regression will trigger an immediate response.

Join the conversation! Your thoughts help the community grow.