Azure Alert - Microsoft.AspNetCore.Hosting|Failed Requests (Azure.ApplicationInsights)

Maarten Clauwaert 31 Reputation points
2021-10-29T06:35:47.513+00:00

I'm having trouble understanding how the standard metric "Microsoft.AspNetCore.Hosting|Failed Requests (Azure.ApplicationInsights)" works in Azure. I'm hoping someone can shed some light on it as it seems no documentation on it exists either.

The alert is configured as shown in below picture. It's being triggered multiple times a day, while no failures are appearing in the relevant Application Insights instance.

GsTo4.png

I was expecting the chart from the above alert would match following kusto query:

let start=ago(6hr);
let end=now();
let timeGrain=5m;
let dataset=requests
| where timestamp > start and timestamp < end
| where client_Type != "Browser"
;
dataset
| summarize failedCount=sumif(itemCount, success == false) by bin(timestamp, timeGrain)
| extend request='Overall'
| render timechart

ZTMZf.png

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
2,812 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,922 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Ryan Hill 25,981 Reputation points Microsoft Employee
    2021-11-10T15:35:41.18+00:00

    Hi @Maarten Clauwaert ,

    Apologies for the delayed response. It was an ah-ha moment when it was pointed out to me. Application Insights uses EventSource for dotnet. Microsoft.AspNetCore.Hosting|Failed Requests is being generated by RequestFailed() in HostingEventSource. This method is called by HostingApplicationDiagnostics.RequestEnd() when the request ends in a 500. Modifying dataset in your kusto query to the following should pull those 500s in.

    let dataset=AppRequest //requests is a legacy table https://learn.microsoft.com/en-us/azure/azure-monitor/app/apm-tables
    | where timestamp > start and timestamp < end
    | where resultCode > "500"

    0 comments No comments