Troubleshooting no data - Application Insights for .NET/.NET Core

Note

On March 31, 2025, support for instrumentation key ingestion will end. Instrumentation key ingestion will continue to work, but we'll no longer provide updates or support for the feature. Transition to connection strings to take advantage of new capabilities.

Some of my telemetry is missing

In Application Insights, I only see a fraction of the events that are being generated by my app.

  • If you're consistently seeing the same fraction, it's probably because of adaptive sampling. To confirm this, open Search (from the Overview in the portal on the left) and look at an instance of a Request or other event. To see the full property details, select the ellipsis (...) at the bottom of the Properties section. If Request Count > 1, sampling is in operation.
  • It's possible that you're hitting a data rate limit for your pricing plan. These limits are applied per minute.

I'm randomly experiencing data loss.

I'm experiencing data loss in Console App or on Web App when app is about to stop.

  • SDK channel keeps telemetry in buffer, and sends them in batches. If the application is shutting down, you might need to explicitly call Flush(). Behavior of Flush() depends on the actual channel used.

  • Per .NET Core/.NET Framework Console application, explicitly calling Flush() followed by sleep is required in Console Apps.

Request count collected by Application Insights SDK doesn't match the IIS log count for my application

Internet Information Services (IIS) logs counts of all request reaching IIS and inherently could differ from the total request reaching an application. Due to this behavior, it isn't guaranteed that the request count collected by the SDKs will match the total IIS log count.

No data from my server

I installed Azure Monitor Application Insights Agent on my web server to monitor existing apps. I don't see any results.

Check TLS/SSL client settings (ASP.NET)

If you have an ASP.NET application hosted in Azure App Service or in IIS on a virtual machine, your application could fail to connect to the Snapshot Debugger service due to a missing SSL security protocol.

The Snapshot Debugger endpoint requires TLS version 1.2. The set of SSL security protocols is one of the quirks enabled by the httpRuntime targetFramework value in the system.web section of web.config. If the httpRuntime targetFramework is 4.5.2 or lower, then TLS 1.2 isn't included by default.

Note

The httpRuntime targetFramework value is independent of the target framework used when building your application.

To check the setting, open your web.config file and find the system.web section. Ensure that the targetFramework for httpRuntime is set to 4.6 or above.

<system.web>
   ...
   <httpRuntime targetFramework="4.7.2" />
   ...
</system.web>

Note

Modifying the httpRuntime targetFramework value changes the runtime quirks applied to your application and can cause other, subtle behavior changes. Be sure to test your application thoroughly after making this change. For a full list of compatibility changes, see Retargeting changes.

Note

If the targetFramework is 4.7 or above then Windows determines the available protocols. In Azure App Service, TLS 1.2 is available. However, if you are using your own virtual machine, you may need to enable TLS 1.2 in the OS.

FileNotFoundException: "Could not load file or assembly Microsoft.AspNet TelemetryCorrelation"

For more information on this error, see [GitHub issue 1610 ] (https://github.com/microsoft/ApplicationInsights-dotnet/issues/1610).

When upgrading from SDKs older than (2.4), you need to make sure the following changes applied to web.config and ApplicationInsights.config:

  1. Two http modules instead of one. In web.config, you should have two http modules. Order is important for some scenarios:

    <system.webServer>
      <modules>
          <add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" preCondition="integratedMode,managedHandler" />
          <add name="ApplicationInsightsHttpModule" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
      </modules>
    </system.webServer>
    
  2. In ApplicationInsights.config in addition to RequestTrackingTelemetryModule you should have the following telemetry module:

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

Failure to upgrade properly may lead to unexpected exceptions or telemetry not being collected.

No 'Add Application Insights' option in Visual Studio

When I right-click an existing project in Solution Explorer, I don't see any Application Insights options.

  • Not all types of .NET project are supported by the tools. Web and WCF projects are supported. For other project types such as desktop or service applications, you can still add an Application Insights SDK to your project manually.
  • Make sure you have Visual Studio 2013 Update 3 or later. It comes pre-installed with Developer Analytics tools, which provide the Application Insights SDK.
  • Select Tools, Extensions and Updates and check that Developer Analytics Tools is installed and enabled. If so, select Updates to see if there's an update available.
  • Open the New Project dialog and choose ASP.NET Web application. If you see the Application Insights option there, then the tools are installed. If not, try uninstalling and then reinstalling the Developer Analytics Tools.

Adding Application Insights failed

When I try to add Application Insights to an existing project, I see an error message.

Likely causes:

Fix:

  • Check that you provided sign-in credentials for the right Azure account.
  • In your browser, check that you have access to the Azure portal. Open Settings and see if there's any restriction.
  • Add Application Insights to your existing project: In Solution Explorer, right select your project and choose "Add Application Insights."

"NuGet package(s) are missing" on my build server

Everything builds OK when I'm debugging on my development machine, but I get a NuGet error on the build server.

See NuGet Package Restore and Automatic Package Restore.

Missing menu command to open Application Insights from Visual Studio

When I right-click my project Solution Explorer, I don't see any Application Insights commands, or I don't see an Open Application Insights command.

Likely causes:

  • You created the Application Insights resource manually.
  • The project is of a type that isn't supported by the Application Insights tools.
  • The Developer Analytics tools are disabled in your Visual Studio.
  • Your Visual Studio is older than 2013 Update 3.

Fix:

  • Make sure your Visual Studio version is 2013 update 3 or later.
  • Select Tools, Extensions and Updates and check that Developer Analytics tools is installed and enabled. If so, select Updates to see if there's an update available.
  • Right-click your project in Solution Explorer. If you see the command Application Insights > Configure Application Insights, use it to connect your project to the resource in the Application Insights service.

Otherwise, your project type isn't directly supported by the Developer Analytics tools. To see your telemetry, sign in to the Azure portal, choose Application Insights on the left navigation bar, and select your application.

'Access denied' on opening Application Insights from Visual Studio

The 'Open Application Insights' menu command takes me to the Azure portal, but I get an 'access denied' error.

The Microsoft sign-in that you last used on your default browser doesn't have access to the resource that was created when Application Insights was added to this app. There are two likely reasons:

More than one Microsoft account - maybe a work and a personal Microsoft account? The sign-in that you last used on your default browser was for a different account than the one that has access to add Application Insights to the project.

  • Fix: Select your name at top right of the browser window, and sign out. Then sign in with the account that has access. Then on the left navigation bar, select Application Insights and select your app.
  • Someone else added Application Insights to the project, and they forgot to give you access to the resource group in which it was created.
    • Fix: If they used an organizational account, they can add you to the team; or they can grant you individual access to the resource group.

'Asset not found' on opening Application Insights from Visual Studio

The 'Open Application Insights' menu command takes me to the Azure portal, but I get an 'asset not found' error.

Likely causes:

  • The Application Insights resource for your application has been deleted; or
  • The connection string was set or changed in ApplicationInsights.config by editing it directly, without updating the project file.

The connection string in ApplicationInsights.config controls where the telemetry is sent. A line in the project file controls which resource is opened when you use the command in Visual Studio.

Fix:

  • In Solution Explorer, right-click the project and choose Application Insights, Configure Application Insights. In the dialog, you can either choose to send telemetry to an existing resource, or create a new one. Or:
  • Open the resource directly. Sign in to the Azure portal, select Application Insights on the left navigation bar, and then select your app.

Where do I find my telemetry?

I signed in to the Azure portal, and I'm looking at the Azure home dashboard. So where do I find my Application Insights data?

  • On the left navigation bar, select Application Insights, then your app name. If you don't have any projects there, you need to add or configure Application Insights in your web project.
    There you'll see some summary charts. You can select through them to see more detail.
  • In Visual Studio, while you're debugging your app, select the Application Insights button.

No server data (or no data at all)

I ran my app and then opened the Application Insights service in Azure, but all the charts show 'Learn how to collect...' or 'Not configured.' Or, only Page View and user data, but no server data.

  • Run your application in debug mode in Visual Studio (F5). Use the application so as to generate some telemetry. Check that you can see events logged in the Visual Studio output window.
    Screenshot that shows running your application in debug mode in Visual Studio.
  • In the Application Insights portal, open Diagnostic Search. Data usually appears here first.
  • Select the Refresh button. The blade refreshes itself periodically, but you can also do it manually. The refresh interval is longer for larger time ranges.
  • Verify the connection strings match. On the main blade for your app in the Application Insights portal, in the Essentials drop-down, look at Connection string. Then, in your project in Visual Studio, open ApplicationInsights.config and find the <ConnectionString>. Check that the two strings are equal. If not:
    • In the portal, select Application Insights and look for the app resource with the right string; or
    • In Visual Studio Solution Explorer, right-click the project and choose Application Insights, Configure. Reset the app to send telemetry to the right resource.
    • If you can't find the matching strings, check that you're using the same sign-in credentials in Visual Studio as in to the portal.
  • In the Azure home dashboard, look at the Service Health map. If there are some alert indications, wait until they've returned to OK and then close and reopen your Application Insights application blade.
  • Check also our status blog.
  • Did you write any code for the server-side SDK that might change the connection string in TelemetryClient instances or in TelemetryContext? Or did you write a filter or sampling configuration that might be filtering out too much?
  • If you edited ApplicationInsights.config, carefully check the configuration of TelemetryInitializers and TelemetryProcessors. An incorrectly named type or parameter can cause the SDK to send no data.

No data on Page Views, Browsers, Usage

I see data in Server Response Time and Server Requests charts, but no data in Page View Load time, or in the Browser or Usage blades.

The data comes from scripts in the web pages.

  • If you added Application Insights to an existing web project, you have to add the scripts by hand.
  • Make sure Internet Explorer isn't displaying your site in Compatibility mode.
  • Use the browser's debug feature (F12 on some browsers, then choose Network) to verify that data is being sent to dc.services.visualstudio.com.

No dependency or exception data

See dependency telemetry and exception telemetry.

No performance data

Performance data (CPU, IO rate, and so on) is available for Java web services, Windows desktop apps, IIS web apps and services if you install Application Insights Agent, and Azure Cloud Services. you'll find it under Settings, Servers.

No (server) data since I published the app to my server

  • Check that you copied all the Microsoft. ApplicationInsights DLLs to the server, together with Microsoft.Diagnostics.Instrumentation.Extensions.Intercept.dll
  • In your firewall, you might have to open some TCP ports.
  • If you have to use a proxy to send out of your corporate network, set defaultProxy in Web.config
  • Windows Server 2008: Make sure you've installed the following updates: KB2468871, KB2533523, KB2600217.

I used to see data, but it has stopped

  • Have you hit your monthly quota of data points? Open the Settings/Quota and Pricing to find out. If so, you can upgrade your plan, or pay for more capacity. See the pricing scheme.

I don't see all the data I'm expecting

If your application sends considerable data and you're using the Application Insights SDK for ASP.NET version 2.0.0-beta3 or later, the adaptive sampling feature may operate and send only a percentage of your telemetry.

You can disable it, but doing so isn't recommended. Sampling is designed so that related telemetry is correctly transmitted, for diagnostic purposes.

Client IP address is 0.0.0.0

On February 5 2018, we announced that we removed logging of the Client IP address. This recommendation doesn't affect Geo Location.

Note

If you need the first 3 octets of the IP address, you can use a telemetry initializer to add a custom attribute. This does not affect data collected prior to February 5, 2018.

Wrong geographical data in user telemetry

The city, region, and country dimensions are derived from IP addresses and aren't always accurate. These IP addresses are processed for location first and then changed to 0.0.0.0 to be stored.

Exception "method not found" on running in Azure Cloud Services

Did you build for .NET LTS? Earlier versions aren't automatically supported in Azure Cloud Services roles. Install LTS on each role before running your app.

Troubleshooting Logs

Follow these instructions to capture troubleshooting logs for your framework.

.NET Framework

Note

Starting in version 2.14, the Microsoft.AspNet.ApplicationInsights.HostingStartup package is no longer necessary, SDK logs are now collected with the Microsoft.ApplicationInsights package. No additional package is required.

  1. Modify your applicationinsights.config file to include the following XML:

    <TelemetryModules>
      <Add Type="Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.FileDiagnosticsTelemetryModule, Microsoft.ApplicationInsights">
        <Severity>Verbose</Severity>
        <LogFileName>mylog.txt</LogFileName>
        <LogFilePath>C:\\SDKLOGS</LogFilePath>
      </Add>
    </TelemetryModules>
    

    Your application must have Write permissions to the configured location

  2. Restart process so that these new settings are picked up by SDK

  3. Revert these changes when you're finished.

.NET Core

  1. Install the Application Insights SDK NuGet package for ASP.NET Core package from NuGet. The version you install must match the current installed version of Microsoft.ApplicationInsights.

    The latest version of Microsoft.ApplicationInsights.AspNetCore is 2.14.0, and it refers to Microsoft.ApplicationInsights version 2.14.0. Hence the version of Microsoft.ApplicationInsights.AspNetCore to be installed should be 2.14.0.

  2. Modify ConfigureServices method in your Startup.cs class.:

    services.AddSingleton<ITelemetryModule, FileDiagnosticsTelemetryModule>();
    services.ConfigureTelemetryModule<FileDiagnosticsTelemetryModule>( (module, options) => {
        module.LogFilePath = "C:\\SDKLOGS";
        module.LogFileName = "mylog.txt";
        module.Severity = "Verbose";
    } );
    

    Your application must have Write permissions to the configured location

  3. Restart process so that these new settings are picked up by SDK

  4. Revert these changes when you're finished.

Collect logs with PerfView

PerfView is a free tool that helps isolate CPU, memory, and other issues.

The Application Insights SDK log EventSource self-troubleshooting logs that can be captured by PerfView.

To collect logs, download PerfView and run this command:

PerfView.exe collect -MaxCollectSec:300 -NoGui /onlyProviders=*Microsoft-ApplicationInsights-Core,*Microsoft-ApplicationInsights-Data,*Microsoft-ApplicationInsights-WindowsServer-TelemetryChannel,*Microsoft-ApplicationInsights-Extensibility-AppMapCorrelation-Dependency,*Microsoft-ApplicationInsights-Extensibility-AppMapCorrelation-Web,*Microsoft-ApplicationInsights-Extensibility-DependencyCollector,*Microsoft-ApplicationInsights-Extensibility-HostingStartup,*Microsoft-ApplicationInsights-Extensibility-PerformanceCollector,*Microsoft-ApplicationInsights-Extensibility-EventCounterCollector,*Microsoft-ApplicationInsights-Extensibility-PerformanceCollector-QuickPulse,*Microsoft-ApplicationInsights-Extensibility-Web,*Microsoft-ApplicationInsights-Extensibility-WindowsServer,*Microsoft-ApplicationInsights-WindowsServer-Core,*Microsoft-ApplicationInsights-LoggerProvider,*Microsoft-ApplicationInsights-Extensibility-EventSourceListener,*Microsoft-ApplicationInsights-AspNetCore,*Redfield-Microsoft-ApplicationInsights-Core,*Redfield-Microsoft-ApplicationInsights-Data,*Redfield-Microsoft-ApplicationInsights-WindowsServer-TelemetryChannel,*Redfield-Microsoft-ApplicationInsights-Extensibility-AppMapCorrelation-Dependency,*Redfield-Microsoft-ApplicationInsights-Extensibility-AppMapCorrelation-Web,*Redfield-Microsoft-ApplicationInsights-Extensibility-DependencyCollector,*Redfield-Microsoft-ApplicationInsights-Extensibility-PerformanceCollector,*Redfield-Microsoft-ApplicationInsights-Extensibility-EventCounterCollector,*Redfield-Microsoft-ApplicationInsights-Extensibility-PerformanceCollector-QuickPulse,*Redfield-Microsoft-ApplicationInsights-Extensibility-Web,*Redfield-Microsoft-ApplicationInsights-Extensibility-WindowsServer,*Redfield-Microsoft-ApplicationInsights-LoggerProvider,*Redfield-Microsoft-ApplicationInsights-Extensibility-EventSourceListener,*Redfield-Microsoft-ApplicationInsights-AspNetCore

You can modify these parameters as needed:

  • MaxCollectSec. Set this parameter to prevent PerfView from running indefinitely and affecting the performance of your server.
  • OnlyProviders. Set this parameter to only collect logs from the SDK. You can customize this list based on your specific investigations.
  • NoGui. Set this parameter to collect logs without the GUI.

For more information,

Collect logs with dotnet-trace

Alternatively, customers can also use a cross-platform .NET Core tool, dotnet-trace for collecting logs that can further help in troubleshooting. This tool may be helpful for linux-based environments.

After installation of dotnet-trace, execute the command below in bash.

dotnet-trace collect --process-id <PID> --providers Microsoft-ApplicationInsights-Core,Microsoft-ApplicationInsights-Data,Microsoft-ApplicationInsights-WindowsServer-TelemetryChannel,Microsoft-ApplicationInsights-Extensibility-AppMapCorrelation-Dependency,Microsoft-ApplicationInsights-Extensibility-AppMapCorrelation-Web,Microsoft-ApplicationInsights-Extensibility-DependencyCollector,Microsoft-ApplicationInsights-Extensibility-HostingStartup,Microsoft-ApplicationInsights-Extensibility-PerformanceCollector,Microsoft-ApplicationInsights-Extensibility-EventCounterCollector,Microsoft-ApplicationInsights-Extensibility-PerformanceCollector-QuickPulse,Microsoft-ApplicationInsights-Extensibility-Web,Microsoft-ApplicationInsights-Extensibility-WindowsServer,Microsoft-ApplicationInsights-WindowsServer-Core,Microsoft-ApplicationInsights-LoggerProvider,Microsoft-ApplicationInsights-Extensibility-EventSourceListener,Microsoft-ApplicationInsights-AspNetCore,Redfield-Microsoft-ApplicationInsights-Core,Redfield-Microsoft-ApplicationInsights-Data,Redfield-Microsoft-ApplicationInsights-WindowsServer-TelemetryChannel,Redfield-Microsoft-ApplicationInsights-Extensibility-AppMapCorrelation-Dependency,Redfield-Microsoft-ApplicationInsights-Extensibility-AppMapCorrelation-Web,Redfield-Microsoft-ApplicationInsights-Extensibility-DependencyCollector,Redfield-Microsoft-ApplicationInsights-Extensibility-PerformanceCollector,Redfield-Microsoft-ApplicationInsights-Extensibility-EventCounterCollector,Redfield-Microsoft-ApplicationInsights-Extensibility-PerformanceCollector-QuickPulse,Redfield-Microsoft-ApplicationInsights-Extensibility-Web,Redfield-Microsoft-ApplicationInsights-Extensibility-WindowsServer,Redfield-Microsoft-ApplicationInsights-LoggerProvider,Redfield-Microsoft-ApplicationInsights-Extensibility-EventSourceListener,Redfield-Microsoft-ApplicationInsights-AspNetCore

How to remove Application Insights

Learn how to remove Application Insights in Visual Studio by following the steps provide in the remove Application Insights article.

Still not working...