Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I reduce the amount of trace logs that Application Insights sends to the server

I'm working with a production system that has a moderate amount of load. The amount of trace events and AI sends up is way too detailed, and makes it difficult to wade through logs later.

Each request to the server has information such as:

Message='Selected formatter='JsonMediaTypeFormatter', content-type='application/json; charset=utf-8'', Operation=DefaultContentNegotiator.Negotiate

and

Message='Action returned 'RZ.API.Support.Controllers.OperationActionResult`1[System.Collections.Generic.List`1[RZ.Entity.System.ClientMessage]]'', Operation=ReflectedHttpActionDescriptor.ExecuteAsync

There are maybe 30 entries for each request!

I just need the request type:

12/16/2015, 9:17:29 AM - REQUEST

GET /api/v1/user/messages

And the result code - as well as any custom stuff I do along the way.

So basically I want to trim most the traces except the request and the result (and any errors etc).

I have my eye on this bad boy in the AI config:

<Add Type="Microsoft.ApplicationInsights.Web.RequestTrackingTelemetryModule, Microsoft.AI.Web"/>

... but I cannot for the life of me see any doco on how to ask it to reduce the amount of stuff that is sent!

Any help is much appreciated.

Jordan.

P.S. All the extra logging has put us over the 15m a month plan, we had to upgrade!

like image 370
Jordan Avatar asked Dec 15 '15 22:12

Jordan


2 Answers

RequestTrackingTelemetryModule does not do anything like you described. It adds requests, exceptions and dependencies collection. And in you example you are saying you see verbose WebApi traces being forwarded to ApplicationInsights. I assume you actually use Application Insights logging adapter.

Here you can read how WebApi traces can be forwarded to AI Version 1: http://apmtips.com/blog/2014/11/13/collect-asp-dot-net-mvc-web-api-traces-with-application-insights/

Here you can read how WebApi traces can be forwarded to AI Version 2: http://apmtips.com/blog/2016/01/05/webapi-tracing-powered-by-ai-in-vs2015-update1/

Source code of logging adapters: https://github.com/Microsoft/ApplicationInsights-dotnet-logging

Documentation: https://azure.microsoft.com/en-us/documentation/articles/app-insights-search-diagnostic-logs/#trace

So you have multiple options:

  • Do not use logging adapters
  • Change verbosity of WebApi tracing (read http://www.asp.net/web-api/overview/testing-and-debugging/tracing-in-aspnet-web-api). I would prefer this one since you probably want to collect failures.
  • Remove WebApi tracing (as you did)
like image 105
Anastasia Black Avatar answered Sep 28 '22 18:09

Anastasia Black


To answer my own question.

In my WebApiConfig file, I had:

config.EnableSystemDiagnosticsTracing();

Removing this line drastically cut down the clutter to what I was trying to achieve.

like image 43
Jordan Avatar answered Sep 28 '22 17:09

Jordan