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:

    1. plugin_attr:
    2. 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:

    enable prometheus plugin

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

    prometheus apisix in-depth metric view

    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:

    1. plugin_attr:
    2. 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.

    Grafana chart-2

    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, where 1 is available, and 0 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:

    1. curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
    2. {
    3. "uri": "/hello",
    4. "plugins": {},
    5. "upstream": {
    6. "type": "roundrobin",
    7. "nodes": {
    8. "127.0.0.1:80": 1
    9. }