🎓 A1Learner
🔍
0 of 50 lessons completed

Prometheus: Federation, Remote Write and High Availability

Federation, remote write and high availability are three ways to grow past one Prometheus server. This lesson is orientation, not a build guide.

A federation scrape job

This job pulls only the shopsentry series from another Prometheus. The match list is the filter.

  - job_name: federate
    honor_labels: true
    metrics_path: /federate
    params: {match: ['{job="shopsentry"}']}
    static_configs: [{targets: ['127.0.0.1:19105']}]

A remote write block

Two lines send every sample to a remote store. The local server keeps its own copy too.

cat >> prometheus.yml <<'EOF'
remote_write:
  - url: http://127.0.0.1:19105/api/v1/write
EOF

Validate before you believe it

Promtool checks the whole file, including the federation job and the remote write block.

promtool check config prometheus-federation-sample.yml

Example

promtool check config prometheus-federation-sample.yml && echo "config valid, nothing running"

Key points

  • Federation: one Prometheus scrapes selected series from another Prometheus, through its /federate endpoint.
  • A global Prometheus federates up and alert state from each site, and leaves detail on the local servers.
  • Remote write: a Prometheus sends its samples to another store as they arrive.
  • Remote write suits long-term storage in a system built for it, such as Mimir or Thanos.
  • High availability: two Prometheus servers scrape the same targets, so one can fail.
  • High availability doubles the scrape load and the disk, and still leaves two separate stores.
  • Deduplication across the pair needs an extra layer, because neither server knows the other.
  • A single node is the right start, because it is simple, cheap, and easy to reason about.

In this example, the federation and remote write config is valid, but no second server was started and no series were federated. That is the honest limit of this lesson. Federation and remote write are ideas to recognise, and the lab stays on one node until it outgrows it.

Note

Grow when one server is measurably too small, not before. Each of these three adds a system to run.

Try it Yourself

Edit the code, then press Run.

Running is simulated · Rust Playground

Exercise

You run one Prometheus and want a single view of three sites. Which option pulls selected series from each site into one global server?