Search code examples
c#asp.net-mvcazureasp.net-mvc-4azure-application-insights

Application Insights telemetry shows 'NA' from MVC 4 application behind private load balancer


Hello Stack Overflow community,

I'm facing an issue with Application Insights telemetry in my MVC 4 application when it's deployed behind a private load balancer. Locally, the CPU and Memory telemetry is successfully pushed, but when running from a Virtual Machine behind a private load balancer, it shows "NA" as seen in the screenshot below:

enter image description here

Initially, I suspected the load balancer, but ongoing requests are indeed being pushed from the VM.

Here's how I've configured Application Insights in my Startup.cs:

[assembly: OwinStartup(typeof(DesignHub.WebMvc.Startup))]
public class Startup
{ 
    public void Configuration(IAppBuilder app)
    {
        string appInsightsConnectionString = ConfigurationManager.AppSettings["AppInsightsConnectionString"];

        Configure Application Insights
        if (string.IsNullOrEmpty(appInsightsConnectionString) == false)
        {
            TelemetryConfiguration.Active.ConnectionString = appInsightsConnectionString;
        }
    }
}

I'd greatly appreciate any insights or suggestions on what might be causing this discrepancy and how to resolve it.

Thank you for your assistance!


Solution

  • The core issue lies in the IIS Application Pool's identity lacking sufficient permissions to access performance counters, impeding proper monitoring and resource analysis.

    Resolution Steps:

    Verify Application Pool Identity:

    • Open the Internet Information Services (IIS) Manager.
    • Navigate to Application Pools.
    • Double-click the relevant Application Pool.
    • In the Identity section, note the current user or service account under which the pool is running.

    Grant Permissions:

    • Open an elevated Command Prompt window (Run as administrator).

    • Execute the following command, replacing PoolName with the actual name of your Application Pool:

    net localgroup "Performance Monitor Users" /add "IIS APPPOOL\PoolName"
    
    • Press Enter to execute the command. This grants the Application Pool's identity membership in the "Performance Monitor Users" group, enabling access to performance counters.

    Validate the Fix:

    • Restart the Application Pool (right-click on the pool in IIS Manager and select "Restart").

    • Attempt to access or collect performance counters after the restart. Confirm that the issue is resolved.