Metrics Reporters

App Metrics reporters allows your defined metrics to be flushed for reporting and visualization. The following is a list of the reporters currently available.

    Prometheus

    Basics Prometheus promotes a Pull based approach rather than Push, therefore App Metrics does not include a reporter to push metrics, but rather supports formatting metric data in Prometheus formats using the App.Metrics.Prometheus nuget package. App.Metrics.Prometheus supports both Prometheus’s plain text and protobuf formats. To use the Prometheus formatter, first install the nuget package: nuget install App.Metrics.Prometheus Then enable Prometheus formatting using the MetricsBuilder: Plain text To configure Prometheus plain-text formatting:

    GrafanaCloud Hosted Metrics

    GrafanaCloud Hosted Metrics The App.Metrics.GrafanaCloudHostedMetrics nuget package reports metrics to GrafanaCloud Hosted Metrics using the App.Metrics.Formatters.GrafanaCloudHostedMetrics nuget package to format metrics. GrafanCloud URL, API Key and UserId You will need these three to correctly configure App.Metrics to report to GrafanaCloud Hosted Metrics. By default a graphite hosted metrics instance is created for you when you sign up to GrafanaCloud Hosted Metrics, usually named [YourOrganisation]-graphite. You can see this at https://grafana.

    Influx Data

    InfluxDB The App.Metrics.InfluxDB nuget package reports metrics to InfluxDB using the App.Metrics.Formatters.InfluxDB nuget package to format metrics by default using the Line Protocol. Getting started To use the InfluxDB reporter, first install the nuget package: nuget install App.Metrics.InfluxDB Then enable the reporter using Report.ToInfluxDb(...): var metrics = new MetricsBuilder() .Report.ToInfluxDb("http://127.0.0.1:8086", "metricsdatabase") .Build(); < See Reporting for details on configuring metric report scheduling. Configuration Configuration options are provided as a setup action used with ToInfluxDb(.

    Datadog

    Datadog The App.Metrics.Datadog nuget package reports metrics to Datadog using the App.Metrics.Formatting.Datadog and App.Metrics.Reporting.Datadog nuget packages to format and report metrics. Datadog URL, API Key You will need these two to correctly configure App.Metrics to report to Datadog over HTTP. Create an API key in Datadog here. The Datadog base URL to report metrics over http is https://api.datadoghq.com/ Getting started To use the Datadog HTTP reporter, first install the nuget package:

    StatsD

    StatsD The App.Metrics.StatsD nuget package reports metrics to StatsD using the App.Metrics.Formatting.StatsD and App.Metrics.Reporting.StatsD nuget packages to format and report metrics. Getting started To use the Datadog HTTP reporter, first install the nuget package: nuget install App.Metrics.StatsD Then enable the reporter using Report.ToStatsDTcp(...): var metrics = new MetricsBuilder() .Report.ToStatsDTcp(options => {}) .Build(); or using Report.ToStatsDUdp(...): var metrics = new MetricsBuilder() .Report.ToStatsDUdp(options => {}) .Build(); See Reporting for details on configuring metric report scheduling.

    Http

    The App.Metrics.Reporting.Http nuget package reports metrics to a custom HTTP endpoint. The default output is JSON using App.Metrics.Formatters.JSON which can be substituted with any other App Metrics Formatter. Getting started To use the HTTP reporter, first install the nuget package: nuget install App.Metrics.Reporting.HTTP Then enable the reporter using Report.OverHttp(url): var metrics = new MetricsBuilder() .Report.OverHttp("http://localhost/metrics") .Build(); App Metrics at the moment leaves report scheduling up the the user unless using App.

    Microsoft HealthChecks

    The App.Metrics.Extensions.HealthChecks nuget package records AspNetCore health check results as metrics allowing results to be flushed to a supported TSDB via one of the App Metrics metrics available reporters. How to use With App Metrics configured in either an AspNetCore application or dotnet core application enable the Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheckPublisher implementation to record health check results as metrics on the IServiceCollection services.AddAppMetricsHealthPublishing();

    Socket

    The App.Metrics.Reporting.Socket nuget package reports metrics through a socket. The reporter has no default output formatter, so one of the available formatters must be provided. Getting started To use the Socket reporter, first install the Socket nuget package: nuget install App.Metrics.Reporting.Socket Then install output formatter package of your choice. For example, to report metrics into Telegraf the InfluxDB package is required: nuget install App.Metrics.Formatters.InfluxDB Capabilities Socket reporter is transport layer to send data via sockets.

    Console

    The App.Metrics.Reporting.Console nuget package writes metrics to the Windows Console via standard output. The default output is plain text using App.Metrics.Formatters.Ascii which can be substituted with any other App Metrics Formatter. Getting started To use the console reporter, first install the nuget package: nuget install App.Metrics.Reporting.Console Add the using App.Metrics for access the ToConsole() extension method: using App.Metrics; Then enable the reporter using Report.ToConsole():

    Azure Application Insights

    Getting started Install nuget package: App.Metrics.Reporting.ApplicationInsights Obtain Application Insights instrumentation key. Configure App.Metrics like so: using App.Metrics.Reporting.ApplicationInsights; var instrumentationKey = "00000000-0000-0000-0000-000000000000"; var metrics = new MetricsBuilder() .Configuration.Configure(metricsOptions) .Report.ToApplicationInsights(instrumentationKey) .Build(); Caveats There are few caveats that come along by marriage of two frameworks which both do metric pre-aggragetion before sending it upstream using a reporter. Also the interface for sending metric aggregates on Application Insight’s TelemetryClient is lacking some features which are otherwise available (metric dimensions).

    Text File

    The App.Metrics.Reporting.TextFile nuget package writes metrics to a text file. The default output is plain text using App.Metrics.Formatters.Ascii which can be substituted with any other App Metrics Formatter. Getting started To use the text file reporter, first install the nuget package: nuget install App.Metrics.Reporting.TextFile Then enable the reporter using Report.ToTextFile(): var metrics = new MetricsBuilder() .Report.ToTextFile() .Build(); If not output file name is specified, the default path is the application execution path and file name metrics.

    Graphite

    Graphite The App.Metrics.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.Graphite Then enable the reporter using Report.ToGraphite(...): var metrics = new MetricsBuilder() .Report.ToGraphite("http://127.0.0.1:2003", TimeSpan.FromSeconds(5)) .Build(); See Reporting for details on configuring metric report scheduling. Configuration Configuration options are provided as a setup action used with ToGraphite(.