Closed TestUser0811 closed 3 years ago
@cijothomas,
Code taken from .Net Core2.1 Web API application hosted on Azure service fabric,
services.ConfigureTelemetryModule
module.Counters.Add(new PerformanceCounterCollectionRequest(
@"\Process([dotnet])\Page Faults/sec", "DotnetPageFaultsPerfSec")); //not sure "dotnet" is right value here?
});
BTW data shown on 'PerformanceCounter' table of Azure Application Insights are application related or infrastructure related?
While trying out with "Microsoft.ApplicationInsights.AspNetCore" Version="2.8.2" encountering obsolete warning as shown in the attached image, how to overcome?
Please check the doc link I shared above. Perfcounters are not supported in Asp.Net Core applications.
@cijothomas,
But I can able to get 'Perfcounters' from Asp.Net Core 2.1 application but after upgrading "Microsoft.ApplicationInsights.AspNetCore" from Version="2.3.0" to Version="2.8.2"
With below code,
public IServiceProvider ConfigureServices(IServiceCollection services)
{
var aiOptions = new Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions();
aiOptions.EnableAdaptiveSampling = false;
aiOptions.EnableQuickPulseMetricStream = true;
aiOptions.InstrumentationKey = "XXXXX-XXX-XXX-a97xxxxxxxxxxb";
services.AddApplicationInsightsTelemetry(aiOptions);
// The following configures PerformanceCollectorModule.
services.ConfigureTelemetryModule<PerformanceCollectorModule>((module) =>
{
// the application process name could be "dotnet" for ASP.NET Core self-hosted applications.
module.Counters.Add(new PerformanceCounterCollectionRequest(
@"\Process([dotnet])\Page Faults/sec", "DotnetPageFaultsPerfSec"));
});
//Add MVC
services.AddMvcCore(options =>
{
options.Filters.Add(new LoggingFilter(_container.GetInstance<IMemoryCache>()));
options.Filters.Add(new LoggingFilter(_container.GetInstance<IMemoryCache>()));
options.ModelBinderProviders.Insert(0, new GrantModelBinderProvider());
})
Edited csproj to add,
<PackageReference Include="Microsoft.ApplicationInsights.PerfCounterCollector" Version="2.15.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.8.2" />
Screenshot from Application Insight Instance,
@cijothomas,
Any update? Is the above approach, right approach to get performance counters from .net core2.1 webapi project which inturn runs on Azure SF cluster? Getting performance counters using the approach I have mentioned above, is reliable? Please clarify.
There is limited support for perf counters in Asp.Net Core. Are you seeing any perf counters at all? or not seeing the ones you configure additionally?
With Microsoft.ApplicationInsights.AspNetCore Version="2.8.2", I'm getting below performance counters like "Available Bytes", "% Processor Time" etc (attached image for your reference). Not sure these performance counter values are reliable, as they are retrieved by Aps.net core sdk but not by dedicated oms agents. Are performance counter values retrieved by Asp.Net Core reliable?
My requirement is to get basic performance counters like CPU & Memory utilization by Asp.Net Core web api deployed on each Azure service fabric cluster nodes, any additional or custom performance counters not required for me at this moment.
Your screenshot shows you are already getting performance counters. So what is the question?
monitoring the system from within the system using Asp.Net Core, is right approach?
monitoring the system from within the system using Asp.Net Core, is right approach?
I cannot offer any official guidance on that part. Here's what I know: PerfCounters are published for a lot of "system" things like Memory, Network, and also for Application specific like "Asp.Net, Process CPU" etc. You can query/ready perfCounters either from Application or from an agent. Its quite likely multiples app read the same data if they run in same host machine - in those cases collecting it via agent might be most efficient. Application Insights SDK support reading perf counters (some limitations aside) - its upto you to decide if you want to leverage that or use an agent based approach.
If you are most interested in knowing about .NET Runtime things like (GC pressure, heap size etc), it may be best to use EventCounters. https://docs.microsoft.com/en-us/azure/azure-monitor/app/eventcounters
This issue is stale because it has been open 300 days with no activity. Remove stale label or comment or this will be closed in 7 days.
Need to get Performance counter details like CPU, Memory of Azure Service Fabric nodes using Azure Application insights, to understand what specifically limits the load on the Azure SF cluster.
As per link, modified "ConfigureServices" method in our Startup.cs class.
Note: the code shown below is taken from .Netcore2.1 Web API project deployed on Azure service fabric cluster
Also edited .csproj to add the following line
Still 'PerformanceCounter' table on Azure Application Insights remains empty. What needs done? What I'm missing?
image