Prometheus and Grafana
Encyclopedia home · Search machine-readable catalog
CF-086
Prometheus lab scrape target
Copy to monitoring/prometheus.yml.
global: {scrape_interval: 15s}
scrape_configs:
- job_name: web
static_configs: [{targets: ["web:8000"]}]Verification. Expose /metrics on web:8000 and verify the target becomes UP.
Validation syntax-validated. Official reference
CF-087
Request-success recording rule
Copy to monitoring/rules/slo.yml.
groups:
- name: service
rules:
- record: service:http_success_ratio:rate5m
expr: sum(rate(http_requests_total{status!~"5.."}[5m])) / sum(rate(http_requests_total[5m]))Verification. Test low/no traffic behavior and add labels for multiple services.
Validation syntax-validated. Official reference
CF-088
Service down alert
Copy to monitoring/rules/alerts.yml.
groups:
- name: lab
rules:
- alert: WebDown
expr: up{job="web"} == 0
for: 2m
labels: {severity: warning}
annotations: {summary: "Web fixture scrape is down"}Verification. Validate with promtool and add absent-target alert separately when needed.
Validation syntax-validated. Official reference
CF-089
Grafana datasource provisioning
Copy to provisioning/datasources/prometheus.yaml.
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
uid: prometheus-lab
access: proxy
url: http://prometheus:9090
isDefault: true
editable: falseVerification. Verify the expected UID and run a read-only dashboard query.
Validation syntax-validated. Official reference
CF-090
Grafana availability dashboard
Copy to monitoring/dashboards/web.json.
{"title":"Web availability","uid":"web-lab","schemaVersion":39,"timezone":"utc","panels":[{"id":1,"type":"timeseries","title":"Web up","datasource":{"type":"prometheus","uid":"prometheus-lab"},"gridPos":{"h":8,"w":24,"x":0,"y":0},"targets":[{"refId":"A","expr":"up{job=\"web\"}"}]}]}Verification. Provision matching datasource UID and check the rendered time series.
Validation syntax-validated. Official reference