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"
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");
});
2
Answers
I had the same issue – in my case I used
And it got fixed after I changed it to
I had the same problem, but the unit was different:
Found a solution and explanation here https://github.com/open-telemetry/opentelemetry-dotnet-contrib/issues/1617
A quote from the issue "You can configure the Prometheus exporter to disable the _total suffix with this option:"