prometheus
Attributes
This plugin will add /apisix/prometheus/metrics
to expose the metrics.
The metrics are exposed via a separate Prometheus server address. By default, the address is 127.0.0.1:9091
. You can change it in the conf/config.yaml
, for example:
Assume environment variable INTRANET_IP
is 172.1.1.1
, now APISIX will export the metrics via 172.1.1.1:9092
.
If you still want to expose the metrics via the data plane port (default: 9080), you can configure it like this:
plugin_attr:
enable_export_server: false
And expose it by using plugin.
How to enable it
prometheus
plugin could be enable with empty table. Notice, name
could be duplicated for multiple routes/services, so when set prefer_name
to true
, take care of naming format or it could be misleading.
For example:
You can use to complete the above operations through the web console.
First, add a Route:
Then add prometheus plugin:
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:
And we can check the status at prometheus console:
How to specify export uri
We can change the default export uri in the plugin_attr
section of conf/config.yaml
.
Here is an example:
plugin_attr:
export_uri: /apisix/metrics
Metrics exported by the plugin can be graphed in Grafana using a drop in dashboard.
Downloads and imports it to Grafana。
Or you can goto Grafana official for Grafana
meta data.
Available metrics
Status codes
: HTTP status code returned from upstream services. These status code available per service and across all services.Attributes:
Bandwidth
: Total Bandwidth (egress/ingress) flowing through APISIX. The total bandwidth of per service can be counted.Attributes:
etcd reachability
: A gauge type with a value of 0 or 1, representing if etcd can be reached by a APISIX or not, where1
is available, and0
is unavailable.Connections
: Various Nginx connection metrics like active, reading, writing, and number of accepted connections.: 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.
Info
: the information of APISIX node.
Here is the original metric data of APISIX:
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:80": 1
}