fix(grafana): добавлено Reduce перед порогами алертов

- Зачем:
  - диапазонные запросы Prometheus возвращали временные ряды, из-за чего Grafana не вычисляла алерты Airflow и Kafka.
- Что:
  - между запросом Prometheus и Threshold добавлен Reduce(last) в семи правилах, а аннотации переведены на итоговое число.
  - добавлены регрессионные тесты конфигурации и зависимость PyYAML для их запуска.
  - в уроке 5 уточнено время срабатывания и восстановления алерта scheduler.
- Проверка:
  - uv run --with-requirements generator/requirements.txt pytest tests/ -q -p no:cacheprovider: 33 passed.
  - uv run --with-requirements requirements.txt pytest tests/ -q -p no:cacheprovider из generator: 218 passed.
  - Docker Compose config и вычисление правил в Grafana 11.5.2 прошли успешно.
This commit is contained in:
ddadmin committed 2026-09-01 00:51:03 +03:00
1 parent ffd467bf43
commit 335e5e7612
5 files changed
+114 -43

No files matched your search

@@ -33,9 +33,8 @@ groups:
model:
conditions:
- evaluator:
params:
- 0.1
type: lt
params: []
type: gt
operator:
type: and
query:
@@ -51,16 +50,17 @@ groups:
expression: A
intervalMs: 1000
maxDataPoints: 43200
reducer: last
refId: B
type: threshold
type: reduce
- refId: C
datasourceUid: __expr__
model:
conditions:
- evaluator:
params:
- 0
type: gt
- 0.1
type: lt
operator:
type: and
query:
@@ -114,8 +114,7 @@ groups:
model:
conditions:
- evaluator:
params:
- 50
params: []
type: gt
operator:
type: and
@@ -132,15 +131,16 @@ groups:
expression: A
intervalMs: 1000
maxDataPoints: 43200
reducer: last
refId: B
type: threshold
type: reduce
- refId: C
datasourceUid: __expr__
model:
conditions:
- evaluator:
params:
- 0
- 50
type: gt
operator:
type: and
@@ -164,7 +164,7 @@ groups:
for: 5m
annotations:
summary: "В очереди Airflow > 50 задач"
description: "airflow_executor_queued_tasks = {{ $values.A }} (превышает 50 в течение 5 минут) — возможна перегрузка"
description: "airflow_executor_queued_tasks = {{ $values.B.Value }} (превышает 50 в течение 5 минут) — возможна перегрузка"
labels:
severity: warning
@@ -195,8 +195,7 @@ groups:
model:
conditions:
- evaluator:
params:
- 0.1
params: []
type: gt
operator:
type: and
@@ -213,15 +212,16 @@ groups:
expression: A
intervalMs: 1000
maxDataPoints: 43200
reducer: last
refId: B
type: threshold
type: reduce
- refId: C
datasourceUid: __expr__
model:
conditions:
- evaluator:
params:
- 0
- 0.1
type: gt
operator:
type: and
@@ -245,7 +245,7 @@ groups:
for: 3m
annotations:
summary: "Высокий rate падений тасков"
description: "rate(airflow_task_failures_total) = {{ $values.A }} (превышает 0.1 в течение 3 минут) — проверьте логи DAG"
description: "rate(airflow_task_failures_total) = {{ $values.B.Value }} (превышает 0.1 в течение 3 минут) — проверьте логи DAG"
labels:
severity: warning
@@ -276,8 +276,7 @@ groups:
model:
conditions:
- evaluator:
params:
- 30
params: []
type: gt
operator:
type: and
@@ -294,15 +293,16 @@ groups:
expression: A
intervalMs: 1000
maxDataPoints: 43200
reducer: last
refId: B
type: threshold
type: reduce
- refId: C
datasourceUid: __expr__
model:
conditions:
- evaluator:
params:
- 0
- 30
type: gt
operator:
type: and
@@ -326,6 +326,6 @@ groups:
for: 5m
annotations:
summary: "Парсинг DAG занимает > 30 секунд"
description: "airflow_dag_processing_total_parse_time = {{ $values.A }}s — возможно, есть тяжелые DAG"
description: "airflow_dag_processing_total_parse_time = {{ $values.B.Value }}s — возможно, есть тяжелые DAG"
labels:
severity: info