Prometheus Configuration Guide
This document outlines a typical Prometheus configuration file, detailing key sections for setting up a robust monitoring and alerting system. Understanding these parameters is crucial for effective system management and incident response.
Prometheus Global Configuration
The global
section defines default settings that apply across your Prometheus instance. This includes the scrape_interval
, which dictates how frequently Prometheus scrapes metrics from targets, and the evaluation_interval
for evaluating alerting rules. external_labels
are useful for identifying the Prometheus instance itself within a larger federated setup.
Alerting Manager Configuration
The alerting
section specifies how Prometheus should send alerts to an Alertmanager instance. Here, you define the scheme
(e.g., http
) and the targets
where the Alertmanager is running. Proper Alertmanager configuration is vital for reliable notification delivery.
Scrape Configuration Jobs
The scrape_configs
section is where you define the jobs that Prometheus will monitor. Each job_name
represents a distinct service or set of targets. Within each job, static_configs
can be used to list the specific endpoints (targets
) to scrape. This example includes configurations for Prometheus itself and the Traefik reverse proxy.
Prometheus Scrape Job
This job configures Prometheus to scrape its own metrics. A shorter scrape_interval
(e.g., 5s
) is often used for self-monitoring to ensure prompt visibility into Prometheus's operational status.
Traefik Scrape Job
This job demonstrates how to configure Prometheus to collect metrics from Traefik, a popular edge router. The scrape_interval
is set to 15s
, a common interval for service metrics.
global:
scrape_interval: 15s
evaluation_interval: 15s
external_labels:
cluster: 'cheatsheets-promtail'
rule_files:
- '/etc/prometheus/rules/host_alert_rules.yml'
- '/etc/prometheus/rules/healtcheck_alert_rules.yml'
alerting:
alertmanagers:
- scheme: http
static_configs:
- targets: ['alertmanager:9093']
scrape_configs:
- job_name: 'prometheus'
scrape_interval: 5s
static_configs:
- targets: ['localhost:9090']
- job_name: 'traefik'
scrape_interval: 15s
static_configs:
- targets: ['traefik:8080']