Send alerts from Airflow through Apprise
Context and Problem Statement
The maintainer wants a deployment that runs for years with no one watching it, and reports a problem by itself. Today a person finds a problem by opening the Ops collection in Metabase or by running ./agoranomos status. Until someone does, no one knows. A failed task is only a part of the problem: an account in quarantine, a late source and a full disk give no red task.
ADR-0021 says that the product sets up no email server, no Slack and no webhook for Metabase. An alert is an outgoing channel, so it gets a record of its own.
What notices a problem, what carries the message, and what may a message hold?
Decision Drivers
- A task that the kernel killed for its memory is noticed too: that is how tasks fail here.
- What is not a failed task, such as a quarantine or a full disk, is noticed as well.
- Any channel that a person uses, from Telegram to Slack or email, with one line of settings.
- No new service, and little memory.
- A secret of a channel stays out of the interface of Airflow.
- A message holds no text of a platform, which anyone can write.
- With no setting, nothing leaves the deployment.
Considered Options
For what delivers the message:
- The library Apprise, with the addresses in
.env - The provider of Apprise for Airflow
- Notifiers from the image of Airflow
- Alerts of Metabase on the questions of the Ops collection
- A module of our own over HTTP
For what notices a problem:
- A listener
on_dag_run_failedin a plugin, and a DAG that watches every 15 minutes on_failure_callbackon each task- A new service
Decision Outcome
Chosen options: "The library Apprise, with the addresses in .env" and "A listener on_dag_run_failed in a plugin, and a DAG that watches every 15 minutes", because one code serves every channel with the address out of reach of the interface of Airflow, and the listener is the one mechanism that also fires for a killed task, while the watcher sees what never fails.
In practice this means:
- The listener. A plugin in
airflow/plugins/, one for all the DAGs, those ofextensions/too. It runs in the scheduler, and is to work in both variants of the executor, of which only the LocalExecutor has been run. It sends in a background thread with a timeout, as a listener can slow a component down. - The watcher. A DAG every 15 minutes reads what does not look like a failure: accounts in quarantine, late sources, the status of a backup and the used disk. It sends only when a state changes, repeats once a day, and reports a recovery. The state lies in a table of
ops, so a channel does not fill with repeats. - Delivery.
AGORANOMOS_ALERT_URLSin.env, empty by default, and then nothing goes anywhere. One or more addresses of Apprise, such astgram://token/chat. Logs mask the value. - The content. A code of a reason from a fixed list, the identifier of an account and a time, with no amounts and no text of a platform: anyone can write the name of a campaign, and agents may read a message.
- The status of a backup comes from a small shared volume, as the folder of backups has mode 700 and no access for Airflow, and ADR-0020 rejected a DAG of backups, so that tasks get no passwords of the databases. The watcher sees the free disk through the volume of logs.
- Reach. The scheduler has a way out through the network
default, so a message can leave in both variants. The address in.envreaches tasks, those of a DAG inextensions/too, which is the code of the deployment itself. - Alerts of Metabase stay for people, for questions about the business, such as a client's spend that rose. That works today when a deployment sets up its own email or Slack. They do not become a channel of the system.
- What it cannot do. If the server is off or the scheduler is dead, nothing inside can report it. There is no outside check of liveness: only the silence and the dashboard say so.
The other options were not chosen for these reasons:
- The provider of Apprise keeps the address in a Connection, which the role Op can change: the same risk for which dlt does not read Variables. It also needs a callback on each DAG.
- Notifiers of the image need code and settings for each channel, and a provider of its own with
python-telegram-botfor Telegram. - Alerts of Metabase have no direct Telegram. The body of a webhook is set by code and holds rows and a picture of a chart, so data leaves; a webhook is for admins only; an alert repeats on each check; Slack needs an app of its own and email SMTP; a backup and a disk are out of its sight; and when Metabase falls, it is silent. It would, though, also work when Airflow is dead.
- A module of our own needs retries, rate limits, the masking of tokens and care for each channel, and the product needs the channels of all its users.
on_failure_callbackof a task does not fire for a killed task, as it runs in the process of that task. A new service costs memory that the budget of ADR-0022 does not have.
Consequences
- Good, because a deployment reports a problem by itself, on the channel of its user.
- Good, because a killed task is noticed, which is how tasks fail here.
- Good, because a message holds no text from a platform, so it carries no injection.
- Good, because nothing leaves by default.
- Bad, because Apprise is a new dependency, of 9 MB, and takes 20 MiB in a process for the time of a send.
- Bad, because a server that is off stays silent, so the absence of messages proves nothing.
- Bad, because a listener in the scheduler is one more thing that runs there, and the documentation warns of that.
- Bad, because a message says little, and a person has to go to Ops or an agent for the reason.
More Information
- Implementation status, as of November 2026: built for v0.5: the plugin
airflow/plugins/agoranomos_alerts.pywith the listeneron_dag_run_failedand Apprise 1.13.1, the DAGagoranomos_watcherevery 15 minutes with its state inops.alert_state, the status of the backups in the volumebackup-status, andAGORANOMOS_ALERT_URLSin.env, with the stack tests of both variants (Get alerts). The cleanup of the logs of Airflow came before, in the DAGagoranomos_maintenance. -
The facts behind this record, run on 31 October 2026 on the image of the stack, Airflow 3.3.2, with one task that raises an exception, one killed by signal 9 and one that succeeds:
Mechanism Exception in a task Process of a task killed Runs in on_failure_callbackof a taskFired Did not fire The process of the task Listener on_task_instance_failedFired Did not fire The process of the task on_failure_callbackof a DAGFired Fired dag-processorListener on_dag_run_failedFired Fired The scheduler - A send through Apprise 1.13.1 from
on_dag_run_failed, in a background thread: the listener returned in 0.7 ms, a message with Cyrillic reached a local address, an unreachable address took 2 s with a timeout ofcto=2, and the scheduler went on. The constraints of Airflow 3.3.2 hold Apprise 1.13.1 (constraints), under BSD-2-Clause (Apprise). - Airflow on listeners, callbacks and notifications. Metabase on webhooks and alerts; its body of a webhook is in
src/metabase/channel/impl/http.cljat the tag v0.64.1. - Not checked yet:
- A real send to Slack: the stack tests send to a local address only.
- Checked on a deployment, on 16 November 2026, on v0.5.0 with the LocalExecutor (Docker Engine on Ubuntu 24.04, amd64): the test alert of Get alerts, sent from the scheduler to an address
tgram://of a bot, printedTrue, the log of Apprise saidSent Telegram notification., and the message reached the chat. - Checked with the code, on 7 November 2026, on a Mac (Docker Desktop, arm64): the listener on the CeleryExecutor sent the alert of a task that the worker ran and that killed itself with signal 9, from the scheduler, as on the LocalExecutor; the scheduler of the CeleryExecutor peaked at 322 MiB of its 640 MiB in those stack tests, with Apprise imported.
- Related decisions: ADR-0021 does not change, as alerts leave from Airflow and not from Metabase. Quarantine is in ADR-0035, and the plugins in
airflow/plugins/follow the base package (ADR-0013). - Revisit this record when a deployment needs an outside check of liveness, or when Airflow offers a built-in channel for every provider.
- A send through Apprise 1.13.1 from