Bryan Schmiedeler
Bryan Schmiedeler

Reputation: 3137

App Insight Alerts - exclude certain http errors or change coding

I have an alert in Application Insights that monitors our app service. The alert looks for request failures greater than 1. It generates a lot of good information and we have eliminated many bugs this way.

Today I used Postman to try to authenticate and made 2 errors and the alert fired, with a 400 exception.

I am not sure how to handle this? This is not really a coding error. Should I exclude 400 errors (is this even possible)? Should the programming handle the http 400 error?

Upvotes: 0

Views: 1643

Answers (1)

Ivan Glasenberg
Ivan Glasenberg

Reputation: 30035

Update 0306:

If you only want to alert on the 2 requests were from a separate API, you can add the where clause with some specified properties, like the name, url etc.(any property can identify the 2 requests.)

For example(if you don't know which property can identify the 2 requests), nav to azure portal -> your application insights -> in the left menu, click Logs -> then double click the requests table, and select a proper Time range, then click the Run button -> in the query results, please check the properties of the 2 requests so you can make sure which property(or properties) can identify the request, screenshot as below:

enter image description here

if the name property can identify the request, just add the where clause like

where name == "xxx"

if the name and url property combination can identify the request, add below code:

| where name == "xxx" 
| where url == "xxx"

Original answer:

There're 2 ways for this.

1.Change the query of alert, add the following where clause in the alert query:

where resultCode != "400" 

2.If it's .NET core / .NET framework project, you can use ITelemetryProcessor to filter out the requests whose response code is 400:

Follow this example Filter out requests with a "401" response, and the follow step 2 in this section to register the ITelemetryProcessor.

Upvotes: 1

Related Questions