prometheus metric failed when add process metric

38 views Asked by At

I am adding metric to my project. I am using OpenTelemetry.Instrumentation.Process package, but when I check the Targets status in Prometheus , I saw the following error:

unit "seconds" not a suffix of metric "process_cpu_time_seconds_total"

enter image description here

here is how I add the metrics

.WithMetrics(x =>
        {
            x.AddProcessInstrumentation();
            x.AddHttpClientInstrumentation();
            x.AddAspNetCoreInstrumentation();
            //x.AddRuntimeInstrumentation();
            x.AddPrometheusExporter()
                .AddMeter("MyApplication.Api")
                .AddMeter("System.Runtime")
                .AddMeter("System.Net.Http")
                .AddMeter("System.Data.SqlClient")
                .AddMeter("Microsoft.AspNetCore.Hosting")
                .AddMeter("Microsoft.AspNetCore.Server.Kestrel")
                .AddMeter("Microsoft.AspNetCore.Http.Connections")
                .AddMeter("Microsoft.AspNetCore.Routing")
                .AddMeter("Microsoft.AspNetCore.Diagnostics")
                .AddMeter("Microsoft.AspNetCore.RateLimiting");
        });
1

There are 1 answers

0
Dmitry On

I had the same issue - in my case I used

endpoints.MapPrometheusScrapingEndpoint()

And it got fixed after I changed it to

app.UseMetricServer();