AirflowDAGMonitor/zabbix/zbx_template_airflow_monitor_5x.xml
Maksim Totmin f3e1ad7df3 fix: экспорт всех текущих проблем в Zabbix + совместимость шаблона с Zabbix 5.0
collect_and_alert теперь экспортирует ВСЕ текущие проблемные DAG-и,
а не только новые — Zabbix видит проблему пока DAG не починен.

Zabbix XML шаблон: version 5.0, убраны tags, preprocessing params,
triggers/graphs вынесены на верхний уровень, history 7d / trends 365d.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 10:11:27 +07:00

267 lines
11 KiB
XML
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.

<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>5.0</version>
<groups>
<group>
<name>Templates/Applications</name>
</group>
</groups>
<templates>
<template>
<template>Airflow DAG Monitor</template>
<name>Airflow DAG Monitor</name>
<description>Мониторинг Apache Airflow DAG-ов через сервис airflow-monitor.&#13;
Сервис пишет данные в файлы, Zabbix Agent читает через UserParameter.&#13;
&#13;
Требования:&#13;
- Установлен airflow-monitor (/opt/airflow-monitor)&#13;
- Установлен конфиг /etc/zabbix/zabbix_agentd.conf.d/airflow-monitor.conf&#13;
&#13;
Версия шаблона: 1.0.1 (Zabbix 5.0)</description>
<groups>
<group>
<name>Templates/Applications</name>
</group>
</groups>
<items>
<!-- Problematic DAGs JSON -->
<item>
<name>Airflow: Problematic DAGs (JSON)</name>
<key>airflow.dag.problems</key>
<delay>1m</delay>
<history>7d</history>
<value_type>TEXT</value_type>
<description>JSON-массив проблемных DAG-запусков. [] = нет проблем.</description>
</item>
<!-- Problematic DAGs count -->
<item>
<name>Airflow: Problematic DAGs count</name>
<key>airflow.dag.problems.count</key>
<delay>1m</delay>
<history>7d</history>
<trends>365d</trends>
<value_type>UNSIGNED</value_type>
<description>Количество DAG-запусков с проблемами.</description>
</item>
<!-- Heartbeat -->
<item>
<name>Airflow Monitor: Heartbeat</name>
<key>airflow.monitor.heartbeat</key>
<delay>1m</delay>
<history>7d</history>
<trends>365d</trends>
<value_type>UNSIGNED</value_type>
<description>Epoch timestamp последнего успешного цикла мониторинга.</description>
</item>
<!-- Status JSON -->
<item>
<name>Airflow Monitor: Status (JSON)</name>
<key>airflow.monitor.status</key>
<delay>5m</delay>
<history>7d</history>
<value_type>TEXT</value_type>
<description>JSON со статусом монитора.</description>
</item>
<!-- Service alive -->
<item>
<name>Airflow Monitor: Service alive</name>
<key>airflow.monitor.alive</key>
<delay>1m</delay>
<history>7d</history>
<trends>365d</trends>
<value_type>UNSIGNED</value_type>
<description>1 = сервис запущен, 0 = остановлен.</description>
<valuemap>
<name>Service state</name>
</valuemap>
</item>
<!-- DAG count (dependent from status) -->
<item>
<name>Airflow Monitor: DAG count</name>
<type>DEPENDENT</type>
<key>airflow.monitor.dag_count</key>
<history>7d</history>
<trends>365d</trends>
<value_type>UNSIGNED</value_type>
<description>Количество отслеживаемых DAG-ов.</description>
<master_item>
<key>airflow.monitor.status</key>
</master_item>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.dag_count</params>
</step>
<step>
<type>DISCARD_UNCHANGED_HEARTBEAT</type>
<params>1h</params>
</step>
</preprocessing>
</item>
<!-- Cycle time (dependent from status) -->
<item>
<name>Airflow Monitor: Cycle time (seconds)</name>
<type>DEPENDENT</type>
<key>airflow.monitor.cycle_time</key>
<history>7d</history>
<trends>365d</trends>
<value_type>FLOAT</value_type>
<units>s</units>
<description>Время выполнения последнего цикла мониторинга.</description>
<master_item>
<key>airflow.monitor.status</key>
</master_item>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.cycle_time_seconds</params>
</step>
</preprocessing>
</item>
<!-- Cycle count (dependent from status) -->
<item>
<name>Airflow Monitor: Cycle count</name>
<type>DEPENDENT</type>
<key>airflow.monitor.cycle_count</key>
<history>7d</history>
<trends>365d</trends>
<value_type>UNSIGNED</value_type>
<description>Номер текущего цикла мониторинга.</description>
<master_item>
<key>airflow.monitor.status</key>
</master_item>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.cycle_count</params>
</step>
<step>
<type>DISCARD_UNCHANGED_HEARTBEAT</type>
<params>1h</params>
</step>
</preprocessing>
</item>
</items>
<macros>
<macro>
<macro>{$AIRFLOW.STALE_THRESHOLD}</macro>
<value>600</value>
<description>Порог устаревания данных (секунды).</description>
</macro>
<macro>
<macro>{$AIRFLOW.CYCLE_TIME_WARN}</macro>
<value>60</value>
<description>Порог предупреждения о долгом цикле (секунды).</description>
</macro>
</macros>
</template>
</templates>
<triggers>
<!-- Problematic DAGs detected -->
<trigger>
<expression>{Airflow DAG Monitor:airflow.dag.problems.count.last()}&gt;0</expression>
<recovery_expression></recovery_expression>
<name>Airflow: {ITEM.LASTVALUE1} problematic DAG run(s) detected</name>
<priority>HIGH</priority>
<description>Обнаружены проблемные DAG-запуски (failed или long_running).&#13;
Подробности в item "Airflow: Problematic DAGs (JSON)".&#13;
Триггер снимается автоматически при разрешении всех проблем.</description>
</trigger>
<!-- Heartbeat stale -->
<trigger>
<expression>{Airflow DAG Monitor:airflow.monitor.heartbeat.nodata(600)}=1 or (({Airflow DAG Monitor:airflow.monitor.heartbeat.last()}&gt;0) and ({Airflow DAG Monitor:airflow.monitor.heartbeat.fuzzytime(600)}=0))</expression>
<name>Airflow Monitor: Data is stale (no update for 10+ minutes)</name>
<priority>DISASTER</priority>
<description>Данные мониторинга не обновлялись более 10 минут.&#13;
Возможные причины: сервис остановлен, Airflow API недоступен.</description>
<dependencies>
<dependency>
<name>Airflow Monitor: Service is not running</name>
<expression>{Airflow DAG Monitor:airflow.monitor.alive.last()}=0</expression>
</dependency>
</dependencies>
</trigger>
<!-- Service down -->
<trigger>
<expression>{Airflow DAG Monitor:airflow.monitor.alive.last()}=0</expression>
<name>Airflow Monitor: Service is not running</name>
<priority>HIGH</priority>
<description>Сервис airflow-monitor не запущен.&#13;
Запустить: sudo systemctl start airflow-monitor</description>
</trigger>
<!-- Slow cycle -->
<trigger>
<expression>{Airflow DAG Monitor:airflow.monitor.cycle_time.last()}&gt;60</expression>
<name>Airflow Monitor: Cycle time is high ({ITEM.LASTVALUE1}s)</name>
<priority>WARNING</priority>
<description>Цикл мониторинга выполняется дольше 60 секунд.</description>
</trigger>
</triggers>
<graphs>
<!-- Problem count graph -->
<graph>
<name>Airflow: Problem DAG count</name>
<graph_items>
<graph_item>
<color>FF0000</color>
<item>
<host>Airflow DAG Monitor</host>
<key>airflow.dag.problems.count</key>
</item>
</graph_item>
<graph_item>
<color>00AA00</color>
<yaxisside>RIGHT</yaxisside>
<item>
<host>Airflow DAG Monitor</host>
<key>airflow.monitor.dag_count</key>
</item>
</graph_item>
</graph_items>
</graph>
<!-- Cycle time graph -->
<graph>
<name>Airflow Monitor: Cycle time</name>
<graph_items>
<graph_item>
<color>0000FF</color>
<item>
<host>Airflow DAG Monitor</host>
<key>airflow.monitor.cycle_time</key>
</item>
</graph_item>
</graph_items>
</graph>
</graphs>
<value_maps>
<value_map>
<name>Service state</name>
<mappings>
<mapping>
<value>0</value>
<newvalue>Stopped</newvalue>
</mapping>
<mapping>
<value>1</value>
<newvalue>Running</newvalue>
</mapping>
</mappings>
</value_map>
</value_maps>
</zabbix_export>