Files
clickstream-ch-kafka-supers…/configs/grafana/provisioning/alerting/kafka-alert-rules.yml
T
ddadmin 335e5e7612 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 прошли успешно.
2026-09-01 00:51:03 +03:00

251 lines
7.3 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
apiVersion: 1
groups:
- orgId: 1
name: kafka_health_group
folder: Kafka Alerts
interval: 1m
rules:
# --- Alert: Kafka Broker Down ---
- uid: kafka_broker_down
title: Kafka Broker Down
condition: C
data:
- refId: A
relativeTimeRange:
from: 300
to: 0
datasourceUid: prometheus_uid
model:
datasource:
type: prometheus
uid: prometheus_uid
editorMode: code
expr: kafka_brokers
instant: false
intervalMs: 1000
legendFormat: __auto
maxDataPoints: 43200
range: true
refId: A
- refId: B
datasourceUid: __expr__
model:
conditions:
- evaluator:
params: []
type: gt
operator:
type: and
query:
params:
- B
reducer:
params: []
type: last
type: query
datasource:
type: __expr__
uid: __expr__
expression: A
intervalMs: 1000
maxDataPoints: 43200
reducer: last
refId: B
type: reduce
- refId: C
datasourceUid: __expr__
model:
conditions:
- evaluator:
params:
- 1
type: lt
operator:
type: and
query:
params:
- C
reducer:
params: []
type: last
type: query
datasource:
type: __expr__
uid: __expr__
expression: B
intervalMs: 1000
maxDataPoints: 43200
refId: C
type: threshold
noDataState: Alerting
execErrState: Error
for: 1m
annotations:
summary: "Kafka broker недоступен"
description: "Количество доступных брокеров: {{ $values.B.Value }} (ожидается ≥ 1)"
labels:
severity: critical
# --- Alert: High Consumer Lag ---
- uid: kafka_consumer_lag_high
title: Kafka Consumer Lag High
condition: C
data:
- refId: A
relativeTimeRange:
from: 300
to: 0
datasourceUid: prometheus_uid
model:
datasource:
type: prometheus
uid: prometheus_uid
editorMode: code
expr: kafka_consumergroup_lag
instant: false
intervalMs: 1000
legendFormat: "{{ consumergroup }} - {{ topic }}:{{ partition }}"
maxDataPoints: 43200
range: true
refId: A
- refId: B
datasourceUid: __expr__
model:
conditions:
- evaluator:
params: []
type: gt
operator:
type: and
query:
params:
- B
reducer:
params: []
type: last
type: query
datasource:
type: __expr__
uid: __expr__
expression: A
intervalMs: 1000
maxDataPoints: 43200
reducer: last
refId: B
type: reduce
- refId: C
datasourceUid: __expr__
model:
conditions:
- evaluator:
params:
- 10000
type: gt
operator:
type: and
query:
params:
- C
reducer:
params: []
type: last
type: query
datasource:
type: __expr__
uid: __expr__
expression: B
intervalMs: 1000
maxDataPoints: 43200
refId: C
type: threshold
noDataState: NoData
execErrState: Error
for: 5m
annotations:
summary: "Высокий лаг консьюмера {{ $labels.consumergroup }}"
description: "Lag для {{ $labels.topic }}:{{ $labels.partition }} составляет {{ $values.B.Value }} сообщений (порог: 10000)"
labels:
severity: warning
# --- Alert: No Messages Produced ---
- uid: kafka_no_messages_produced
title: Kafka No Messages Produced
condition: C
data:
- refId: A
relativeTimeRange:
from: 600
to: 0
datasourceUid: prometheus_uid
model:
datasource:
type: prometheus
uid: prometheus_uid
editorMode: code
expr: rate(kafka_topic_partition_current_offset[5m])
instant: false
intervalMs: 1000
legendFormat: "{{ topic }}"
maxDataPoints: 43200
range: true
refId: A
- refId: B
datasourceUid: __expr__
model:
conditions:
- evaluator:
params: []
type: gt
operator:
type: and
query:
params:
- B
reducer:
params: []
type: last
type: query
datasource:
type: __expr__
uid: __expr__
expression: A
intervalMs: 1000
maxDataPoints: 43200
reducer: last
refId: B
type: reduce
- refId: C
datasourceUid: __expr__
model:
conditions:
- evaluator:
params:
- 0.1
type: lt
operator:
type: and
query:
params:
- C
reducer:
params: []
type: last
type: query
datasource:
type: __expr__
uid: __expr__
expression: B
intervalMs: 1000
maxDataPoints: 43200
refId: C
type: threshold
noDataState: NoData
execErrState: Error
for: 10m
annotations:
summary: "В топик {{ $labels.topic }} не поступают сообщения"
description: "Rate сообщений < 0.1 msg/sec в течение 10 минут"
labels:
severity: warning