A DAG (Directed Acyclic Graph) is a collection of tasks organized in a way that reflects their relationships and dependencies. It defines the order in which tasks run.
Click to reveal answer
beginner
Why is tracking DAG performance important?
Tracking DAG performance helps identify slow tasks, bottlenecks, and failures. This allows improving workflow efficiency and reliability.
Click to reveal answer
intermediate
Which Airflow UI feature helps monitor DAG run durations?
The Airflow UI's 'Graph View' and 'Tree View' show task durations and statuses, helping track how long each task and DAG run takes.
Click to reveal answer
intermediate
How can you programmatically track DAG performance?
You can use Airflow's REST API or query the metadata database to get DAG run and task instance durations and statuses for performance analysis.
Click to reveal answer
advanced
What is the role of Airflow's metrics exporter in DAG performance tracking?
Airflow's metrics exporter sends performance data like task durations and success rates to monitoring tools like Prometheus for alerting and dashboards.
Click to reveal answer
What does DAG stand for in Airflow?
ADistributed Application Gateway
BData Analysis Group
CDirected Acyclic Graph
DDynamic Automated Generator
✗ Incorrect
DAG stands for Directed Acyclic Graph, which is a structure defining task dependencies in Airflow.
Which Airflow UI view shows task durations and statuses?
AConfig View
BCode View
CLog View
DGraph View
✗ Incorrect
Graph View visually displays tasks with their durations and statuses, helping track performance.
How can you access DAG run performance data programmatically?
ARestarting Airflow scheduler
BUsing Airflow's REST API
CEditing DAG Python files
DUsing Airflow CLI to delete DAGs
✗ Incorrect
Airflow's REST API allows fetching DAG run and task instance data for performance tracking.
What is a common use of Airflow metrics exporter?
ASending performance data to monitoring tools
BDeploying new DAGs automatically
CBacking up DAG files
DScheduling DAG runs manually
✗ Incorrect
Metrics exporter sends performance metrics to tools like Prometheus for monitoring.
Explain how you would monitor the performance of a DAG in Airflow using the UI and programmatic methods.
Think about both visual and data-driven ways to track performance.
You got /3 concepts.
Describe the benefits of integrating Airflow metrics with external monitoring tools.
Consider how external tools improve visibility and response.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of tracking DAG performance in Airflow?
easy
A. To measure how long workflows and tasks take to run
B. To change the order of tasks in a DAG
C. To create new DAGs automatically
D. To delete old task logs
Solution
Step 1: Understand DAG performance tracking
DAG performance tracking focuses on measuring execution times of workflows and tasks.
Step 2: Identify the main goal
The goal is to find how long tasks and DAG runs take to help improve pipeline speed.
Final Answer:
To measure how long workflows and tasks take to run -> Option A
Quick Check:
DAG performance tracking = measuring run times [OK]
Hint: Think: performance means measuring speed or time [OK]
Common Mistakes:
Confusing performance tracking with task ordering
Thinking it creates or deletes DAGs
Mixing logs management with performance tracking
2. Which Airflow model stores information about individual task execution times?
easy
A. DagRun
B. Variable
C. TaskInstance
D. Connection
Solution
Step 1: Identify models related to execution times
DagRun stores info about the whole DAG run, TaskInstance stores info about each task run.
Step 2: Match model to task execution time
TaskInstance tracks start and end times for each task, so it holds execution time data.
Final Answer:
TaskInstance -> Option C
Quick Check:
TaskInstance = task execution info [OK]
Hint: TaskInstance = single task run details [OK]
Common Mistakes:
Choosing DagRun which tracks whole DAG, not tasks
Confusing Variables or Connections with timing data
Assuming all info is in one model
3. Given this code snippet, what will be printed?
from airflow.models import TaskInstance
from datetime import datetime, timedelta
start = datetime(2024, 6, 1, 10, 0, 0)
end = datetime(2024, 6, 1, 10, 5, 30)
ti = TaskInstance(dag_id='example_dag', task_id='task1', execution_date=start)
ti.start_date = start
ti.end_date = end
print((ti.end_date - ti.start_date).total_seconds())
medium
A. 5.5
B. 330
C. SyntaxError
D. 330.0
Solution
Step 1: Identify variable name mismatch
The code assigns TaskInstance to 'ti' but prints using 'ti', which is correct. However, the code snippet uses 'ti' consistently, so no mismatch here.
Step 2: Check for syntax errors
The code is syntactically correct, but the TaskInstance constructor requires a DAG object or context in recent Airflow versions, so this code may raise a runtime error.
Step 3: Consider the actual output
Assuming the code runs, the output would be 330.0 seconds.
Final Answer:
330.0 -> Option D
Quick Check:
5 min 30 sec = 330.0 seconds [OK]
Hint: Subtract datetimes, use total_seconds() for float seconds [OK]
Common Mistakes:
Confusing minutes with seconds
Expecting integer instead of float
Syntax errors from missing imports (not here)
4. You wrote this code to get task duration but it raises an error: