ASP.NET Core Middleware ASCII Formatting
To serialize metrics, environment info and/or health as plain text when /metrics
, /metrics-text
, /env
and/or /health
are requested:
- Add the App.Metrics.Formatters.Ascii nuget package to your ASP.NET Core web application.
- Configure in your
Startup.cs
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMetrics()
// .AddAsciiSerialization() - Enables plain text format on the /metrics-text, /metrics, /health and /env endpoints.
.AddAsciiMetricsSerialization() // Enables plain text format on the /metrics-text endpoint.
.AddAsciiMetricsTextSerialization() // Enables plain text format on the /metrics endpoint.
.AddAsciiHealthSerialization() // Enables plain text format on the /health endpont.
.AddAsciiEnvironmentInfoSerialization() // Enables plain text format on the /env endpont.
.AddHealthChecks()
.AddMetricsMiddleware();
}
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
app.UseMetrics();
}
}