- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
每当我的 DAG 中的任务无法运行或重试运行时,我都会尝试让 Airflow 使用 AWS SES 向我发送电子邮件。我也在使用我的 AWS SES 凭证,而不是我的通用 AWS 凭证。
我的当前 Airflow .cfg
[email]
email_backend = airflow.utils.email.send_email_smtp
[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 = emailsmtpserver.region.amazonaws.com
smtp_starttls = True
smtp_ssl = False
# Uncomment and set the user/pass settings if you want to use SMTP AUTH
smtp_user = REMOVEDAWSACCESSKEY
smtp_password = REMOVEDAWSSECRETACCESSKEY
smtp_port = 25
smtp_mail_from = myemail@myjob.com
testfaildag_library_install_jar_jdbc = PythonOperator(
task_id='library_install_jar',
retries=3,
retry_delay=timedelta(seconds=15),
python_callable=add_library_to_cluster,
params={'_task_id': 'cluster_create', '_cluster_name': CLUSTER_NAME, '_library_path':s3000://fakepath.jar},
dag=dag,
email_on_failure=True,
email_on_retry=True,
email=’myname@myjob.com’,
provide_context=True
)
on_failure_callback
调用 AWS 提供的 Python 脚本的函数
here在失败时发送电子邮件,但这不是此时的首选路线。
最佳答案
--使用 SES 更新 6/8
这是我写的关于我们如何让这一切正常工作的文章。这个答案的底部有一个小总结。
几个重点:
email_on_failure
提供服务的是 Airflow worker 和 email_on_retry
特征。你可以做journalctl –u airflow-worker –f
在 Dag 运行期间监控它。在您的生产服务器上,您无需在更改 airflow.cfg
后重新启动 Airflow 工作器。使用新的 smtp 设置 - 应该会自动提取。无需担心弄乱当前正在运行的 Dag。 airflow.cfg
中的 smtp 设置。 .
[email]
email_backend = airflow.utils.email.send_email_smtp
[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 = localhost
smtp_starttls = False
smtp_ssl = False
# Uncomment and set the user/pass settings if you want to use SMTP AUTH
#smtp_user = not used
#smtp_password = not used
smtp_port = 25
smtp_mail_from = myjob@mywork.com
socket.error: [Errno 111] Connection refused
-- 您必须更改您的 smtp_host
线在 airflow.cfg
至 localhost
smtplib.SMTPException: STARTTLS extension not supported by server.
-- 您必须更改您的 smtp_starttls
在 airflow.cfg
至 False
# Airflow imports
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
from airflow.operators.bash_operator import BashOperator
from airflow.operators.dummy_operator import DummyOperator
# General imports
from datetime import datetime,timedelta
def throwerror():
raise ValueError("Failure")
SPARK_V_2_2_1 = '3.5.x-scala2.11'
args = {
'owner': ‘me’,
'email': ['me@myjob'],
'depends_on_past': False,
'start_date': datetime(2018, 5,24),
'end_date':datetime(2018,6,28)
}
dag = DAG(
dag_id='testemaildag',
default_args=args,
catchup=False,
schedule_interval="* 18 * * *"
)
t1 = DummyOperator(
task_id='extract_data',
dag=dag
)
t2 = PythonOperator(
task_id='fail_task',
dag=dag,
python_callable=throwerror
)
t2.set_upstream(t1)
journalctl -u airflow-worker -f
,您可以看到工作人员说它已向您的 DAG 中的电子邮件发送了有关失败的警报电子邮件,但我们仍未收到该电子邮件。然后我们决定通过做
cat /var/log/maillog
来查看 sendmail 的邮件日志。 .我们看到了这样的日志:
Jun 5 14:10:25 production-server-ip-range postfix/smtpd[port]: connect from localhost[127.0.0.1]
Jun 5 14:10:25 production-server-ip-range postfix/smtpd[port]: ID: client=localhost[127.0.0.1]
Jun 5 14:10:25 production-server-ip-range postfix/cleanup[port]: ID: message-id=<randomMessageID@production-server-ip-range-ec2-instance>
Jun 5 14:10:25 production-server-ip-range postfix/smtpd[port]: disconnect from localhost[127.0.0.1]
Jun 5 14:10:25 production-server-ip-range postfix/qmgr[port]: MESSAGEID: from=<myjob@mycompany.com>, size=1297, nrcpt=1 (queue active)
Jun 5 14:10:55 production-server-ip-range postfix/smtp[port]: connect to aspmx.l.google.com[smtp-ip-range]:25: Connection timed out
Jun 5 14:11:25 production-server-ip-range postfix/smtp[port]: connect to alt1.aspmx.l.google.com[smtp-ip-range]:25: Connection timed out
email_on_failure
和
email_on_retry
在您的 DAG
API Reference 中默认为
True
- 如果您不想,则无需将其放入您的参数中,但在其中明确说明 True 或 False 仍然是一个好习惯)。
[email]
email_backend = airflow.utils.email.send_email_smtp
[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 = emailsmtpserver.region.amazonaws.com
smtp_starttls = True
smtp_ssl = False
# Uncomment and set the user/pass settings if you want to use SMTP AUTH
smtp_user = REMOVEDAWSACCESSKEY
smtp_password = REMOVEDAWSSECRETACCESSKEY
smtp_port = 587
smtp_mail_from = myemail@myjob.com (Verified SES email)
关于amazon-web-services - 在 Apache Airflow DAG 中使用 AWS SES 发送失败的电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50645578/
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
虽然 SES 仪表板显示了有关通过该服务发送的电子邮件的退回率的汇总统计信息,但我没有看到检索退回的单个地址的方法。这可能吗?我们的情况是,我们在某些电子邮件中设置的“发件人”地址不正确,并解析为我们
我正在使用 nodejs nodemailer 连接到 Amazon SES 电子邮件服务。这一切看起来很简单,但我不断收到错误消息: “我们计算的请求签名与您提供的签名不匹配。请检查您的 AWS s
在下面的代码中,我尝试了 2 种组合 用户(参见附图),密码 访问 ID 和访问 key 两者都给出了相同的错误。我在家庭网络的 eclipse 环境中运行了这段代码。 错误 Attempting t
我正在尝试制作一个可重用的 CloudFormation 模板,并且想要执行某种条件,如果环境参数为“test”(或“prod”以外的任何其他环境),则将 SES 电子邮件仅发送到 gmail帐户(即
我见过几个使用 Amazon SES 的 gem。但是,如果没有该 gem,我找不到亚马逊提供的任何 API 来构建服务。 如何在不使用 gem 的情况下完成 gem 的功能?这对我的应用非常重要,因
我在具有共享托管平台(不在 AWS 上)的网站上使用 AWS SES 当我使用 SMTP 发送电子邮件时,它运行良好。当我尝试调用和使用 API 时,没有发送电子邮件,也没有收到错误消息。 我想使用
我有一个 Amazon SES 连接设置,目前处于沙盒模式。 我有我的电子邮件地址,我使用真实的地址,但对于这篇文章,我们称之为 myemail@arealdomain.com .它已在 SES 中验
我们最近收到了一封来自亚马逊的电子邮件。 Hello, Amazon Web Services currently supports Amazon SES API requests that are
我是 Amazon SES 的新手,我发现有两种以编程方式发送电子邮件的方法: SES API ( http://docs.aws.amazon.com/ses/latest/DeveloperGui
因此,我设法创建了一个控制台应用程序,该应用程序引用以下链接通过SES发送电子邮件:https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send
我已经配置了Amazon SES,但是无法发送电子邮件。我收到未验证电子邮件的错误,但无法完成,因为该电子邮件在我拥有的另一个应用程序中运行正常。 这是错误: | Error com.amazonaw
我正在将.Net Core 1.2与Amazon SES(SimpleEmail)一起使用来发送电子邮件(原始电子邮件)。 以下是我们在.net Framework 4.5中使用的工作代码版本:
SES 不允许我进行身份验证。我可以在端口 25 上远程登录,但每当我在命令下方给出“AUTH LOGIN”时,连接就会丢失。 $ telnet.exe email-smtp.us-west-2.am
我已经改用 Amazon SES 从我们的 asp.net 系统发送我们的交易警报,我接到电话说人们收到了重复的电子邮件。 我已经确认我们的程序只向每个用户发送一次电子邮件。 我在第一封电子邮件发送后
是否可以回复我之前使用 AWS SES 发送给用户的电子邮件?我在文档中看不到任何可以实现这一点的内容。 所以我想: (1) 发送电子邮件至电子邮件地址 X (2) 回复来自 (1) 的电子邮件线程
我想知道从哪里开始设置每周个性化摘要以发送给我的用户(超过 20 万)。 它将提取特定于他们的内容,我们目前在带有 SQL 的 Windows EC2 实例上使用 SES 进行通知。 Windows
看来 Amazon SES 已开始支持接收电子邮件: http://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-cons
最近通过 Java Amazon SDK(v. 1.11.202),我将 1000 个 SendEmailRequests 排队到同一电子邮件地址。请求以 14/s 的速率排队,这是我的配额限制。没有
我们使用 aws 服务器,我们的应用程序通过亚马逊的简单电子邮件服务 (SES) 向客户发送电子邮件。 当收件人打开外出回复时,SES 将他们视为退回并在发送几次后阻止该电子邮件 ID。 这是 SES
我是一名优秀的程序员,十分优秀!