Lesson 8 of 13 · 20m
Past 15 Days: HA Prometheus and Remote Write
Two replicas with external labels, remote_write to Thanos/Mimir/VictoriaMetrics, and where queries and rules move.
Prometheus's TSDB is single-node by design: one process, one disk, retention that defaults to 15 days (--storage.tsdb.retention.time). The wrong mental model is that scaling means making Prometheus bigger. The actual answer is that high availability and long-term storage are someone else's job — Thanos, Mimir, or VictoriaMetrics — while Prometheus keeps being the hot 15-day scraper it was built to be.
HA is two copies, not a cluster
There is no Prometheus cluster mode. HA is two identical Prometheus servers scraping the same targets; both write the same data and deduplication happens at query time in the Thanos querier or the Mimir side. Each replica carries an external label — replica: a versus replica: b in global.external_labels — so the dedup layer can tell the copies apart and drop the label on the way out. Deploy two replicas without distinguishing labels and your "HA" setup shows every metric doubled, which is worse than no HA because it looks like it works.
remote_write is the egress
remote_write: in prometheus.yml streams every sample to a remote endpoint — a Mimir distributor, VictoriaMetrics vminsert, Thanos receive, or a vendor:
remote_write:
- url: https://mimir.example.org/api/v1/push
queue_config: {capacity: 10000, max_shards: 50}
write_relabel_configs:
- source_labels: [__name__]
regex: "scrape_.*"
action: dropThe queue reads from the WAL and retries on backend failure, so a remote outage backfills rather than loses data — until capacity is exceeded and the oldest data is dropped. Two consequences people learn by invoice: remote_write roughly doubles your egress, and every high-cardinality series you failed to kill locally now bills you at the destination too. write_relabel_configs exists to drop series on the way out — internal noise like scrape_samples_scraped rarely needs to leave the building.
The storage-layer options
- Thanos: a sidecar per Prometheus uploads the local two-hour TSDB blocks to object storage; a querier fans queries out across sidecars and the store gateway; a compactor downsamples old data to 5m/1h resolution and applies retention; an optional ruler evaluates recording rules against stored data. Raw data stays cheap forever in S3 at the cost of several moving parts.
- Mimir: Grafana Labs' multi-tenant store in the Cortex lineage. You remote_write in; it handles dedup, sharding, and retention. More turnkey, more infra to run.
- VictoriaMetrics: speaks PromQL-compatible MetricsQL and accepts Prometheus remote_write, with a simpler footprint. The cheap-and-fast option many ops teams land on after doing the math.
Federation (/federate) still exists for rolling a handful of aggregate series up into a global Prometheus. It is wrong for shipping everything.
Thanos retention splits by resolution: raw blocks might live 30 days, 5m-downsampled a year, 1h-downsampled forever — the compactor enforces each tier separately, which is how "infinite history" stays cheap. Ten-year capacity questions get answered against 1h data; Tuesday's incident gets answered against raw.
There is also a lighter deployment shape worth knowing: Prometheus agent mode (--enable-feature=agent, or the prometheus-agent binary) scrapes and remote_writes with no local query or TSDB retention — it is the answer for edge clusters and customer installs where you want the pull model's semantics without running a store.
What moves operationally
Grafana points at the Thanos querier or Mimir, not at Prometheus directly. Retention stops being a flag and becomes a storage policy plus a compaction schedule. Rules split: alerting rules stay on the scraping Prometheus because they need up freshness; recording rules feeding dashboards can move to the ruler layer.
Concrete practice
- Two identical scrapers plus a distinguishing external label is the HA answer; do not chase "clustered Prometheus."
- remote_write to one backend, with
write_relabel_configsdropping what you refuse to pay to store. - Downsampled history answers capacity-planning questions; 15-day raw answers "what happened Tuesday."
- Before any of this: kill the cardinality. Scaling a broken label schema buys a bigger, more expensive broken label schema.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Your Container Is Running SerialGC and Nobody Told You
You tuned G1 flags for a week. Your pod has one CPU, which means the JVM quietly picked a single-threaded collector at startup and ignored every flag you set. Here is the OpenJDK source that made that decision.
PostgreSQL 19 Is Out. REPACK Kept My Writes Running. The Docker Upgrade Will Stop Your App.
PostgreSQL 19 shipped on November 19 with REPACK (CONCURRENTLY), which removes table bloat without blocking writes. I measured it against VACUUM FULL, ran the upgrade from 18, and checked what breaks for self-hosters: Docker tags that refuse to start, a config setting that stops the server, and...
AWS Emulator Puts AWS on Your Laptop. Keep Your IAM Tests Off It.
AWS released AWS Emulator on November 11, a free local server that answers AWS API calls on 127.0.0.1 with per-run keys and fresh certificates.
Your npm Install Just Ran Someone Else's Code: Why Dependency Security Has to Start Before CI
A pull request checkout, a poisoned GitHub Actions cache, and an OIDC token pulled straight out of runner memory. That's how 84 malicious versions of TanStack's packages hit npm in six minutes.