Skip to main content
RunBook Academy

CephLXXV · Prometheus MetricsPrometheus Metrics

Operating the metrics exporter

Advanced⏱ ~17 mincephcurlprometheus

What you'll learn

  • Configure the exporter for a large cluster
  • Manage its performance cost on the manager
  • Control which metric families are exposed
  • Diagnose exporter problems

Prerequisites

None — start here.

Verified against Ceph Tentacle 20.2.x · Ceph Squid 19.2.x (supported previous) · cephadm matches the verified Ceph release · podman 4.x · csi-rbd and csi-cephfs current · RBD / CephFS / RGW current (matches Ceph release) · Linux kernel 5.15+ (5.10 minimum) · Ubuntu 24.04 LTS (Ceph host baseline) · Debian 12 (Bookworm) (Ceph host baseline) · Rocky Linux / RHEL / AlmaLinux 9.x (Ceph host baseline) · Proxmox VE 9.x (cross-course integration) · Kubernetes 1.31+ (cross-course integration) · 2026-08-18

Not yet marked complete on this device.

Why this matters in production

On a large cluster the exporter produces a large response and takes real time to generate it. Left at defaults it can affect manager responsiveness and produce scrape timeouts.

The cost

# Substitute the active manager's address before running:
MGR_HOST=192.0.2.11

time curl -s "http://$MGR_HOST:9283/metrics" > /dev/null
curl -s "http://$MGR_HOST:9283/metrics" | wc -l
curl -s "http://$MGR_HOST:9283/metrics" | awk -F'{' '{print $1}' | sort | uniq -c | sort -rn | head
  76800 ceph_pg_
  38400 ceph_osd_
   9600 ceph_pool_

On a 500-OSD cluster with 32,768 PGs the response can exceed a hundred thousand lines and take several seconds to generate.

Configuring for scale

ceph config set mgr mgr/prometheus/scrape_interval 30
ceph config set mgr mgr/prometheus/cache true
ceph config set mgr mgr/prometheus/stale_cache_strategy fail
ceph config set mgr mgr/prometheus/rbd_stats_pools ''
SettingEffect
scrape_intervaltells the exporter how often to expect scrapes
cacheserve a cached response rather than regenerating
stale_cache_strategyfail or return when the cache is stale
rbd_stats_poolswhich pools get per-image RBD statistics

The cache setting matters most: with it enabled the exporter generates the response on its own schedule and serves it to any number of scrapers, rather than regenerating per scrape.

# the exporter's own scrape interval must be <= Prometheus's
ceph config get mgr mgr/prometheus/scrape_interval

If Prometheus scrapes more often than the exporter refreshes, it receives the same data repeatedly — harmless but pointless. If it scrapes less often, the cache goes stale and the strategy determines what happens.

Controlling cardinality

# per-image RBD statistics are high cardinality
ceph config get mgr mgr/prometheus/rbd_stats_pools
ceph config set mgr mgr/prometheus/rbd_stats_pools 'rbd-vms'

Enabling RBD per-image statistics on a pool with ten thousand images adds tens of thousands of series. It is valuable for a pool where per-image visibility is needed and expensive everywhere else.

# check the resulting cardinality
MGR_HOST=192.0.2.11

curl -s "http://$MGR_HOST:9283/metrics" | grep -c '^ceph_rbd'

Diagnosing problems

SymptomCause
Scrape timeoutsgeneration time exceeds the scrape timeout
Manager CPU highfrequent regeneration without caching
Missing metrics after failoverscraping only the old active manager
Stale datacache interval longer than the scrape interval
Metrics missing for some daemonsthose daemons not reporting to the manager
# what Prometheus sees
curl -s 'http://prometheus:9090/api/v1/targets' | python3 -c '
import sys,json; d=json.load(sys.stdin)
for t in d["data"]["activeTargets"]:
    if "ceph" in str(t["labels"]):
        print(t["labels"].get("instance"), t["health"], t.get("lastScrapeDuration"))'
# raise the scrape timeout if generation is genuinely slow
- job_name: ceph
  scrape_interval: 30s
  scrape_timeout: 25s

Quiz

Knowledge check · 4 questions

  1. Q1. Why is `stale_cache_strategy: fail` safer than returning stale data?

  2. Q2. Enabling per-image RBD statistics on all pools is a reasonable default.

  3. Q3. Fix scrape timeouts on a large cluster.

    A 500-OSD cluster with 32,768 PGs has intermittent Ceph scrape failures. Manager CPU is elevated. Three Prometheus instances scrape the exporter every 15 seconds.

  4. Q4. What determines whether an exporter response is large enough to need caching?

Passing score: 75%. Answers are checked in this browser.

Production discipline

Enable the exporter cache on any cluster where generating the metrics response takes measurable time — it decouples manager load from the number of scrapers entirely. Set stale_cache_strategy to fail so stale values are never recorded as current and alerts evaluate on real data.

Cross-course references

  • Kubernetes: kube-state-metrics faces the same cardinality and generation-cost issues
  • Linux: any exporter that enumerates many objects needs the same scale consideration