AirflowDAGMonitor/zabbix/zbx_template_airflow_monitor.yaml
Maksim Totmin bc437cbf8c feat: добавил систему мониторинга Airflow DAG-ов с интеграцией в Zabbix
- автообнаружение Docker Airflow через docker inspect и .env
- мониторинг failed и long-running DAG-запусков с автоматическим retry
- экспорт данных в файлы для Zabbix Agent через UserParameter
- офлайн-сборка ZIP-архива для закрытых контуров
- Zabbix шаблоны для 5.x (XML) и 6.x+ (YAML)
- systemd сервис с graceful shutdown и lock file
2026-04-08 17:23:03 +07:00

289 lines
12 KiB
YAML
Raw Permalink 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.

zabbix_export:
version: '6.4'
template_groups:
- uuid: 846977d1dfed4968bc5f8bdb363285bc
name: 'Templates/Applications'
templates:
- uuid: a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6
template: 'Airflow DAG Monitor'
name: 'Airflow DAG Monitor'
description: |
Мониторинг Apache Airflow DAG-ов через сервис airflow-monitor.
Сервис пишет данные в файлы, Zabbix Agent читает через UserParameter.
Требования:
- Установлен airflow-monitor (/opt/airflow-monitor)
- Установлен конфиг /etc/zabbix/zabbix_agentd.conf.d/airflow-monitor.conf
- Перезапущен zabbix-agent после установки конфига
Версия шаблона: 1.0.0
groups:
- name: 'Templates/Applications'
items:
# ================================================================
# Основные items
# ================================================================
- uuid: 11111111111111111111111111111001
name: 'Airflow: Problematic DAGs (JSON)'
key: airflow.dag.problems
type: ZABBIX_PASSIVE
value_type: TEXT
delay: 1m
history: 7d
description: 'JSON-массив проблемных DAG-запусков. [] = нет проблем.'
tags:
- tag: component
value: airflow
- tag: component
value: dag-monitor
- uuid: 11111111111111111111111111111002
name: 'Airflow: Problematic DAGs count'
key: airflow.dag.problems.count
type: ZABBIX_PASSIVE
value_type: UNSIGNED
delay: 1m
history: 90d
trends: 365d
description: 'Количество DAG-запусков с проблемами (failed или long_running).'
tags:
- tag: component
value: airflow
- uuid: 11111111111111111111111111111003
name: 'Airflow Monitor: Heartbeat'
key: airflow.monitor.heartbeat
type: ZABBIX_PASSIVE
value_type: UNSIGNED
delay: 1m
history: 7d
description: 'Epoch timestamp последнего успешного цикла мониторинга.'
tags:
- tag: component
value: dag-monitor
- uuid: 11111111111111111111111111111004
name: 'Airflow Monitor: Status (JSON)'
key: airflow.monitor.status
type: ZABBIX_PASSIVE
value_type: TEXT
delay: 5m
history: 7d
description: 'JSON со статусом монитора: cycle_count, dag_count, issue_count, cycle_time.'
tags:
- tag: component
value: dag-monitor
- uuid: 11111111111111111111111111111005
name: 'Airflow Monitor: Service alive'
key: airflow.monitor.alive
type: ZABBIX_PASSIVE
value_type: UNSIGNED
delay: 1m
history: 90d
trends: 365d
description: '1 = сервис airflow-monitor запущен, 0 = остановлен.'
tags:
- tag: component
value: dag-monitor
# ================================================================
# Вычисляемые items (из heartbeat)
# ================================================================
- uuid: 11111111111111111111111111111006
name: 'Airflow Monitor: Data age (seconds)'
key: airflow.monitor.data_age
type: CALCULATED
value_type: UNSIGNED
delay: 1m
history: 7d
params: 'now()-last(//airflow.monitor.heartbeat)'
description: 'Сколько секунд прошло с последнего обновления данных.'
tags:
- tag: component
value: dag-monitor
# ================================================================
# Dependent items (извлечение из status JSON)
# ================================================================
- uuid: 11111111111111111111111111111010
name: 'Airflow Monitor: DAG count'
key: airflow.monitor.dag_count
type: DEPENDENT
value_type: UNSIGNED
history: 90d
trends: 365d
description: 'Количество отслеживаемых DAG-ов (из status.json).'
master_item:
key: airflow.monitor.status
preprocessing:
- type: JSONPATH
parameters:
- '$.dag_count'
- type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1h
tags:
- tag: component
value: airflow
- uuid: 11111111111111111111111111111011
name: 'Airflow Monitor: Cycle time (seconds)'
key: airflow.monitor.cycle_time
type: DEPENDENT
value_type: FLOAT
history: 90d
trends: 365d
description: 'Время выполнения последнего цикла мониторинга (секунды).'
master_item:
key: airflow.monitor.status
preprocessing:
- type: JSONPATH
parameters:
- '$.cycle_time_seconds'
tags:
- tag: component
value: dag-monitor
- uuid: 11111111111111111111111111111012
name: 'Airflow Monitor: Cycle count'
key: airflow.monitor.cycle_count
type: DEPENDENT
value_type: UNSIGNED
history: 90d
trends: 365d
description: 'Номер текущего цикла мониторинга (с момента запуска сервиса).'
master_item:
key: airflow.monitor.status
preprocessing:
- type: JSONPATH
parameters:
- '$.cycle_count'
- type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 1h
tags:
- tag: component
value: dag-monitor
# ==================================================================
# Triggers
# ==================================================================
triggers:
- uuid: 22222222222222222222222222222001
expression: 'last(/Airflow DAG Monitor/airflow.dag.problems.count)>0'
name: 'Airflow: {ITEM.LASTVALUE1} problematic DAG run(s) detected'
priority: HIGH
description: |
Обнаружены проблемные DAG-запуски (failed или long_running).
Подробности в item "Airflow: Problematic DAGs (JSON)".
Триггер снимается автоматически, когда все проблемы разрешены.
tags:
- tag: scope
value: availability
- tag: component
value: airflow
- uuid: 22222222222222222222222222222002
expression: 'last(/Airflow DAG Monitor/airflow.monitor.data_age)>600'
name: 'Airflow Monitor: Data is stale (no update for {ITEM.LASTVALUE1}s)'
priority: DISASTER
description: |
Данные мониторинга не обновлялись более 10 минут.
Возможные причины: сервис остановлен, Airflow API недоступен,
ошибка в цикле мониторинга.
dependencies:
- name: 'Airflow Monitor: Service is not running'
expression: 'last(/Airflow DAG Monitor/airflow.monitor.alive)=0'
tags:
- tag: scope
value: availability
- tag: component
value: dag-monitor
- uuid: 22222222222222222222222222222003
expression: 'last(/Airflow DAG Monitor/airflow.monitor.alive)=0'
name: 'Airflow Monitor: Service is not running'
priority: HIGH
description: |
Сервис airflow-monitor не запущен (systemctl is-active вернул не-active).
Запустить: sudo systemctl start airflow-monitor
tags:
- tag: scope
value: availability
- tag: component
value: dag-monitor
- uuid: 22222222222222222222222222222004
expression: 'last(/Airflow DAG Monitor/airflow.monitor.cycle_time)>60'
name: 'Airflow Monitor: Cycle time is high ({ITEM.LASTVALUE1}s)'
priority: WARNING
description: |
Цикл мониторинга выполняется дольше 60 секунд.
Возможные причины: большое количество DAG-ов, медленный API,
проблемы с сетью до Airflow.
tags:
- tag: scope
value: performance
- tag: component
value: dag-monitor
- uuid: 22222222222222222222222222222005
expression: 'last(/Airflow DAG Monitor/airflow.dag.problems.count)>0 and length(last(/Airflow DAG Monitor/airflow.dag.problems))>2'
recovery_mode: RECOVERY_EXPRESSION
recovery_expression: 'last(/Airflow DAG Monitor/airflow.dag.problems.count)=0'
name: 'Airflow: DAG failures require attention'
priority: AVERAGE
description: |
Есть проблемные DAG-запуски после попытки автоматического перезапуска.
Требуется ручное вмешательство.
tags:
- tag: scope
value: notice
- tag: component
value: airflow
# ==================================================================
# Graphs
# ==================================================================
graphs:
- uuid: 33333333333333333333333333333001
name: 'Airflow: Problem DAG count'
graph_items:
- color: FF0000
item:
host: 'Airflow DAG Monitor'
key: airflow.dag.problems.count
- color: 00AA00
yaxisside: RIGHT
item:
host: 'Airflow DAG Monitor'
key: airflow.monitor.dag_count
- uuid: 33333333333333333333333333333002
name: 'Airflow Monitor: Cycle time'
graph_items:
- color: 0000FF
item:
host: 'Airflow DAG Monitor'
key: airflow.monitor.cycle_time
- uuid: 33333333333333333333333333333003
name: 'Airflow Monitor: Data freshness'
graph_items:
- color: FF6600
item:
host: 'Airflow DAG Monitor'
key: airflow.monitor.data_age
# ==================================================================
# Macros (для тюнинга через host-level overrides)
# ==================================================================
macros:
- macro: '{$AIRFLOW.STALE_THRESHOLD}'
value: '600'
description: 'Порог устаревания данных (секунды). По умолчанию 10 минут.'
- macro: '{$AIRFLOW.CYCLE_TIME_WARN}'
value: '60'
description: 'Порог предупреждения о долгом цикле (секунды).'