Operations
What this does: Runs a dedicated health-check pipeline that monitors data freshness independently of model training — so data outages are caught immediately, even if the training pipeline is paused.
Overview
While the training pipeline (airflow_dag_enhanced) handles model updates, a separate, dedicated monitoring pipeline (dataset_monitoring_dag.py) runs continuously to ensure data health.
Separating monitoring from training ensures that even if the training pipeline fails, validation checks continue to run and potential data outages are detected immediately.
Monitoring DAG Architecture
Thedataset_monitoring_dag runs on an hourly schedule (Schedule: 0 * * * *) and performs the following checks:
1. S3 Timestamp Validation
The system does not just check “is data present?” but “how stale is it?”.- It queries the S3 bucket (
demand-forecasting) directly. - Compares the
LastModifiedtimestamp of key files against a configuredmax_age_hoursthreshold (e.g., 24h for raw data, 48h for models).
2. Metric Reporting
It generates a daily HTML email report sent at 8 AM UTC, summarizing:- Freshness: Which datasets were updated in the last 24h.
- Failures: Any validation checks that failed.
- Trend: Sparklines or logic indicating if data arrival is delayed compared to historical norms.
Critical vs. Non-Critical Alerts
The system distinguishes between dataset importance to avoid “alert fatigue”:Code Reference
The freshness logic is defined indataset_monitoring_dag.py:
Email Reporting Template
The system uses a Jinja2 template for its HTML reports, ensuring they are readable on mobile devices.- Green Status: All critical datasets fresh.
- Red Status: At least one critical dataset stale > 24h.
