7
votes

My application writes a lot of logs ib Dependencies which caused it to be super expensive (even more expensive than my server farms + database) and we have not used it for anything for months. How can I disable the dependencies but keep the rest (requests ,exceptions, custom events, etc.)?

In the documentation, adding application insights is not separated from adding dependencies.

https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net-dependencies

At the same time,

in application insights resource >Usage and estimated costs

The only options avalable are

  • Daily cap

-Data Sampling

But The custom events (and requests) have a great value for the business and I don't want them not to be logged because of a cap, or being sampled. enter image description here

2

2 Answers

4
votes

If you don't need it, just remove the DependencyTrackingTelemetryModule from your ApplicationInsights.config file.

Look for this entry:

<Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector">
    .....
</Add>

And remove it or comment out:

<!--<Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector">
    .....
</Add>-->

Another way is to set the sampling to 100% for Dependencies only. See the documentation for more information about that. But I think it is always better not to have something loaded or running what you don't need.

2
votes

I think you can achieve that by creating a telemetry processor and disable the telemetry data within the Process method.

Example:

public void Process(ITelemetry item)
{
    var request = item as DependencyTelemetry;

    // Don't process dependency telemetry
    if (request != null)
    {
        return;
    }

    this.Next.Process(item);
}

See also: Filtering and preprocessing telemetry in the Application Insights SDK