The collector_cluster value must match the name provided for the Datadog Agent cluster. The service_name can be changed to a meaningful value for your usage of Envoy.
With this configuration, HTTP requests to Envoy initiate and propagate Datadog traces, and appear in the APM UI.
The following example configuration demonstrates the placement of items required to enable tracing using Datadog APM.
static_resources:listeners:- address:socket_address:address:0.0.0.0port_value:80traffic_direction:OUTBOUNDfilter_chains:- filters:- name:envoy.filters.network.http_connection_managertyped_config:"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManagergenerate_request_id:truerequest_id_extension:typed_config:"@type": type.googleapis.com/envoy.extensions.request_id.uuid.v3.UuidRequestIdConfiguse_request_id_for_trace_sampling:falsetracing:provider:name:envoy.tracers.datadogtyped_config:"@type": type.googleapis.com/envoy.config.trace.v3.DatadogConfigcollector_cluster:datadog_agent # matched against the named clusterservice_name:envoy-v1.19 # user-defined service namecodec_type:autostat_prefix:ingress_httproute_config:name:local_routevirtual_hosts:- name:backenddomains:- "*"routes:- match:prefix:"/"route:cluster:service1# Traces for healthcheck requests should not be sampled.http_filters:- name:envoy.filters.http.health_checktyped_config:"@type": type.googleapis.com/envoy.extensions.filters.http.health_check.v3.HealthCheckpass_through_mode:falseheaders:- exact_match:/healthcheckname::path- name:envoy.filters.http.routertyped_config:{}use_remote_address:trueclusters:- name:service1connect_timeout:0.250stype:strict_dnslb_policy:round_robinload_assignment:cluster_name:service1endpoints:- lb_endpoints:- endpoint:address:socket_address:address:service1port_value:80# Configure this cluster with the address of the datadog Agent# for sending traces.- name:datadog_agentconnect_timeout:1stype:strict_dnslb_policy:round_robinload_assignment:cluster_name:datadog_agentendpoints:- lb_endpoints:- endpoint:address:socket_address:address:localhostport_value:8126admin:access_log_path:"/dev/null"address:socket_address:address:0.0.0.0port_value:8001
If you are using Envoy’s dog_statsd configuration to report metrics, you can exclude activity from the datadog_agent cluster with this additional configuration.
To control the volume of Envoy traces that are sent to Datadog, specify a sampling rate by setting the parameter DD_TRACE_SAMPLING_RULES to a value between 0.0 (0%) and 1.0 (100%). If no value is specified, 100% of traces starting from Envoy are sent.
To use the Datadog Agent calculated sampling rates (10 traces per second per Agent) and ignore the default sampling rule set to 100%, set the parameter DD_TRACE_SAMPLING_RULES to an empty array:
DD_TRACE_SAMPLING_RULES=[]
You can also define an explicit sampling rate between 0.0 (0%) and 1.0 (100%) by service. For example, to set the sample rate to 10% for service envoy-proxy:
Note: The variables DD_AGENT_HOST, DD_TRACE_AGENT_PORT and DD_TRACE_AGENT_URL do not apply to Envoy, as the address of the Datadog Agent is configured using the cluster settings.
The available environment variables depend on the version of the C++ tracer embedded in Envoy.
The version of the C++ tracer can be found in the logs, indicated by the line starting with “DATADOG TRACER CONFIGURATION”.