Datadog Synthetics is now available!


Support for Datadog APM is available for NGINX using a combination of plugins and configurations. The instructions below use NGINX from the official Linux repositories and pre-built binaries for the plugins.

Plugin Installation

The following plugins must be installed:

Commands to download and install these modules:

# Gets the latest release version number from Github.
get_latest_release() {
  wget -qO- "$1/releases/latest" |
    grep '"tag_name":' |
    sed -E 's/.*"([^"]+)".*/\1/';
OPENTRACING_NGINX_VERSION="$(get_latest_release opentracing-contrib/nginx-opentracing)"
DD_OPENTRACING_CPP_VERSION="$(get_latest_release DataDog/dd-opentracing-cpp)"
# Install NGINX plugin for OpenTracing
tar zxf linux-amd64-nginx-${NGINX_VERSION} -C /usr/lib/nginx/modules
# Install Datadog Opentracing C++ Plugin
gunzip -c > /usr/local/lib/

NGINX Configuration

The NGINX configuration must load the OpenTracing module.

load_module modules/; # Load OpenTracing module

The http section enables the OpenTracing module and loads the Datadog tracer:

    opentracing on; # Enable OpenTracing
    opentracing_tag http_user_agent $http_user_agent; # Add a tag to each trace!
    opentracing_trace_locations off; # Emit only one span per request.

    # Load the Datadog tracing implementation, and the given config file.
    opentracing_load_tracer /usr/local/lib/ /etc/dd-config.json;

Locations within the server where tracing is desired should add the following:

            opentracing_operation_name "$request_method $uri";
            opentracing_tag "" "/";

A config file for the Datadog tracing implementation is also required:

  "service": "nginx",
  "operation_name_override": "nginx.handle",
  "agent_host": "localhost",
  "agent_port": 8126

The service value can be modified to a meaningful value for your usage of NGINX. The agent_host value may need to be changed if NGINX is running in a container or orchestrated environment.

Complete examples:

After completing this configuration, HTTP requests to NGINX will initiate and propagate Datadog traces, and will appear in the APM UI.

Further Reading