Document updated on Feb 27, 2024
Datadog Telemetry Integration
Datadog is a cloud monitoring and security platform for developers, IT operations teams, and businesses.
The OpenTelemetry integration allows you to send metrics and traces to Datadog using a Collector.
Datadog configuration
Datadog uses the standard OTLP exporter, here is a configuration example:
{
"version": 3,
"extra_config": {
"telemetry/opentelemetry": {
"service_name": "krakend_service",
"metric_reporting_period": 1,
"@comment": "Report 20% of traces",
"trace_sample_rate": 0.2,
"exporters": {
"otlp": [
{
"name": "my_datadog_agent",
"host": "ddagent",
"port": 8126,
"use_http": false
}
]
}
}
}
}
The important part of the configuration is the otlp
exporter, which accepts the following fields:
Fields of "telemetry/opentelemetry": { "exporters":{} }
otlp
array- The list of OTLP exporters you want to use. Set at least one object to push metrics and traces to an external collector using OTLP.Each item is an object with the following properties:
disable_metrics
boolean- Disable metrics in this exporter (leaving only traces if any). It won’t report any metrics when the flag is
true
.Defaults tofalse
disable_traces
boolean- Disable traces in this exporter (leaving only metrics if any). It won’t report any metrics when the flag is
true
.Defaults tofalse
host
string- The host where you want to push the data. It can be a sidecar or a remote collector.
name
string- A unique name to identify this exporter.Examples:
"local_prometheus"
,"remote_grafana"
port
integer- A custom port to send the data. The port defaults to 4317 for gRPC unless you enable
use_http
, which defaults to 4318.Defaults to4317
use_http
boolean- Whether this exporter uses HTTP instead of gRPC.
In addition, you can configure how the layers
behave (see all options).
Datadog agent
You must set your Datadog API key in the agent. The exporter communicates with the agent and is the agent the one reporting to Datadog.
Here’s an example of how to run the Datadog agent together with KrakenD in a docker-compose file:
krakend:
image: krakend/krakend-ee:2.6
ddagent:
image: gcr.io/datadoghq/agent:latest
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /proc/:/host/proc/:ro
- /sys/fs/cgroup/:/host/sys/fs/cgroup:ro
ports:
- 8126:8126/tcp
- 8125:8125/udp
environment:
# Replace with your API key:
- DD_API_KEY=<API-KEY>
- DD_APM_ENABLED=true
# Replace with your site: https://docs.datadoghq.com/getting_started/site/
- DD_SITE=<DATADOG-SITE>
- DD_APM_NON_LOCAL_TRAFFIC=true
And the configuration would contain:
{ "datadog":
{
"@comment": "Rest of the necessary fields intentionally omitted",
"trace_address": "ddagent:8126",
"stats_address": "ddagent:8125"
}
}
Notice that we are naming the service ddagent
in Docker compose, and this is what we have added in the address.
Migrating from OpenCensus
Prior to v2.6, telemetry sent to Datadog used the OpenCensus exporter. Enabling required adding the datadog
exporter in the opencensus module, and the configurations looked like this:
{
"version": 3,
"extra_config": {
"telemetry/opencensus": {
"sample_rate": 100,
"reporting_period": 0,
"exporters": {
"datadog": {
"tags": [
"gw"
],
"global_tags": {
"env": "prod"
},
"disable_count_per_buckets": true,
"trace_address": "localhost:8126",
"stats_address": "localhost:8125",
"namespace": "krakend",
"service": "gateway"
}
}
}
}
}
You can migrate to OpenTelemetry doing the following changes:
- Rename
telemetry/opencensus
totelemetry/opentelemetry
. sample_rate
-> Delete this fieldreporting_period
-> Rename tometric_reporting_period
datadog
-> Rename tootlp
, and add an array surrounding the object, so it becomes"otlp": [{...}]
namespace
-> Rename toname
tag_host
,tag_path
,tag_method
,tag_statuscode
-> Delete them