Interview Prep/Monitoring & Observability/Prometheus and PromQL at Scale

One Prometheus cannot scrape 5000 targets. How do you scale scraping horizontally?

AdvancedScenarioPrometheus and PromQL at Scale
Answer

Situation read → A single Prometheus has CPU, memory and scrape-time limits. Scale by splitting the target set, not by adding replicas that scrape the same targets.

What I'd do →

  1. Functional sharding: one Prometheus per team, environment or job type.
  2. Hash-based sharding with relabeling:
relabel_configs:
  - source_labels: [__address__]
    modulus: 4
    target_label: __tmp_hash
    action: hashmod
  - source_labels: [__tmp_hash]
    regex: ^1$        # this instance keeps shard 1
    action: keep
  1. The Prometheus Operator supports shards: 4 natively.
  2. Put a global query layer on top (Thanos Querier, Mimir, VictoriaMetrics) because each shard sees only part of the data.
  3. Run HA pairs per shard.

Why → Hashing gives an even, stable split. Global queries then need a layer that merges shards.

Interview tip → Before sharding, check whether cardinality, not target count, is the real problem.

All Monitoring & Observability questions Roadmap: Monitoring & alerting

More on Prometheus and PromQL at Scale