Graphite

Graphite

The App.Metrics.Reporting.Graphite nuget package reports metrics to Graphite using the App.Metrics.Formatters.Graphite nuget package to format metrics by default using the PlainText Protocol.

Getting started

To use the Graphite reporter, first install the nuget package:

nuget install App.Metrics.Reporting.Graphite

Then enable the reporter using Report.ToGraphite(...):

var metrics = new MetricsBuilder()
    .Report.ToGraphite("http://127.0.0.1:2003", TimeSpan.FromSeconds(5))
    .Build();

App Metrics at the moment leaves report scheduling up the the user unless using App.Metrics.AspNetCore.Reporting. To run all configured reports use the ReportRunner on IMetricsRoot:

await metrics.ReportRunner.RunAllAsync();

Report Scheduling will be added when Microsoft.Extensions.Hosting.Background is released, otherwise there are various other scheduling solutions available for C#. For ASP.NET Core reporting see details on the App.Metrics.AspNetCore.Reporting support package.

Configuration

Configuration options are provided as a setup action used with ToGraphite(...).

To configure ToGraphite reporting options:

var filter = new MetricsFilter().WhereType(MetricType.Timer);
var metrics = new MetricsBuilder()
    .Report.ToGraphite(
        options => {
            options.Graphite.BaseUri = new Uri("http://127.0.0.1:8086");
            options.Graphite.Protocol = Protocol.Tcp; // or Protocol.Udp
            options.ClientPolicy.BackoffPeriod = TimeSpan.FromSeconds(30);
            options.ClientPolicy.FailuresBeforeBackoff = 5;
            options.ClientPolicy.Timeout = TimeSpan.FromSeconds(10);
            options.Filter = filter;
            options.FlushInterval = TimeSpan.FromSeconds(20);
        })
    .Build();

Web Monitoring

Grafana

The App.Metrics.AspNetCore.Tracking nuget package automatically records typical web metrics when added to an ASP.NET Core application. App Metrics includes a couple of pre-built Grafana dashboards to visualize these metrics:

Install the App Metrics Grafana dashboard. There is also an OAuth2 dashboard for APIs using OAuth2.