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.
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/
To use the Datadog HTTP reporter, first install the nuget package:
nuget install App.Metrics.Datadog
Then enable the reporter using Report.ToDatadogHttp(...)
:
var metrics = new MetricsBuilder()
.Report.ToDatadogHttp("base url of datadogs api", "datadog api key")
.Build();
See Reporting for details on configuring metric report scheduling.
Configuration options are provided as a setup action used with ToDatadogHttp(...)
.
To configure Datadog reporting options:
var filter = new MetricsFilter().WhereType(MetricType.Timer);
var metrics = new MetricsBuilder()
.Report.ToDatadogHttp(
options => {
options.Datadog.BaseUri = "base url of your datadog";
options.Datadog.ApiKey = "datadog api key";
options.HttpPolicy.BackoffPeriod = TimeSpan.FromSeconds(30);
options.HttpPolicy.FailuresBeforeBackoff = 5;
options.HttpPolicy.Timeout = TimeSpan.FromSeconds(10);
options.Filter = filter;
options.FlushInterval = TimeSpan.FromSeconds(20);
})
.Build();
The configuration options provided are:
Option | Description |
---|---|
MetricsDatadogJsonOutputFormatter | The metric payment formatter used when reporting metrics to Datadog |
Filter | The filter used to filter metrics just for this reporter. |
FlushInterval | The delay between reporting metrics. |
BaseUri | The URI of the Datadog’s HTTP api |
ApiKey | The Api Key which your application will use to authenticate with Datadog. |
HttpPolicy.BackoffPeriod | The TimeSpan to back-off when metrics are failing to report to the metrics ingress endpoint. |
HttpPolicy.FailuresBeforeBackoff | The number of failures before backing-off when metrics are failing to report to the metrics ingress endpoint. |
HttpPolicy.Timeout | The HTTP timeout duration when attempting to report metrics to the metrics ingress endpoint. |