Prometheus Tutorials
This page collects practical Prometheus setup and query examples.
A Minimal Scrape Config
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: node
static_configs:
- targets:
- node-exporter:9100
- job_name: app
metrics_path: /metrics
static_configs:
- targets:
- app:8080
Basic Queries
Useful patterns:
rate()for counters.sum by (...)to aggregate dimensions.histogram_quantile()for latency percentiles.
Alert Rule Example
groups:
- name: app-alerts
rules:
- alert: HighErrorRate
expr: rate(http_requests_total{status=~"5.."}[5m]) > 1
for: 10m
labels:
severity: warning
annotations:
summary: High 5xx error rate
Common Setup Flow
- Expose
/metricsin the application or install exporters. - Add the target to
scrape_configs. - Verify the target is
up. - Build one or two dashboards in Grafana.
- Add alerting once the dashboards reflect the real system.
Practical Notes
- Start with a small set of metrics that answer operational questions.
- Use labels for dimensions you actually need to filter or group by.
- Keep the dashboard and alert names close to the service or team that owns them.