Apache APISIX is a dynamic, real-time, high-performance API gateway, and it provides rich traffic management features such as load balancing, dynamic upstream, canary release, circuit breaking, authentication, observability, and more. For example, use Apache APISIX to handle traditional north-south traffic, as well as east-west traffic between services. It can also be used as a Kubernetes ingress controller.
The APISIX-Datadog plugin pushes its custom metrics to the DogStatsD server and comes bundled with the Datadog Agent over the UDP connection. DogStatsD is an implementation of StatsD protocol. It collects the custom metrics for Apache APISIX agent, aggregates it into a single data point, and sends it to the configured Datadog server.
Follow the configuration instructions below.
If you are already using Datadog and have the Datadog Agent installed, make sure port 8125/UDP is allowed through your firewall. For example, the Apache APISIX agent can reach port 8125 of the Datadog Agent. If you already have this configured, you can skip to step 3.
First, create an account by visiting the Datadog website and click on the Get Started Free button.
Generate an API Key.
The APISIX-Datadog plugin requires only the DogStatsD component of datadog/agent as the plugin asynchronously send metrics to the DogStatsD server following the statsd protocol over standard UDP socket. That’s why APISIX recommends using the standalone datadog/dogstatsd image instead of using the full agent. It’s extremely lightweight (only ~11 MB in size) compared to ~2.8GB of datadog/agent image.
To run it as a container:
# pull the latest image
$ docker pull datadog/dogstatsd:latest
# run a detached container
$ docker run -d --name dogstatsd-agent -e DD_API_KEY=<Your API Key from step 2> -p 8125:8125/udp datadog/dogstatsd
If you are using Kubernetes in your production environment, you can deploy dogstatsd as a Daemonset or as a Multi-Container Pod alongside Apache APISIX agent.
The following is an example on how to activate the Datadog plugin for a specific route. This assumes the dogstatsd agent is already up and running.
# enable plugin for a specific route
$ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
Now any requests to endpoint URI /hello will generate the above metrics and push it to local DogStatsD server of the Datadog Agent.
To deactivate the plugin, remove the corresponding JSON configuration in the plugin configuration to disable datadog. APISIX plugins are hot-reloaded, therefore there is no need to restart APISIX.