Skill for configuring the Apache APISIX prometheus plugin via the a6 CLI. Covers enabling Prometheus metrics export on routes and globally, exposed metrics (HTTP status, latency, bandwidth, upstream health, LLM tokens), custom labels, histogram buckets, and Grafana dashboard integration.
The prometheus plugin exposes APISIX metrics in Prometheus text format. It
tracks HTTP status codes, request latency, bandwidth, upstream health, etcd
status, and (since v3.15) LLM token usage. Prometheus scrapes the metrics
endpoint; Grafana visualizes them.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
prefer_name | boolean | No | false | Use route/service name instead of ID in metric labels |
The plugin has minimal per-route config. Most configuration is global via
plugin_attr in APISIX config.yaml.
| Metric | Type | Description |
|---|---|---|
apisix_http_status | counter | HTTP status codes per route/service/consumer |
apisix_http_latency | histogram | Request latency in ms (types: request, upstream, apisix) |
apisix_bandwidth | counter | Bandwidth in bytes (types: ingress, egress) |
apisix_http_requests_total | gauge | Total HTTP requests received |
apisix_nginx_http_current_connections | gauge | Current connections by state |
apisix_upstream_status | gauge | Upstream health (1=healthy, 0=unhealthy) |
apisix_etcd_reachable | gauge | etcd reachability (1=reachable, 0=unreachable) |
apisix_etcd_modify_indexes | gauge | etcd modification count |
apisix_node_info | gauge | APISIX node hostname and version |
apisix_shared_dict_capacity_bytes | gauge | Shared memory capacity |
apisix_shared_dict_free_space_bytes | gauge | Shared memory free space |
apisix_stream_connection_total | counter | TCP/UDP stream connections |
| Metric | Type | Description |
|---|---|---|
apisix_llm_latency | histogram | LLM request latency |
apisix_llm_prompt_tokens | counter | Prompt tokens consumed |
apisix_llm_completion_tokens | counter | Completion tokens consumed |
apisix_llm_active_connections | gauge | Active LLM connections |
request - upstream (APISIX processing overhead)a6 route create -f - <<'EOF'
{
"id": "my-api",
"uri": "/api/*",
"plugins": {
"prometheus": {
"prefer_name": true
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"backend:8080": 1
}
}
}
EOF
curl "$(a6 context current -o json | jq -r .server)/apisix/admin/global_rules" \
-X PUT \
-H "X-API-KEY: $(a6 context current -o json | jq -r .api_key)" \
-d '{
"id": "prometheus-global",
"plugins": {
"prometheus": {}
}
}'
Default endpoint: http://127.0.0.1:9091/apisix/prometheus/metrics
# prometheus.yml
scrape_configs:
- job_name: apisix
scrape_interval: 15s
static_configs:
- targets: ['127.0.0.1:9091']
Import dashboard ID 11719 from grafana.com for a pre-built APISIX monitoring dashboard.
Configure in APISIX config.yaml (not via Admin API):
plugin_attr:
prometheus:
export_uri: /apisix/prometheus/metrics
metric_prefix: apisix_
enable_export_server: true
export_addr:
ip: 0.0.0.0
port: 9091
plugin_attr:
prometheus:
metrics:
http_status:
extra_labels:
- upstream_addr: $upstream_addr
http_latency:
extra_labels:
- upstream_addr: $upstream_addr
bandwidth:
extra_labels:
- upstream_addr: $upstream_addr
plugin_attr:
prometheus:
default_buckets:
- 10
- 50
- 100
- 200
- 500
- 1000
- 5000
- 30000