ASP.NET Core Middleware Graphite Formatting
To serialize metrics in Graphite Plain Text format when /metrics
or /metrics-text
is requested:
- Add the App.Metrics.Formatters.Graphite nuget package to your ASP.NET Core web application.
- Configure in your
Startup.cs
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMetrics()
// .AddGraphiteSerialization() - Enables graphite plain text format on the /metrics-text and /metrics endpoints respectively.
.AddGraphiteMetricsTextSerialization() // Enables graphite plain text format on the /metrics-text endpoint.
.AddGraphiteMetricsSerialization() // Enables graphite plain text format on the /metrics endpoint.
.AddAsciiHealthSerialization()
.AddHealthChecks()
.AddMetricsMiddleware();
}
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
app.UseMetrics();
}
}