Prometheus Federation is a feature that allows multiple Prometheus servers to work together to collect and aggregate metrics. This is particularly useful in large, distributed environments where you may have multiple Prometheus instances running across different clusters or geographic locations.
The prometheus which scrapes other prometheus is called global prometheus and the configuration looks like below:
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'federate'
honor_labels: true
metrics_path: '/federate'
params:
'match[]':
- '{job="example"}'
static_configs:
- targets:
- 'remote-prometheus-server:9090'
Note: remote-prometheus-server -> prometheus running on remote server.
Official Documentation: https://prometheus.io/docs/prometheus/latest/federation/