Skip to main content

datadog

The datadog plugin supports the integration with Datadog, one of the most used observability service for cloud applications. When enabled, the plugin pushes metrics to DogStatsD server, which comes bundled with the Datadog agent, over UDP protocol.

Metrics

The plugin exports the following metrics by default.

All metrics will be prefixed by the namespace configured in metadata. For example, if the namespace is configured to be apisix, you will see the request.counter metric exported as apisix.request.counter in Datadog.

NameTypeDescription
request.countercounterNumber of requests received.
request.latencyhistogramTime taken to process the request, in milliseconds.
upstream.latencyhistogramTime taken to proxy the request to the upstream server until a response is received, in milliseconds.
apisix.latencyhistogramTime taken by APISIX agent to process the request, in milliseconds.
ingress.sizetimerRequest body size in bytes.
egress.sizetimerResponse body size in bytes.

Tags

The plugin exports metrics with the following tags.

When there are no suitable values for any particular tag, the tag will be omitted.

NameDescription
route_nameName of the route. If not present or if the attribute prefer_name is set to false, fall back to the route ID.
service_nameName of the service. If not present or if the attribute prefer_name is set to false, fall back to the service ID.
consumerUsername of the consumer if the route is connected to a consumer.
balancer_ipIP address of the upstream balancer that processes the current request.
response_statusHTTP response status code.
schemeRequest scheme, such as HTTP and gRPC.

Examples

The examples below demonstrate how you can configure datadog plugin for different scenarios.

Update Datadog Agent Address and Other Metadata

By default, the plugin expects the DogStatsD server to be available at 127.0.0.1:8125. To customize the address and other metadata, update the plugin metadata as such:

curl "http://127.0.0.1:9180/apisix/admin/plugin_metadata/datadog" -X PUT \
-H "X-API-KEY: ${ADMIN_API_KEY}" \
-d '{
"host": "192.168.0.90",
"port": 8181,
"namespace": "apisix",
"constant_tags": [
"source:apisix",
"service:custom"
]
}'

To reset to default configuration, send a request to the datadog plugin metadata with an empty body:

curl "http://127.0.0.1:9180/apisix/admin/plugin_metadata/datadog" -X PUT -d '{}'

Monitor Route Metrics

The example below shows how you can send the metrics of a particular route to Datadog.

Create a route with the datadog plugin and a few optional configuration options:

curl "http://127.0.0.1:9180/apisix/admin/routes" -X PUT \
-H "X-API-KEY: ${ADMIN_API_KEY}" \
-d '{
"id": "datadog-route",
"uri": "/anything",
"plugins": {
"datadog": {
"batch_max_size" : 1,
"max_retry_count": 0
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"httpbin.org": 1
}
}
}'

batch_max_size: set to 1 to send the metric immediately.

max_retry_count: set to 0 to disallow retries if metrics were unsuccessfully sent.

Generate a few requests to the previously created route:

curl "http://127.0.0.1:9080/anything"

In Datadog, Select Metrics from the left menu and go to Explorer. Select apisix.ingress.size.count as the metric. You should see the count reflecting the number of requests generated:

apisix-datadog-ingress-size-count


API7.ai Logo

API Management for Modern Architectures with Edge, API Gateway, Kubernetes, and Service Mesh.

Product

API7 Cloud

SOC2 Type IRed Herring

Copyright © APISEVEN Ltd. 2019 – 2024. Apache, Apache APISIX, APISIX, and associated open source project names are trademarks of the

Apache Software Foundation