Prometheus metrics
Scrape /stats/prometheus and chart per-cluster behavior.
Envoy's metrics, for free
Every Envoy emits a long list of counters, gauges, and histograms by default — without you adding any config beyond the admin interface. They're exposed at:
http://localhost:9901/stats # plain text
http://localhost:9901/stats/prometheus # Prometheus scrape format
Per-cluster, per-listener, per-virtual-host stats are all there. Most of the dashboards you'll ever want for an Envoy fleet come from a handful of metric families.
The metrics you'll actually use
| Metric | What it measures |
|---|---|
envoy_cluster_upstream_rq_total | Requests sent to a cluster (rate) |
envoy_cluster_upstream_rq_xx{response_code_class="2"} | 2xx broken out (also 4, 5) |
envoy_cluster_upstream_rq_time_bucket | Request latency histogram (→ p50/p95/p99) |
envoy_cluster_upstream_cx_active | Open connections to a cluster |
envoy_cluster_upstream_rq_retry | How often retries fire |
envoy_cluster_upstream_rq_pending_overflow | Circuit breakers tripping |
envoy_cluster_outlier_detection_ejections_active | How many endpoints are currently ejected |
envoy_listener_downstream_cx_total | Inbound connections per listener |
envoy_server_state | 0 = LIVE, 1 = DRAINING, 2 = PRE_INITIALIZING, 3 = INITIALIZING |
All envoy_cluster_* metrics come pre-tagged with the cluster name as a
label. That's what makes per-cluster dashboards trivial.
Scraping with Prometheus
A minimal prometheus.yml:
global:
scrape_interval: 15s
scrape_configs:
- job_name: envoy
metrics_path: /stats/prometheus
static_configs:
- targets: ["envoy:9901"]
If you also want only a subset of stats (Envoy emits a lot), narrow them at
the source with a stats_config in envoy.yaml:
stats_config:
stats_matcher:
inclusion_list:
patterns:
- prefix: "cluster."
- prefix: "http."
- prefix: "listener."
- prefix: "server."
That alone can cut your scrape size by 70%.
Hands-on: end-to-end Prometheus + Grafana
Create a folder with three files: envoy.yaml (your Lesson 5
hello-world is fine), prometheus.yml (above), and
compose.yaml:
services:
envoy:
image: envoyproxy/envoy:v1.31-latest
volumes: [ "./envoy.yaml:/etc/envoy/envoy.yaml" ]
ports: [ "10000:10000", "9901:9901" ]
prometheus:
image: prom/prometheus:latest
volumes: [ "./prometheus.yml:/etc/prometheus/prometheus.yml" ]
ports: [ "9090:9090" ]
grafana:
image: grafana/grafana:latest
environment:
GF_AUTH_ANONYMOUS_ENABLED: "true"
GF_AUTH_ANONYMOUS_ORG_ROLE: Admin
ports: [ "3000:3000" ]
Bring it up:
docker compose up -d
Generate some load:
while true; do curl -s -o /dev/null localhost:10000/get; sleep 0.1; done
In Grafana (localhost:3000), add a Prometheus data source at
http://prometheus:9090. Then chart:
rate(envoy_cluster_upstream_rq_total[1m])
You should see request rate per cluster. Add a second panel for latency:
histogram_quantile(0.95,
sum by (le, envoy_cluster_name) (
rate(envoy_cluster_upstream_rq_time_bucket[5m])
)
)
That's a real p95-by-cluster panel. Tear it down with
docker compose down.
You don't have to build dashboards from scratch — search Grafana
Dashboards for "Envoy Proxy"; ID 11021 (or similar)
will give you a pre-built panel set covering RPS, latency, retry rate,
and circuit-breaker overflows.
Up next
Logs tell you about individual requests. Metrics tell you about aggregates. Traces tell you about the journey of one request across many services. That's Lesson 14.
Which metric tracks 5xx responses Envoy received from a cluster's upstream?