evilpilaf
evilpilaf

Reputation: 2030

Ignore specific http status codes from errors

I have a web application monitored with Application Insights but in the errors view I see non 500 http status responses being registered as errors. Is there a way to tell insights to only register 500 status codes or ignore 400 status codes from the captured events?

Upvotes: 3

Views: 2075

Answers (1)

Alex Bulankou
Alex Bulankou

Reputation: 2456

Yes, there is a way. What you can do is register a custom Telemetry Initializer and do something like this:

 public void Initialize(Microsoft.ApplicationInsights.Channel.ITelemetry telemetry)
 {
            if (telemetry is RequestTelemetry && ((RequestTelemetry)telemetry).ResponseCode == "400")
            {
               ((RequestTelemetry)telemetry).Success = true;
            }
 }

Upvotes: 5

Related Questions