Skip to main content
Version: 3.9

datadog

Description#

The datadog monitoring Plugin is for seamless integration of APISIX with Datadog, one of the most used monitoring and observability platform for cloud applications.

When enabled, the Plugin supports multiple metric capture types for request and response cycles.

This Plugin, pushes its custom metrics to the DogStatsD server over UDP protocol and comes bundled with Datadog agent.

DogStatsD implements the StatsD protocol which collects the custom metrics for the Apache APISIX agent, aggregates them into a single data point, and sends it to the configured Datadog server.

This Plugin provides the ability to push metrics as a batch to the external Datadog agent, reusing the same datagram socket. It might take some time to receive the log data. It will be automatically sent after the timer function in the batch processor expires.

Attributes#

NameTypeRequiredDefaultValid valuesDescription
prefer_namebooleanFalsetrue[true,false]When set to false, uses Route/Service ID instead of name (default) with metric tags.

This Plugin supports using batch processors to aggregate and process entries (logs/data) in a batch. This avoids the need for frequently submitting the data. The batch processor submits data every 5 seconds or when the data in the queue reaches 1000. See Batch Processor for more information or setting your custom configuration.

Metadata#

You can configure the Plugin through the Plugin metadata.

NameTypeRequiredDefaultDescription
hoststringFalse"127.0.0.1"DogStatsD server host address.
portintegerFalse8125DogStatsD server host port.
namespacestringFalse"apisix"Prefix for all custom metrics sent by APISIX agent. Useful for finding entities for metrics graph. For example, apisix.request.counter.
constant_tagsarrayFalse[ "source:apisix" ]Static tags to embed into generated metrics. Useful for grouping metrics over certain signals.
tip

See defining tags to know more about how to effectively use tags.

By default, the Plugin expects the DogStatsD service to be available at 127.0.0.1:8125. If you want to change this, you can update the Plugin metadata as shown below:

curl http://127.0.0.1:9180/apisix/admin/plugin_metadata/datadog -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"host": "172.168.45.29",
"port": 8126,
"constant_tags": [
"source:apisix",
"service:custom"
],
"namespace": "apisix"
}'

To reset to default configuration, make a PUT request with empty body:

curl http://127.0.0.1:9180/apisix/admin/plugin_metadata/datadog -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '{}'

Exported metrics#

When the datadog Plugin is enabled, the APISIX agent exports the following metrics to the DogStatsD server for each request/response cycle:

Metric nameStatsD typeDescription
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 till 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.

The metrics will be sent to the DogStatsD agent with the following tags:

  • route_name: Name specified in the Route schema definition. If not present or if the attribute prefer_name is set to false, falls back to the Route ID.
  • service_name: If a Route has been created with an abstracted Service, the Service name/ID based on the attribute prefer_name.
  • consumer: If the Route is linked to a Consumer, the username will be added as a tag.
  • balancer_ip: IP address of the Upstream balancer that processed the current request.
  • response_status: HTTP response status code.
  • scheme: Request scheme such as HTTP, gRPC, and gRPCs.
note

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

Enable Plugin#

Once you have your Datadog agent running, you can enable the Plugin as shown below:

curl http://127.0.0.1:9180/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, requests to the endpoint /hello will generate metrics and push it to the DogStatsD server.

Delete Plugin#

To remove the datadog Plugin, you can delete the corresponding JSON configuration from the Plugin configuration. APISIX will automatically reload and you do not have to restart for this to take effect.

curl http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"methods": ["GET"],
"uri": "/hello",
"plugins": {},
"upstream": {
"type": "roundrobin",
"nodes": {
"127.0.0.1:1980": 1
}
}
}'