Jordan
Jordan

Reputation: 588

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!

Upvotes: 5

Views: 5346

Answers (4)

Anastasia Black
Anastasia Black

Reputation: 1900

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:

Upvotes: 3

John Gardner
John Gardner

Reputation: 25168

As of version 2.0 of the Application Insights SDKs, you can also limit the data sent by enabling sampling:

https://azure.microsoft.com/en-us/documentation/articles/app-insights-sampling/

if you add

 <MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>

to your ApplicationInsights.config, the sdk can limit how much goes out. The article above has a LOT more settings/configuration you can use to get other specific behavior, but the one above is the simplest.

Upvotes: 1

Jordan
Jordan

Reputation: 588

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.

Upvotes: 2

CaringDev
CaringDev

Reputation: 8551

As far as I know there are no configuration options available for the RequestTrackingTelemetryModule. You could just turn it off (by uninstalling the respective NuGet package or commenting the xml) and / or install different / additional telemetry modules.

See app-insights-configuration-with-applicationinsights-config for a list of modules and configuration options.

Upvotes: 0

Related Questions