Document updated on May 15, 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 their collector.
Datadog configuration
Datadog uses the standard OTLP exporter, here is a configuration example:
{
"version": 3,
"$schema": "https://www.krakend.io/schema/krakend.json",
"host": [
"http://localhost:8080"
],
"debug_endpoint": true,
"echo_endpoint": true,
"extra_config": {
"telemetry/opentelemetry": {
"exporters": {
"otlp": [
{
"use_http": false,
"port": 4317,
"host": "ddagent",
"name": "my_dd_exporter",
"disable_metrics": false,
"disable_traces": false
}
]
},
"trace_sample_rate": 1,
"service_name": "krakend_dd_telemetry",
"metric_reporting_period": 1
}
}
}
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:
version: '3'
services:
krakend:
image: devopsfaith/krakend:2.8.0
volumes:
- "./:/etc/krakend"
command: ["run", "-c", "krakend.json"]
ports:
- "8080:8080"
datadog:
image: gcr.io/datadoghq/agent:7
pid: host
environment:
- DD_API_KEY=XXXXXXXXXXXXXXX
- DD_OTLP_CONFIG_RECEIVER_PROTOCOLS_GRPC_ENDPOINT=0.0.0.0:4317
- DD_OTLP_CONFIG_RECEIVER_PROTOCOLS_HTTP_ENDPOINT=0.0.0.0:4318
- DD_SITE=datadoghq.com
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /proc/:/host/proc/:ro
- /sys/fs/cgroup:/host/sys/fs/cgroup:ro
Notice that we are naming the service ddagent
in Docker compose, and this matches our host
field in the configuraton.
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
Contribute to KrakenD Documentation. Improve this page »