skip to Main Content

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");
        });

2

Answers


  1. I had the same issue – in my case I used

    endpoints.MapPrometheusScrapingEndpoint()
    

    And it got fixed after I changed it to

    app.UseMetricServer();
    
    Login or Signup to reply.
  2. I had the same problem, but the unit was different:

    unit "bytes" not a suffix of metric "process_runtime_dotnet_gc_allocations_size_bytes_total"
    

    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:"

    AddPrometheusExporter(o => o.DisableTotalNameSuffixForCounters = true)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search