Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling dependency logging for Application insights on Azure app service (Web app)

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://learn.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

like image 375
Ashkan S Avatar asked Apr 29 '19 18:04

Ashkan S


People also ask

What are dependencies in Azure application insights?

Dependency Tracking in Azure Application Insights. A dependency is an external component that is called by your app. It's typically a service called using HTTP, or a database, or a file system.

How do I enable application logging in Azure App service?

Once you have this configured, deploy your app to Azure App Service and you should be able to configure the log viewer to work. First, scroll down and click on 'App Service logs' and you should see something like this: Next, on the right, toggle Application Logging (Filesystem) to enable it.

How do I view my Azure App service live log stream?

Now click on Log stream on the left to attach to your application's logs. Navigate to your site and you should see log messages corresponding to the requests you're making to the application. View your Azure App Service live log stream. And that's it.

How to configure application insights service?

You can select your existing application insights instance if you want to use that. 1.4 Click on Review + Create and wait till your app service is deployed. 2.1 Go to your web app and click on configuration on left blade. You should see below 3 application settings automatically populated:


2 Answers

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.

like image 72
Marc Avatar answered Oct 07 '22 05:10

Marc


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

like image 29
Martin Brandl Avatar answered Oct 07 '22 06:10

Martin Brandl