Course contentsShow
← Cloud and Infrastructure
Lesson 1961 of 2,98942. Observability - MetricsFree lesson

Federation for Multi-Cluster Monitoring

Setting up Prometheus federation to aggregate metrics from multiple Prometheus servers into a central instance.

Federation for Multi-Cluster Monitoring

What you'll learn: How to use Prometheus federation to collect and aggregate metrics from multiple separate Prometheus servers into a single, central monitoring view.

The Challenge of Multi-Cluster Monitoring

When you operate multiple Kubernetes clusters or distributed infrastructure, each environment typically runs its own Prometheus instance. Without federation, you'd need to jump between different Prometheus UIs to get a complete picture—imagine managing a library with separate catalogs for each floor.

What is Prometheus Federation?

Federation is Prometheus's built-in mechanism for one Prometheus server to scrape and store metrics from another Prometheus server. Think of it like a news aggregator that collects headlines from multiple regional newspapers into one national feed.

The federated (central) Prometheus uses a special endpoint /federate exposed by each child Prometheus server. This endpoint allows selective metric retrieval based on label matching.

How Federation Works

Your central Prometheus scrapes the /federate endpoint of downstream Prometheus servers just like any other target. You configure it in your central Prometheus prometheus.yml:

scrape_configs:
  - job_name: 'federate-cluster-a'
    honor_labels: true
    metrics_path: '/federate'
    params:
      'match[]':
        - '{job="kubernetes-nodes"}'
        - '{__name__=~"job:.*"}'
    static_configs:
      - targets:
        - 'prometheus-cluster-a:9090'

The honor_labels setting prevents label conflicts, while match[] filters which metrics to pull—typically aggregated data from recording rules rather than raw metrics.

Federation Patterns

Hierarchical federation creates layers: edge Prometheus instances → regional aggregators → global view. This scales better than pulling everything into one central instance.

Key Takeaway: Prometheus federation aggregates metrics from multiple Prometheus servers into a central instance using the /federate endpoint, enabling unified monitoring across distributed clusters while keeping local data sovereignty.