0
votes

I have a Service Fabric cluster that is hosting an ASP.NET Core website. I am also using Application Insights to analyze the performance of the website. In order to collect the metrics at runtime and forward them to Application Insights I have added the following line...

AddApplicationInsightsTelemetry("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")

..into the middle of the following standard code for setting up the website inside the Service Fabric service instance...

    protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
    {
        return new ServiceInstanceListener[]
        {
            new ServiceInstanceListener(serviceContext =>
                new HttpSysCommunicationListener(serviceContext, "ServiceEndpoint", (url, listener) =>
                {
                    return new WebHostBuilder()
                                .UseHttpSys()
                                .ConfigureServices(
                                    services => services
                                        .AddSingleton<StatelessServiceContext>(serviceContext)
                                        .AddApplicationInsightsTelemetry("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"))
                                .UseContentRoot(Directory.GetCurrentDirectory())
                                .UseStartup<Startup>()
                                .UseServiceFabricIntegration(listener, ServiceFabricIntegrationOptions.None)
                                .UseUrls(url)
                                .Build();
                }))
        };
    }

Looking at the Application Insights metrics I get the following error trace message...

enter image description here

It states that it could not collection 3 performance counters. I am not sure how to fix that error as the target cluster nodes all have those counters, as confirmed by using the Performance Monitor to check they exist. Plus, different metrics are correctly being collected. Application Insights does list the requests make to the website. So it is mostly working.

Anyone have ideas what the issue might be?

1

1 Answers

0
votes

The ASP.NET Perf Counter Metrics are not available if you are running a Asp.Net Core Web Application.