Monitor Metrics
API7 Gateway provides two ways to monitor traffic:
- A built-in Monitoring page in the Dashboard for at-a-glance status checks with no extra infrastructure.
- A Prometheus scrape endpoint on the data plane for long-term storage, custom queries, and integration with Grafana or any Prometheus-compatible alerting stack.
Approach 1: Built-in Monitoring Page
The Dashboard's Monitoring section displays the most critical real-time metrics:
| Metric | Description |
|---|---|
| QPS | Queries per second, indicating the current load. |
| Latency | Request processing time (average, p90, p99). |
| Error Rate | The percentage of requests returning 4xx or 5xx status codes. |
| Throughput | Inbound and outbound data volume. |
To access this page, sign in to the Dashboard and navigate to Monitoring.
Approach 2: Prometheus Scrape Endpoint
For deep, historical monitoring and custom dashboards, enable the prometheus plugin as a global rule. The data plane then exposes metrics at http://<data-plane>:9091/apisix/prometheus/metrics for any Prometheus-compatible scraper.
Step 1: Enable the Prometheus Plugin Globally
- Admin API
- ADC
curl -k "https://localhost:7443/apisix/admin/global_rules/prometheus?gateway_group_id={group_id}" -X PUT \
-H "X-API-KEY: ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"plugins": {
"prometheus": {}
}
}'
global_rules:
prometheus: {}
adc sync -f adc.yaml
Step 2: Verify the Endpoint
Send a request through any route to generate metrics, then scrape the Prometheus endpoint on the data plane:
curl http://127.0.0.1:9091/apisix/prometheus/metrics
You should see Prometheus-formatted metrics including counters, gauges, and histograms emitted by the gateway. The 9091 port is the data plane's metrics listener; if you run the data plane in Docker, ensure the port is published to the host (-p 9091:9091) before scraping from outside the container.
Step 3: Configure Prometheus to Scrape
Add the data plane to your Prometheus scrape_configs. For example:
scrape_configs:
- job_name: api7-gateway
metrics_path: /apisix/prometheus/metrics
static_configs:
- targets:
- 127.0.0.1:9091
Key Metrics
When building dashboards or alerts, focus on these metrics emitted by the prometheus plugin:
apisix_http_status— counter of responses by status code (labelcode).apisix_http_latency— histogram of request latency (labeltypedistinguishesrequest,upstream, andapisix).apisix_bandwidth— counter of bytes sent and received (labeltype).apisix_nginx_http_current_connections— gauge of active connections (labelstate).
For the full list of metric names, label cardinality, and tuning options, see prometheus.
Additional Resources
- Configure Alerts based on metric thresholds.
- Distributed Tracing to investigate latency spikes surfaced in the metrics.
- Centralized Logging to correlate metric anomalies with log entries.