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