# Python Sample: ETL Healthcheck Runner ```python from datetime import datetime, timedelta import pyodbc WARNING_MINUTES = 30 CRITICAL_MINUTES = 60 connection = pyodbc.connect( "Driver={ODBC Driver 18 for SQL Server};" "Server=tcp:server.database.windows.net,1433;" "Database=etlops;" "Uid=user;" "Pwd=password;" "Encrypt=yes;TrustServerCertificate=no;" ) query = """ SELECT PipelineName, MAX(CompletedAtUtc) AS LastRunUtc FROM dbo.PipelineRunAudit GROUP BY PipelineName; """ now_utc = datetime.utcnow() with connection.cursor() as cursor: cursor.execute(query) for pipeline_name, last_run in cursor.fetchall(): age_minutes = (now_utc - last_run).total_seconds() / 60.0 if age_minutes >= CRITICAL_MINUTES: status = "CRITICAL" elif age_minutes >= WARNING_MINUTES: status = "WARNING" else: status = "HEALTHY" print(f"{pipeline_name}: {status} ({age_minutes:.0f} min since last run)") ``` Use this pattern to: - Detect stalled ETL pipelines. - Flag warning and critical thresholds. - Feed alerts into email, Teams, or ticketing workflows.