我正在尝试使用此处找到的 LocalExecutor.yml 文件运行 puckel Airflow docker 容器:
https://github.com/puckel/docker-airflow
我无法让 Airflow 向我发送失败或重试的电子邮件。
我尝试了以下方法:
[smtp]
# If you want airflow to send emails on retries, failure, and you want to use
# the airflow.utils.email.send_email_smtp function, you have to configure an
# smtp server here
smtp_host = smtp@mycompany.com
smtp_starttls = True
smtp_ssl = False
# Uncomment and set the user/pass settings if you want to use SMTP AUTH
# smtp_user = airflow
# smtp_password = airflow
smtp_port = 25
smtp_mail_from = myname@mycompany.com
: "${AIRFLOW__SMTP__SMTP_HOST:="smtp-host"}"
: "${AIRFLOW__SMTP__SMTP_PORT:="25"}"
# Defaults and back-compat
: "${AIRFLOW_HOME:="/usr/local/airflow"}"
: "${AIRFLOW__CORE__FERNET_KEY:=${FERNET_KEY:=$(python -c "from cryptography.fernet import Fernet; FERNET_KEY = Fernet.generate_key().decode(); print(FERNET_KEY)")}}"
: "${AIRFLOW__CORE__EXECUTOR:=${EXECUTOR:-Sequential}Executor}"
export \
AIRFLOW_HOME \
AIRFLOW__CELERY__BROKER_URL \
AIRFLOW__CELERY__RESULT_BACKEND \
AIRFLOW__CORE__EXECUTOR \
AIRFLOW__CORE__FERNET_KEY \
AIRFLOW__CORE__LOAD_EXAMPLES \
AIRFLOW__CORE__SQL_ALCHEMY_CONN \
AIRFLOW__SMTP__SMTP_HOST \
AIRFLOW__SMTP__SMTP_PORT \
if [ "$AIRFLOW__SMTP__SMTP_HOST" != "smtp-host" ]; then
AIRFLOW__SMTP__SMTP_HOST="smtp-host"
AIRFLOW__SMTP__SMTP_PORT=25
fi
我目前正在运行一个故意失败的 dag,但我从未收到重试或失败的警报。
最佳答案
您不需要执行步骤 1 和 2。在 docker-compose.yml 中指定环境变量。
此外,请确保您已在 Operator 中启用失败时发送电子邮件,
喜欢这里:https://gist.githubusercontent.com/aawgit/0753b3ef1d715257e442ceafbc8583d3/raw/fa45caa9150e08654d476c2d619ab50615942b46/email-notification-on-task-failure.py
关于docker - 使用 docker 容器中的 Airflow 发送失败/重试电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58736009/