Skip to main content
Integrate AnomalyArmor with Apache Airflow to gate pipelines on data quality and freshness.

Installation

Install the SDK in your Airflow environment:

Configuration

Set ARMOR_API_KEY as an Airflow variable or environment variable:

Pre-flight Freshness Check

The most common pattern: fail the task if upstream data is stale.
Use read-only scope for pre-flight checks. You only need read-write if triggering refreshes.

Check Multiple Sources

Verify all upstream dependencies before running:

Trigger Freshness Check

Trigger a freshness check and wait for completion:

Sensor Pattern

Wait for data to become fresh:

Check Lineage

Verify all upstream dependencies using lineage:

Error Handling

Handle different error types appropriately:

Complete DAG Example

Full example with freshness gate, transformation, and post-run schema check:

Next Steps

Common Questions

How do I gate an Airflow DAG on data freshness using AnomalyArmor?

Use a PythonSensor or PythonOperator at the start of your DAG that calls client.freshness.check(table="...") from the AnomalyArmor Python SDK. If freshness is violated, raise an exception to short-circuit the DAG. See the “Gating DAGs” section above for a full example.

Does the AnomalyArmor Python SDK work with Airflow 2 and MWAA?

Yes. The SDK is a pure-Python package (pip install anomalyarmor) and works in any Airflow environment that supports pip-installed dependencies: Airflow 2.x, Astronomer, MWAA, and Airflow on Kubernetes. MWAA requires adding the package to requirements.txt.

Where should I store my AnomalyArmor API key in Airflow?

In an Airflow Connection (Extra JSON field) or a Variable - never in DAG code. For MWAA, use AWS Secrets Manager with Airflow’s Secrets Backend so keys rotate without redeploying DAGs.

Can AnomalyArmor trigger Airflow DAG runs when data quality fails?

Yes via webhooks. Configure an AnomalyArmor alert with a webhook destination pointing at Airflow’s REST API (e.g., POST /api/v1/dags/{dag_id}/dagRuns). Most teams use this pattern to trigger remediation DAGs when a critical freshness or schema-drift alert fires.

Python SDK

SDK reference and patterns

Freshness API

Freshness endpoint details

Lineage API

Explore data dependencies

Alerts

Set up freshness alerts