Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure. ApplicationInsights. Inexplicable error messge in AI log

I have setup AppllicationInsights resource in Azure portal. There are 2 services writing to it: windows service on premise and service fabric service running on a local service fabric cluster. I am using TelemetryClient object in both services to send data to the Azure ApplicationInsights resource. It looks like I am getting all messages I wanted, but there are some messages origin of which I don't understand. Here is example of the strange message:

AI: Error collecting 6 of the configured performance counters. Please check the configuration. Counter \ASP.NET Applications(??APP_W3SVC_PROC??)\Requests/Sec: Failed to perform the first read for performance counter. Please make sure it exists. Category: ASP.NET Applications, counter: Requests/Sec, instance SFAIUsingSrv.exe
Counter .NET CLR Exceptions(??APP_CLR_PROC??)# of Exceps Thrown / sec: Failed to perform the first read for performance counter. Please make sure it exists. Category: .NET CLR Exceptions, counter: # of Exceps Thrown / sec, instance
Counter \ASP.NET Applications(??APP_W3SVC_PROC??)\Request Execution Time: Failed to perform the first read for performance counter. Please make sure it exists. Category: ASP.NET Applications, counter: Request Execution Time, instance SFAIUsingSrv.exe
.Counter \ASP.NET Applications(??APP_W3SVC_PROC??)\Requests In Application Queue: Failed to perform the first read for performance counter. Please make sure it exists. Category: ASP.NET Applications, counter: Requests In Application Queue, instance SFAIUsingSrv.exe
Counter \Process(??APP_W3SVC_PROC??)\Handle Count: Failed to perform the first read for performance counter. Please make sure it exists. Category: Process, counter: Handle Count, instance SFAIUsingSrv.exe
Counter \ASP.NET Applications(??APP_W3SVC_PROC??)\Requests/Sec: Failed to perform the first read for performance counter. Please make sure it exists. Category: ASP.NET Applications, counter: Requests/Sec, instance SFAIUsingSrv.exe

Here is my ApplicationInsights.config for service fabric service:

<?xml version="1.0" encoding="utf-8"?>
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
  <InstrumentationKey>some instrumentation key</InstrumentationKey>
  <TelemetryInitializers>
        <Add Type="Microsoft.ApplicationInsights.DependencyCollector.HttpDependenciesParsingTelemetryInitializer, Microsoft.AI.DependencyCollector"/>
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.AzureRoleEnvironmentTelemetryInitializer, Microsoft.AI.WindowsServer"/>
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.AzureWebAppRoleEnvironmentTelemetryInitializer, Microsoft.AI.WindowsServer"/>
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.BuildInfoConfigComponentVersionTelemetryInitializer, Microsoft.AI.WindowsServer"/>
    </TelemetryInitializers>
    <TelemetryModules>
        <Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector">
            <ExcludeComponentCorrelationHttpHeadersOnDomains>
                <!-- 
        Requests to the following hostnames will not be modified by adding correlation headers. 
        This is only applicable if Profiler is installed via either StatusMonitor or Azure Extension.
        Add entries here to exclude additional hostnames.
        NOTE: this configuration will be lost upon NuGet upgrade.
        -->
                <Add>core.windows.net</Add>
                <Add>core.chinacloudapi.cn</Add>
                <Add>core.cloudapi.de</Add>
                <Add>core.usgovcloudapi.net</Add>
                <Add>localhost</Add>
                <Add>127.0.0.1</Add>
            </ExcludeComponentCorrelationHttpHeadersOnDomains>
        </Add>
        <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.AI.PerfCounterCollector">
     <!--      
      The following placeholders are supported as InstanceName:
        ??APP_WIN32_PROC?? - instance name of the application process  for Win32 counters.
        ??APP_W3SVC_PROC?? - instance name of the application IIS worker   process for IIS/ASP.NET counters.
        ??APP_CLR_PROC?? - instance name of the application CLR process for .NET counters.
-->
        </Add>
        <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryModule, Microsoft.AI.PerfCounterCollector"/>
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.DeveloperModeWithDebuggerAttachedTelemetryModule, Microsoft.AI.WindowsServer"/>
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.UnhandledExceptionTelemetryModule, Microsoft.AI.WindowsServer"/>
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.UnobservedExceptionTelemetryModule, Microsoft.AI.WindowsServer">
            <!--</Add>
    <Add Type="Microsoft.ApplicationInsights.WindowsServer.FirstChanceExceptionStatisticsTelemetryModule, Microsoft.AI.WindowsServer">
-->
        </Add>
    </TelemetryModules>
    <TelemetryProcessors>
        <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryProcessor, Microsoft.AI.PerfCounterCollector"/>
        <Add Type="Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor, Microsoft.ApplicationInsights"/>
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
            <MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
            <ExcludedTypes>Event</ExcludedTypes>
        </Add>
        <Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
            <MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
            <IncludedTypes>Event</IncludedTypes>
        </Add>
    </TelemetryProcessors>
    <TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel"/>
<!-- 
    Learn more about Application Insights configuration with ApplicationInsights.config here: 
    http://go.microsoft.com/fwlink/?LinkID=513840

    Note: If not present, please add <InstrumentationKey>Your Key</InstrumentationKey> to the top of this file.
  -->
</ApplicationInsights>

Could anybody help me understand why I am getting those messages?

EDIT: It was my services(windows service and service fabric service) which has been producing those messages. And both those services has been running on my development box. So it was quite confusing to see those messages, related to the web apps, when there are no any web apps being used. But then I commented out PerformanceCounterCollector section in ApplicationInsights.config file messages are no longer being produced, if I will find a way to deal with those messages in a more friendly manner I will update my question.

EDIT2: Those messages is showing up only when services are starting.

EDIT3: Here are all nugget packages install for the service fabric service: enter image description here

enter image description here

like image 299
fatherOfWine Avatar asked Jul 21 '17 20:07

fatherOfWine


People also ask

How do I log errors in application Insights?

If you want to log the error as Exception in app insights, this line of code _logger. LogError("Test", new Exception("Test")); should be changed. Change it to _logger. LogError(new Exception(), "test"); , which means the new Exception() should be the first paramter.

What is difference between log analytics and application Insights?

"Log Analytics" is referred as a feature and not what used to be known as Log Analytics as a product. For instance, Application Insights resources provide the same "Log Analytics" feature. For Azure Functions / APIM the native integration with Azure Monitor is through Application Insights.

Where is ApplicationInsights config?

By default, when using the automated experience from the Visual Studio template projects that support Add > Application Insights Telemetry, the ApplicationInsights. config file is created in the project root folder and when compiled is copied to the bin folder.


1 Answers

if it is a Azure Web App, only a subset of the perfcounters are exposed by Azure, they are somewhat documented here:

https://github.com/Microsoft/ApplicationInsights-dotnet-server/blob/develop/Src/PerformanceCollector/Shared/Implementation/WebAppPerformanceCollector/CounterFactory.cs

If you're controlling the server, you need to make sure that whatever user is running that IIS website / app pool is a member of Performance Monitor Users group so that it can read the perf counters.

These messages are coming out from the default configuration of the PerfCounterCollector package, which is included by the WindowsServer package, which you can see here at the github source for the perf counter collector

if you aren't using performance collector stuff at all and just want that to all go away, you can remove the entire

<Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.AI.PerfCounterCollector">
...stuff about perf counters here...
</Add>

section and Application Insights will stop trying to collect perf counters entirely.

like image 83
John Gardner Avatar answered Sep 23 '22 15:09

John Gardner