0
0
Apache Airflowdevops~10 mins

Integration with PagerDuty and Slack in Apache Airflow - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the SlackWebhookOperator in Airflow.

Apache Airflow
from airflow.providers.slack.operators.slack_webhook import [1]
Drag options to blanks, or click blank then click option'
ASlackOperator
BSlackWebhookOperator
CSlackHook
DSlackWebhookHook
Attempts:
3 left
💡 Hint
Common Mistakes
Using SlackOperator which is deprecated.
Confusing Hook and Operator classes.
2fill in blank
medium

Complete the code to create a SlackWebhookOperator task that sends a message to Slack.

Apache Airflow
notify_slack = SlackWebhookOperator(task_id='notify_slack', http_conn_id='[1]', message='Task completed!')
Drag options to blanks, or click blank then click option'
Aslack_webhook_default
Bslack_connection
Cpagerduty_connection
Dhttp_default
Attempts:
3 left
💡 Hint
Common Mistakes
Using the PagerDuty connection ID instead of Slack.
Using a generic HTTP connection ID.
3fill in blank
hard

Fix the error in the PagerDuty incident creation code by completing the operator name.

Apache Airflow
pagerduty_alert = [1](task_id='pagerduty_alert', routing_key='your_routing_key', event_action='trigger')
Drag options to blanks, or click blank then click option'
APagerDutyHook
BPagerDutyAlertOperator
CPagerDutyOperator
DPagerDutyIncidentOperator
Attempts:
3 left
💡 Hint
Common Mistakes
Using PagerDutyHook which is not an operator.
Using incorrect operator names that do not exist.
4fill in blank
hard

Fill both blanks to create a DAG that sends a Slack notification and triggers a PagerDuty alert.

Apache Airflow
with DAG('alert_dag', start_date=days_ago(1), schedule_interval='@daily') as dag:
    slack_task = SlackWebhookOperator(task_id='slack_notify', http_conn_id='[1]', message='Alert from DAG')
    pagerduty_task = [2](task_id='pagerduty_alert', routing_key='your_routing_key', event_action='trigger')
    slack_task >> pagerduty_task
Drag options to blanks, or click blank then click option'
Aslack_webhook_default
BPagerDutyHook
CPagerDutyOperator
Dslack_connection
Attempts:
3 left
💡 Hint
Common Mistakes
Using PagerDutyHook instead of PagerDutyOperator.
Using wrong Slack connection ID.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that filters PagerDuty events with status 'triggered' and formats Slack messages.

Apache Airflow
messages = {event['id']: f"Alert: {event['description']}" for event in events if event['status'] [1] '[2]' and event['type'] [3] 'incident'}
Drag options to blanks, or click blank then click option'
A==
Btriggered
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' instead of '==' for filtering.
Using wrong status or type values.