The Forex Data Pipeline(Email Notification)

우상욱·2024년 3월 10일
0

Airflow

목록 보기
13/22

이메일 등록


데이터 파이프라인에서 이메일을 통해서, 실패 혹은 retry에 대한 이메일을 받도록 구성할 수 있습니다.

구글 이메일 앱 등록

  • 해당 링크에서 앱을 생성합니다.
  • 생성된 앱 이름과 비밀번호를 활용합니다.
  • airflow.cfg 파일을 수정합니다.
[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.gmail.com
smtp_starttls = True
smtp_ssl = False
# Example: smtp_user = airflow
smtp_user = {구글 이메일 주소}
# Example: smtp_password = airflow
smtp_password = {발급 받은 앱 비밀번호에서, 띄어쓰기 제외한 문자열}
smtp_port = 587
smtp_mail_from = {구글 이메일 주소}
smtp_timeout = 30
smtp_retry_limit = 5

Airflow Script


yop mail을 통해서 테스트해봅니다.

from airflow.operators.email import EmailOperator

    send_email_notification = EmailOperator(
        task_id="send_email_notification",
        to="airflow_course@yopmail.com",
        subject="forex_data_pipeline",
        html_content="<h3>forex_data_pipeline</h3>",
    )

https://yopmail.com/

profile
데이터엔지니어

0개의 댓글