App Metrics 1.0 Fork me on GitHub
Show / Hide Table of Contents

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:

  1. Add the App.Metrics.Formatters.Ascii nuget package to your ASP.NET Core web application.
  2. 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();
	}
}
  • Edit this Doc
Back to top Copyright © 2017 Allan Hardy
Generated by DocFX