Skip to content

Commit 771bc81

Browse files
feat: add Prometheus alert rules
Target-down, OTel export failures, and >5% span error rate (from Tempo span metrics). Evaluated by Prometheus, surfaced in Grafana Alerting; no Alertmanager to keep the stack minimal.
1 parent d44c8ab commit 771bc81

3 files changed

Lines changed: 45 additions & 0 deletions

File tree

compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ services:
5555
restart: unless-stopped
5656
volumes:
5757
- ./config/prometheus.yaml:/etc/prometheus/prometheus.yaml:ro
58+
- ./config/alerts:/etc/prometheus/alerts:ro
5859
- prometheus_data:/prometheus
5960
command:
6061
- --config.file=/etc/prometheus/prometheus.yaml

config/alerts/stack.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Prometheus alert rules for the stack itself plus RED-style alerts on the
2+
# span metrics Tempo derives from traces. Evaluated by Prometheus; visible in
3+
# Grafana under Alerting → Alert rules (Prometheus datasource).
4+
# No Alertmanager: single-host stack, alerts are surfaced in Grafana.
5+
# Validated by `just check` (promtool check rules).
6+
7+
groups:
8+
- name: stack-health
9+
rules:
10+
- alert: TargetDown
11+
expr: up == 0
12+
for: 2m
13+
labels:
14+
severity: critical
15+
annotations:
16+
summary: "Scrape target {{ $labels.job }} is down"
17+
description: "Prometheus cannot scrape {{ $labels.instance }} (job {{ $labels.job }}) for 2 minutes."
18+
19+
- alert: OtelExportFailures
20+
expr: sum by (exporter) (rate(otelcol_exporter_send_failed_spans_total[5m])) > 0
21+
or sum by (exporter) (rate(otelcol_exporter_send_failed_metric_points_total[5m])) > 0
22+
or sum by (exporter) (rate(otelcol_exporter_send_failed_log_records_total[5m])) > 0
23+
for: 5m
24+
labels:
25+
severity: warning
26+
annotations:
27+
summary: "OTel Collector failing to export via {{ $labels.exporter }}"
28+
description: "The collector has been failing to deliver telemetry to a backend for 5 minutes. Check `just logs otel-collector`."
29+
30+
- name: service-red
31+
rules:
32+
- alert: HighErrorRate
33+
expr: >
34+
sum by (service) (rate(traces_spanmetrics_calls_total{status_code="STATUS_CODE_ERROR"}[5m]))
35+
/ sum by (service) (rate(traces_spanmetrics_calls_total[5m])) > 0.05
36+
for: 5m
37+
labels:
38+
severity: warning
39+
annotations:
40+
summary: "{{ $labels.service }} error rate above 5%"
41+
description: "More than 5% of spans from {{ $labels.service }} report errors (from Tempo span metrics)."

config/prometheus.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ global:
44
external_labels:
55
origin: monitoring-host
66

7+
rule_files:
8+
- /etc/prometheus/alerts/*.yaml
9+
710
# Apps push metrics via OTLP (through the collector). Scrape only infra we host.
811
scrape_configs:
912
- job_name: prometheus

0 commit comments

Comments
 (0)