diff --git a/docs/en/latest/plugins/datadog.md b/docs/en/latest/plugins/datadog.md index be7661533892..2d5be95b0820 100644 --- a/docs/en/latest/plugins/datadog.md +++ b/docs/en/latest/plugins/datadog.md @@ -1,5 +1,11 @@ --- title: datadog +keywords: + - APISIX + - API Gateway + - Plugin + - Datadog +description: This document contains information about the Apache APISIX datadog Plugin. --- -## How to fetch the metric data +## Fetching metrics -We fetch the metric data from the specified url `/apisix/prometheus/metrics`. +You can fetch the metrics from the specified export URI (default: `/apisix/prometheus/metrics`): -``` +```shell curl -i http://127.0.0.1:9091/apisix/prometheus/metrics ``` -Puts this URL address into prometheus, and it will automatically fetch -these metric data. - -For example like this: +You can add this address to Prometheus to fetch the data: ```yaml scrape_configs: - - job_name: 'apisix' + - job_name: "apisix" scrape_interval: 15s # This value will be related to the time range of the rate function in Prometheus QL. The time range in the rate function should be at least twice this value. - metrics_path: '/apisix/prometheus/metrics' + metrics_path: "/apisix/prometheus/metrics" static_configs: - - targets: ['127.0.0.1:9091'] + - targets: ["127.0.0.1:9091"] ``` -And we can check the status at prometheus console: +Now, you will be able to check the status in your Prometheus console: ![checking status on prometheus dashboard](../../../assets/images/plugin/prometheus01.png) ![prometheus apisix in-depth metric view](../../../assets/images/plugin/prometheus02.png) -## How to specify export uri - -We can change the default export uri in the `plugin_attr` section of `conf/config.yaml`. - -| Name | Type | Default | Description | -| ---------- | ------ | ---------------------------- | --------------------------------- | -| export_uri | string | "/apisix/prometheus/metrics" | uri to get the prometheus metrics | - -Here is an example: +## Using Grafana to graph the metrics -```yaml -plugin_attr: - prometheus: - export_uri: /apisix/metrics -``` +Metrics exported by the `prometheus` Plugin can be graphed in Grafana using a drop in dashboard. -## Grafana dashboard - -Metrics exported by the plugin can be graphed in Grafana using a drop in dashboard. - -Downloads [Grafana dashboard meta](https://github.com/apache/apisix/blob/master/docs/assets/other/json/apisix-grafana-dashboard.json) and imports it to Grafana。 - -Or you can goto [Grafana official](https://grafana.com/grafana/dashboards/11719) for `Grafana` meta data. +To set it up, download [Grafana dashboard meta](https://github.com/apache/apisix/blob/master/docs/assets/other/json/apisix-grafana-dashboard.json) and import it in Grafana. Or, you can go to [Grafana official](https://grafana.com/grafana/dashboards/11719) for Grafana metadata. ![Grafana chart-1](../../../assets/images/plugin/grafana-1.png) @@ -153,52 +158,57 @@ Or you can goto [Grafana official](https://grafana.com/grafana/dashboards/11719) ## Available HTTP metrics -* `Status codes`: HTTP status code returned from upstream services. These status code available per service and across all services. +The following metrics are exported by the `prometheus` Plugin: - Attributes: +- Status code: HTTP status code returned from Upstream services. They are available for a single service and across all services. - | Name | Description | - | -------------| --------------------| - | code | The HTTP status code returned by the upstream service. | - | route | The `route_id` of the matched route is request. If it does not match, the default value is an empty string. | - | matched_uri | The `uri` of the route matching the request, if it does not match, the default value is an empty string. | - | matched_host | The `host` of the route that matches the request. If it does not match, the default value is an empty string. | - | service | The `service_id` of the route matched by the request. When the route lacks service_id, the default is `$host`. | - | consumer | The `consumer_name` of the consumer that matches the request. If it does not match, the default value is an empty string. | - | node | The `ip` of the upstream node. | + The available attributes are: -* `Bandwidth`: Total Bandwidth (egress/ingress) flowing through APISIX. The total bandwidth of per service can be counted. + | Name | Description | + |--------------|-------------------------------------------------------------------------------------------------------------------------------| + | code | HTTP status code returned by the upstream service. | + | route | `route_id` of the matched Route with request. Defaults to an empty string if the Routes don't match. | + | matched_uri | `uri` of the Route matching the request. Defaults to an empty string if the Routes don't match. | + | matched_host | `host` of the Route matching the request. Defaults to an empty string if the Routes don't match. | + | service | `service_id` of the Route matching the request. If the Route does not have a `service_id` configured, it defaults to `$host`. | + | consumer | `consumer_name` of the Consumer matching the request. Defaults to an empty string if it does not match. | + | node | IP address of the Upstream node. | - Attributes: +- Bandwidth: Total amount of traffic (ingress and egress) flowing through APISIX. Total bandwidth of a service can also be obtained. - | Name | Description | - | -------------| ------------- | - | type | The type of bandwidth(egress/ingress). | - | route | The `route_id` of the matched route is request. If it does not match, the default value is an empty string.. | - | service | The `service_id` of the route matched by the request. When the route lacks service_id, the default is `$host`. | - | consumer | The `consumer_name` of the consumer that matches the request. If it does not match, the default value is an empty string. | - | node | The `ip` of the upstream node. | + The available attributes are: -* `etcd reachability`: A gauge type with a value of 0 or 1, representing if etcd can be reached by a APISIX or not, where `1` is available, and `0` is unavailable. -* `Connections`: Various Nginx connection metrics like active, reading, writing, and number of accepted connections. -* `Batch process entries`: A gauge type, when we use plugins and the plugin used batch process to send data, such as: sys logger, http logger, sls logger, tcp logger, udp logger and zipkin, then the entries which hasn't been sent in batch process will be counted in the metrics. -* `Latency`: The per service histogram of request time in different dimensions. + | Name | Description | + |----------|-------------------------------------------------------------------------------------------------------------------------------| + | type | Type of traffic (egress/ingress). | + | route | `route_id` of the matched Route with request. Defaults to an empty string if the Routes don't match. | + | service | `service_id` of the Route matching the request. If the Route does not have a `service_id` configured, it defaults to `$host`. | + | consumer | `consumer_name` of the Consumer matching the request. Defaults to an empty string if it does not match. | + | node | IP address of the Upstream node. | + +- etcd reachability: A gauge type representing whether etcd can be reached by APISIX. A value of `1` represents reachable and `0` represents unreachable. +- Connections: Nginx connection metrics like active, reading, writing, and number of accepted connections. +- Batch process entries: A gauge type useful when Plugins like [syslog](./syslog.md), [http-logger](./http-logger.md), [tcp-logger](./tcp-logger.md), [udp-logger](./udp-logger.md), and [zipkin](./zipkin.md) use batch process to send data. Entries that hasn't been sent in batch process will be counted in the metrics. +- Latency: Histogram of the request time per service in different dimensions. - Attributes: + The available attributes are: - | Name | Description | - | ----------| ------------- | - | type | The value can be `apisix`, `upstream` or `request`, which means http latency caused by apisix, upstream, or their sum. | - | service | The `service_id` of the route matched by the request. When the route lacks service_id, the default is `$host`. | - | consumer | The `consumer_name` of the consumer that matches the request. If it does not match, the default value is an empty string. | - | node | The `ip` of the upstream node. | + | Name | Description | + |----------|-------------------------------------------------------------------------------------------------------------------------------------| + | type | Value can be one of `apisix`, `upstream`, or `request`. This translates to latency caused by APISIX, Upstream, or both (their sum). | + | service | `service_id` of the Route matching the request. If the Route does not have a `service_id` configured, it defaults to `$host`. | + | consumer | `consumer_name` of the Consumer matching the request. Defaults to an empty string if it does not match. | + | node | IP address of the Upstream node. | -* `Info`: the information of APISIX node. +- Info: Information about the APISIX node. -Here is the original metric data of APISIX: +Here are the original metrics from APISIX: + +```shell +curl http://127.0.0.1:9091/apisix/prometheus/metrics +``` ```shell -$ curl http://127.0.0.1:9091/apisix/prometheus/metrics # HELP apisix_bandwidth Total bandwidth in bytes consumed per service in Apisix # TYPE apisix_bandwidth counter apisix_bandwidth{type="egress",route="",service="",consumer="",node=""} 8417 @@ -266,8 +276,7 @@ apisix_node_info{hostname="desktop-2022q8f-wsl"} 1 ## Disable Plugin -Remove the corresponding json configuration in the plugin configuration to disable `prometheus`. -APISIX plugins are hot-reloaded, therefore no need to restart APISIX. +To disable the `prometheus` 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. ```shell curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '