Complete the code to import the SlackWebhookOperator in Airflow.
from airflow.providers.slack.operators.slack_webhook import [1]
The correct import for sending Slack messages in Airflow is SlackWebhookOperator.
Complete the code to create a SlackWebhookOperator task that sends a message to Slack.
notify_slack = SlackWebhookOperator(task_id='notify_slack', http_conn_id='[1]', message='Task completed!')
The http_conn_id should match the Airflow connection ID for the Slack webhook, commonly named slack_webhook_default.
Fix the error in the PagerDuty incident creation code by completing the operator name.
pagerduty_alert = [1](task_id='pagerduty_alert', routing_key='your_routing_key', event_action='trigger')
The correct operator to create PagerDuty incidents in Airflow is PagerDutyOperator.
Fill both blanks to create a DAG that sends a Slack notification and triggers a PagerDuty alert.
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
The Slack task uses the connection ID slack_webhook_default, and the PagerDuty task uses the PagerDutyOperator.
Fill all three blanks to create a dictionary comprehension that filters PagerDuty events with status 'triggered' and formats Slack messages.
messages = {event['id']: f"Alert: {event['description']}" for event in events if event['status'] [1] '[2]' and event['type'] [3] 'incident'}The comprehension filters events where status == 'triggered' and type == 'incident'.