Skip to content

Expose endpoint for dotnet counters

Saar Shen edited this page Apr 1, 2023 · 1 revision

Exposing an endpoint for dotnet-counters is easy. Follow these steps:

  1. Add NuGet package:

  2. Update the code in Program.cs:

    var builder = WebApplication.CreateBuilder(args);
    ...
    // Add dotnet-counters services
    builder.Services.AddDotNetCounters();
    
    var app = builder.Build();
    ...
    // Expose an endpoint at `/dotnet-counters`
    app.MapDotNetCounters("/dotnet-counters");
    app.Run();
  3. Hit the endpoint:

Notes: There will be no output, yet, since there are no sinks.

Please refer to [ues dotnet-counters local file sink] or [use dotnet-counters azure blob sink] for how to configure the outputs.