This page covers common configuration steps for Prometheus deployments.
| Installation Method | Configuration Path |
|---|---|
| APT/DNF package | /etc/prometheus/prometheus.yml |
| Binary installation | /opt/prometheus/prometheus.yml |
| Docker | Mounted volume (e.g., /etc/prometheus/prometheus.yml) |
global:
scrape_interval: 15s # How often to scrape targets
evaluation_interval: 15s # How often to evaluate rules
external_labels:
monitor: 'prometheus'
environment: 'production'
scrape_configs:
# Prometheus self-monitoring
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
# Node exporter for system metrics
- job_name: 'node'
static_configs:
- targets: ['localhost:9100']
# Application metrics
- job_name: 'application'
metrics_path: '/metrics'
static_configs:
- targets: ['app-server:8080']
Create a separate file /etc/prometheus/rules/alerts.yml:
groups:
- name: example-alerts
rules:
- alert: InstanceDown
expr: up == 0
for: 5m
labels:
severity: critical
annotations:
summary: "Instance {{ $labels.instance }} down"
description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 5 minutes."
- alert: HighMemoryUsage
expr: (1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes)) * 100 > 90
for: 10m
labels:
severity: warning
annotations:
summary: "High memory usage on {{ $labels.instance }}"
description: "Memory usage is above 90% on {{ $labels.instance }}"
Reference the rules file in prometheus.yml:
rule_files:
- "/etc/prometheus/rules/*.yml"
alerting:
alertmanagers:
- static_configs:
- targets: ['localhost:9093']
scrape_configs:
- job_name: 'kubernetes-pods'
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
action: keep
regex: true
scrape_configs:
- job_name: 'file-sd'
file_sd_configs:
- files:
- '/etc/prometheus/targets/*.json'
promtool check config /etc/prometheus/prometheus.yml
promtool check rules /etc/prometheus/rules/alerts.yml
Without restarting:
curl -X POST http://localhost:9090/-/reload
Or via systemctl:
sudo systemctl reload prometheus
sudo systemctl restart prometheus
Check targets are being scraped:
curl http://localhost:9090/api/v1/targets
Check alert rules:
curl http://localhost:9090/api/v1/rules
Running Prometheus in regulated environments? We assist with:
Secure your deployment: office@linux-server-admin.com | Contact Page