Enterprise Data Governance, Lineage Tracking, SLO Alerting & Centralized Logging for FMCG Real-Time Analytics
- Project Overview
- System Architecture & Data Flow
- Core Features
- Tech Stack
- Directory Structure
- Quick Start Guide
- Service Endpoints
- dbt Lineage Model
- Alert Rules & SLO Definitions
- Troubleshooting
This project implements the Governance & Observability layer for the FMCG Real-Time Analytics Platform (Project A). It operates as a companion repository that connects to Project A's running infrastructure via a shared Docker network to provide:
- Data Catalog & Lineage — OpenMetadata scans PostgreSQL, ClickHouse, and Trino schemas from Project A, while OpenLineage captures transformation lineage from dbt runs.
- Data Transformation — dbt models clean and aggregate raw POS transaction data into analytics-ready mart tables, orchestrated by Apache Airflow.
- Pipeline SLO Alerting — Prometheus scrapes Airflow DAG metrics via StatsD Exporter and routes critical alerts (DAG failures, SLO breaches) to Slack via AlertManager.
- Centralized Logging — Loki + Promtail aggregate Docker container logs from both projects into a single queryable store, visualized on Grafana dashboards using LogQL.
| Dimension | Description |
|---|---|
| Problem | Raw data assets in the analytics platform (Project A) lack documentation, lineage tracking, quality testing, and centralized operational monitoring. Debugging production issues requires SSH-ing into individual containers. |
| Solution | Deploy a governance stack that automatically catalogs all database schemas (OpenMetadata), tracks data lineage from raw → staging → mart (OpenLineage + dbt), monitors pipeline SLOs with threshold-based alerting (Prometheus + AlertManager → Slack), and centralizes all container logs (Loki + Promtail → Grafana). |
| Result | Full metadata catalog with automated lineage graph covering 3 data sources. Pipeline failures trigger Slack alerts within 30 seconds. Centralized log search reduces debugging time from container-level SSH to a single Grafana query. All 14 services orchestrated via make up with zero manual configuration. |
This stack connects to Project A via the shared Docker network fmcg_fmcg-network, enabling container-to-container communication by hostname.
┌────────────────────────────────────────────────────────────────────────┐
│ PROJECT A (Data Infrastructure — FMCG Analytics Platform) │
│ ┌─────────────┐ ┌──────────────┐ ┌─────────┐ ┌──────────────────┐ │
│ │ fmcg-postgres│ │fmcg-clickhouse│ │fmcg-trino│ │ fmcg-kafka │ │
│ │ :5432 │ │ :8123 │ │ :8080 │ │ :29092 │ │
│ └──────┬───────┘ └──────┬───────┘ └────┬─────┘ └──────────────────┘ │
│ │ │ │ │
│ └────────────────┼──────────────┘ │
│ │ Docker Network: fmcg_fmcg-network │
└──────────────────────────┼──────────────────────────────────────────────┘
│ (Connect & Observe)
┌──────────────────────────┼──────────────────────────────────────────────┐
│ PROJECT B (Governance & Observability Stack) │
│ │ │
│ ┌───────────────────────▼────────────────────────────────────────────┐ │
│ │ DATA CATALOG & LINEAGE │ │
│ │ OpenMetadata ◄── Metadata Ingestion (Postgres, CH, Trino) │ │
│ │ ▲ │ │
│ │ │ OpenLineage Events │ │
│ │ Airflow DAGs ──► dbt run ──► staging ──► mart tables │ │
│ └───────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────── PIPELINE SLO ALERTING ─────────────────────┐ │
│ │ Airflow ──► StatsD ──► Prometheus ──► AlertManager ──► Slack │ │
│ │ (metrics) (9125) (9095) (9093) │ │
│ └───────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────── CENTRALIZED LOGGING ───────────────────────┐ │
│ │ Docker Containers ──► Promtail ──► Loki ──► Grafana Dashboard │ │
│ │ (Project A + B) (auto-discover) (3100) (LogQL panels) │ │
│ └───────────────────────────────────────────────────────────────────┘ │
└────────────────────────────────────────────────────────────────────────┘
raw_fmcg.pos_transactions (Project A PostgreSQL)
│
└──► stg_pos_transactions (view)
│ - Region name mapping (HN → Hà Nội, HCM → TP. Hồ Chí Minh...)
│ - Time dimension extraction (date, hour, day_of_week)
│ - Transaction tier classification (high/medium/low value)
│
├──► mart_sales_by_region (table)
│ Daily revenue, units, and transaction mix by region + category
│
└──► mart_product_performance (table)
Product ranking by revenue within category, daily revenue share %
OpenMetadata connects directly to Project A's databases via the shared Docker network and automatically discovers table schemas, column types, and descriptions. Scheduled ingestion pipelines keep the catalog up-to-date without manual intervention.
When Airflow triggers dbt run, the OpenLineage provider automatically emits lineage events to OpenMetadata's HTTP listener. The result is a visual lineage graph tracing data flow from raw source tables through staging views to aggregated mart tables.
Airflow emits operational metrics via StatsD (DAG duration, task success/failure counts, scheduler heartbeat). Prometheus evaluates alert rules against these metrics. When a DAG fails or exceeds the 5-minute SLO, AlertManager routes a formatted notification to the configured Slack channel within 30 seconds.
Promtail auto-discovers Docker containers from both projects using the Docker socket, extracts log streams, and tags them by project (project-a / project-b), service name, and detected log level. A pre-built Grafana dashboard provides 9 panels for real-time error monitoring and log volume analysis using LogQL.
- OpenMetadata 1.6.5 — Open-source data catalog with automated metadata ingestion and lineage visualization.
- OpenLineage — Standard API for lineage event collection from Airflow and dbt.
- Apache Airflow 2.9.3 — DAG-based workflow orchestrator running dbt models on schedule.
- dbt-postgres 1.8.2 — SQL-based transformation framework building staging and mart layers.
- Prometheus — Time-series database scraping Airflow metrics via StatsD Exporter.
- AlertManager — Alert routing engine with Slack webhook integration.
- Grafana Loki 2.9.9 — Log aggregation engine optimized for label-based querying (LogQL).
- Promtail 2.9.9 — Log shipping agent using Docker service discovery.
data-platform-governance/
├── docker-compose.yml # Root orchestrator (includes all service stacks)
├── .env.example # Environment variables template
├── Makefile # 25+ operational commands for full lifecycle
├── README.md # This file
│
├── dbt/
│ └── fmcg_transformation/ # dbt project for data transformation
│ ├── dbt_project.yml # Project configuration
│ ├── profiles.yml # Connection to Project A PostgreSQL (env vars)
│ └── models/
│ ├── staging/
│ │ ├── _sources.yml # Source definitions + data quality tests
│ │ └── stg_pos_transactions.sql # Clean, enrich, classify raw data
│ └── marts/
│ ├── mart_sales_by_region.sql # Regional sales aggregation
│ └── mart_product_performance.sql # Product ranking & revenue share
│
├── scripts/
│ └── init_postgres_source.sql # Bootstrap: create table & seed 5,000 records
│
└── services/
├── openmetadata/ # Phase 1: Data Catalog
│ └── docker-compose.yml # MySQL + Elasticsearch + Server + Ingestion
│
├── airflow/ # Phase 2: Orchestration & Transformation
│ ├── docker-compose.yml # Postgres + Init + Webserver + Scheduler
│ ├── Dockerfile # Custom image: Airflow + dbt + OpenLineage
│ ├── requirements.txt # Python dependencies
│ └── dags/
│ ├── dbt_fmcg_transformation.py # 7-step dbt pipeline DAG
│ └── seed_pos_transactions.py # Bootstrap data seeder DAG
│
├── alerting/ # Phase 3: SLO Alerting
│ ├── docker-compose.yml # StatsD Exporter + Prometheus + AlertManager
│ └── config/
│ ├── prometheus.yml # Scrape targets configuration
│ ├── alert_rules.yml # 4 alert rules (DAG fail, SLO, scheduler, task rate)
│ ├── alertmanager.yml # Slack routing with severity-based channels
│ ├── statsd-mapping.yml # Airflow StatsD → Prometheus metric mapping
│ └── templates/
│ └── slack.tmpl # Slack message formatting template
│
└── logging/ # Phase 4: Centralized Logging
├── docker-compose.yml # Loki + Promtail
├── config/
│ ├── loki-config.yml # Storage, retention, and schema configuration
│ └── promtail-config.yml # Docker service discovery & log labeling
└── grafana/
├── dashboards/
│ └── centralized_logs.json # 9-panel Grafana dashboard
└── provisioning/
├── dashboards/dashboards.yaml
└── datasources/loki.yaml # Loki datasource for Grafana
- Docker and Docker Compose (v2+) installed.
- Project A (
fmcg-real-time-analytics) running with the Docker networkfmcg_fmcg-networkactive.
# Clone the repository
git clone https://github.com/phatle224/data-platform-governance.git
cd data-platform-governance
# Copy environment template
cp .env.example .env
# (Optional) Update SLACK_WEBHOOK_URL in .env for Slack alertingEnsure Project A is running, then seed the PostgreSQL source table:
# Verify Project A network is available
make check-network
# Create pos_transactions table and insert 5,000 sample records
make init-postgres# Start all 14 services (OpenMetadata, Airflow, Alerting, Logging)
make up
# Wait ~2-3 minutes, then verify health
make status# Copy Loki datasource + Log dashboard into Project A's Grafana
make provision-grafana# Verify dbt can reach Project A's PostgreSQL
make dbt-debug
# Execute transformations: staging → mart
make dbt-run
# Run data quality tests
make dbt-testThe transformation pipeline reads raw POS transaction data from Project A's PostgreSQL and produces analytics-ready tables:
| Model | Type | Description |
|---|---|---|
stg_pos_transactions |
View | Cleans raw data, maps region codes to Vietnamese names, extracts time dimensions, classifies transaction value tiers |
mart_sales_by_region |
Table | Daily sales aggregation by region, product category, and store type with revenue percentages |
mart_product_performance |
Table | Product-level metrics with intra-category revenue ranking and daily revenue share percentage |
- Source tests:
transaction_iduniqueness & not-null,categoryaccepted values,regionaccepted values - Staging tests:
transaction_iduniqueness,total_amountnot-null - Mart tests:
transaction_datenot-null,total_revenuenot-null
| Alert Name | Severity | Condition | Action |
|---|---|---|---|
AirflowDagFailed |
🔴 Critical | Any DAG run fails within 5 minutes | Slack notification (immediate) |
PipelineSLOViolated |
🟡 Warning | Average DAG runtime exceeds 300 seconds | Slack notification (1 min buffer) |
AirflowSchedulerDown |
🔴 Critical | StatsD exporter unreachable for 2 minutes | Slack notification (immediate) |
HighDagTaskFailureRate |
🟡 Warning | Task failure rate exceeds 20% over 15 minutes | Slack notification (5 min buffer) |
-
Error:
fmcg_fmcg-network NOT found- Cause: Project A is not running.
- Fix: Start Project A first:
cd D:\project\fmcg-real-time-analytics && make up
-
Error: OpenMetadata cannot connect to
fmcg-postgres- Cause: The OpenMetadata container is not on the shared network.
- Fix: Verify the
fmcg-networksection inservices/openmetadata/docker-compose.ymlhasexternal: true.
-
Error: Airflow DAG import errors
- Cause: dbt packages not installed in the custom Airflow image.
- Fix: Rebuild the image:
docker compose build airflow-webserver airflow-scheduler
-
Error: Promtail cannot discover containers
- Cause: Docker socket not mounted correctly (common on Windows).
- Fix: Ensure Docker Desktop is running and the volume mount
//var/run/docker.sock:/var/run/docker.sock:rois accessible.
-
Error: AlertManager not sending Slack notifications
- Cause:
SLACK_WEBHOOK_URLin.envis still the placeholder value. - Fix: Create a Slack Incoming Webhook at api.slack.com/messaging/webhooks and update the URL in
.env.
- Cause: