---
title: Apache APISIX
description: Datadog-APISIX Integration
breadcrumbs: Docs > Integrations > Apache APISIX
---

# Apache APISIX
Supported OS 
## Overview{% #overview %}

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](https://apisix.apache.org/docs/apisix/plugins/datadog) 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](https://apisix.apache.org/) agent, aggregates it into a single data point, and sends it to the configured Datadog server.

## Setup{% #setup %}

### Installation{% #installation %}

Follow the configuration instructions below.

### Configuration{% #configuration %}

1. 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.

To learn more about how to install the Datadog Agent, see the [Agent documentation](https://docs.datadoghq.com/agent.md).

If you are new to Datadog:

1. First, create an account by visiting the [Datadog website](https://www.datadoghq.com/) and click on the Get Started Free button.
1. 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:

```shell
# 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.
```shell
# 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 '
{
  "plugins": {
    "datadog": {}
  },
  "upstream": {
    "type": "roundrobin",
    "nodes": {
      "127.0.0.1:1980": 1
    }
  },
  "uri": "/hello"
}'
```

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.
```shell
# disable plugin for a route
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
  "uri": "/hello",
  "plugins": {},
  "upstream": {
    "type": "roundrobin",
    "nodes": {
      "127.0.0.1:1980": 1
    }
  }
}'
```
See the [Datadog Plugin](https://apisix.apache.org/docs/apisix/plugins/datadog) documentation for additional custom configuration options.
### Validation{% #validation %}

[Run the Agent's status subcommand](https://docs.datadoghq.com/agent/guide/agent-commands.md#agent-status-and-information) and look for `apisix` under the Checks section.

## Data Collected{% #data-collected %}

### Metrics{% #metrics %}

|  |
|  |
| **apisix.request.counter**(count)  | Number of requests received*Shown as connection*                                                                                   |
| **apisix.request.latency**(gauge)  | Total latency of the request response lifecycle, time taken to process the particular request.*Shown as millisecond*               |
| **apisix.upstream.latency**(gauge) | The latency between time taken from proxying the request to the upstream server till a response is received.*Shown as millisecond* |
| **apisix.apisix.latency**(gauge)   | The latency added by Apache APISIX, time taken by APISIX agent solely to process the request.*Shown as millisecond*                |
| **apisix.ingress.size**(gauge)     | The body size of incoming request before forwarding it to upstream server.*Shown as byte*                                          |
| **apisix.egress.size**(gauge)      | The body size of received response coming from the APISIX forwarded upstream server.*Shown as byte*                                |

### Events{% #events %}

The Apache APISIX check does not include any events.

## Troubleshooting{% #troubleshooting %}

Need help? Contact [Datadog support](https://docs.datadoghq.com/help/).

## Further Reading{% #further-reading %}

- [Cloud Monitoring with Datadog in Apache APISIX | Apache APISIX](https://apisix.apache.org/blog/2021/11/12/apisix-datadog)
