# Apache Superset BI Platform

> Modern data exploration and visualization platform with SQL IDE.

- Category: Monitoring & Observability
- Difficulty: intermediate
- Components: superset, postgresql, redis, celery
- Tags: superset, bi, visualization, data-exploration, dashboards
- Source: https://docker.recipes/monitoring/apache-superset

## Overview

Apache Superset is a modern data exploration and visualization platform originally developed by Airbnb and later open-sourced under the Apache Software Foundation. It provides a rich web interface for creating interactive dashboards, exploring datasets through SQL Lab, and building complex visualizations without requiring extensive programming knowledge. Superset supports dozens of databases and data sources, making it a versatile business intelligence solution for organizations of all sizes.

This stack combines Superset with PostgreSQL as the metadata database, Redis for caching and session storage, and Celery workers for handling asynchronous tasks like report generation and alert processing. PostgreSQL stores Superset's configuration, user permissions, and dashboard metadata, while Redis accelerates chart rendering and manages user sessions. The Celery worker processes background jobs, preventing long-running queries or report exports from blocking the main web interface.

Data teams, analysts, and organizations seeking to democratize data access should consider this configuration. The combination provides enterprise-grade performance with Redis caching reducing dashboard load times, PostgreSQL ensuring data integrity for user management and metadata, and Celery workers enabling scalable report generation. This setup is particularly valuable for teams transitioning from expensive commercial BI tools or those needing a self-hosted alternative to cloud-based analytics platforms.

## Features

- SQL Lab IDE with syntax highlighting, query history, and result export capabilities
- Drag-and-drop dashboard builder with 50+ visualization types including maps and time-series charts
- Native database connectivity to PostgreSQL, MySQL, SQLite, and 30+ other data sources
- Redis-powered chart caching reducing dashboard load times by up to 80%
- Celery task queue for background report generation and scheduled dashboard exports
- Row-level security and column-level permissions using PostgreSQL's robust access control
- Real-time dashboard updates with WebSocket support and automatic refresh intervals
- Jinja templating in SQL queries for dynamic filtering and parameterized reports

## Use cases

- Business intelligence dashboards for sales, marketing, and operations teams
- Self-service analytics platform for non-technical users to explore company data
- Data exploration and visualization for data science teams working with large datasets
- Embedded analytics in SaaS applications using Superset's REST API and iframe embedding
- Real-time monitoring dashboards for application metrics and KPIs
- Financial reporting and compliance dashboards with scheduled PDF exports
- Customer-facing analytics portals with white-label customization options

## Prerequisites

- Docker and Docker Compose installed with at least 4GB RAM available for the stack
- Port 8088 available for Superset web interface access
- Basic SQL knowledge for creating queries and connecting to data sources
- Environment variables configured: SUPERSET_SECRET_KEY, POSTGRES credentials, ADMIN_PASSWORD
- Understanding of your target databases and their connection parameters
- Familiarity with business intelligence concepts like dimensions, measures, and filters

## docker-compose.yml

```yaml
services:
  superset:
    image: apache/superset:latest
    ports:
      - "8088:8088"
    environment:
      SUPERSET_SECRET_KEY: ${SUPERSET_SECRET_KEY}
      SQLALCHEMY_DATABASE_URI: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
      REDIS_HOST: redis
      REDIS_PORT: 6379
    volumes:
      - superset_home:/app/superset_home
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_started
    networks:
      - superset-net
    restart: unless-stopped
    command: >
      bash -c "superset db upgrade &&
               superset fab create-admin --username admin --firstname Admin --lastname User --email admin@example.com --password ${ADMIN_PASSWORD} || true &&
               superset init &&
               gunicorn --bind 0.0.0.0:8088 --workers 4 'superset.app:create_app()'"

  superset-worker:
    image: apache/superset:latest
    environment:
      SUPERSET_SECRET_KEY: ${SUPERSET_SECRET_KEY}
      SQLALCHEMY_DATABASE_URI: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
      REDIS_HOST: redis
      REDIS_PORT: 6379
    volumes:
      - superset_home:/app/superset_home
    depends_on:
      - superset
    command: celery --app=superset.tasks.celery_app:app worker --pool=prefork -O fair -c 4
    networks:
      - superset-net
    restart: unless-stopped

  postgres:
    image: postgres:16-alpine
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - superset-net
    restart: unless-stopped

  redis:
    image: redis:7-alpine
    volumes:
      - redis_data:/data
    networks:
      - superset-net
    restart: unless-stopped

volumes:
  superset_home:
  postgres_data:
  redis_data:

networks:
  superset-net:
    driver: bridge
```

## .env

```bash
# Superset Configuration
SUPERSET_SECRET_KEY=$(openssl rand -base64 42)
ADMIN_PASSWORD=secure_admin_password

# PostgreSQL
POSTGRES_USER=superset
POSTGRES_PASSWORD=secure_postgres_password
POSTGRES_DB=superset
```

## Usage notes

- Superset at http://localhost:8088
- Login with admin account created on startup
- Connect to your databases via SQL Lab
- Create dashboards and visualizations

## Troubleshooting

- Superset fails to start with 'cannot connect to database': Verify PostgreSQL container is healthy and SQLALCHEMY_DATABASE_URI environment variable is correct
- Dashboard charts load slowly or timeout: Check Redis container status and increase Celery worker count by modifying the '-c 4' parameter
- Permission denied when creating datasets: Ensure admin user was created successfully and check superset-worker container logs for Celery task failures
- 'Secret key not found' error: Generate a strong SUPERSET_SECRET_KEY using 'openssl rand -base64 42' and add to environment variables
- Database connection test fails in SQL Lab: Verify database driver compatibility and check if target database allows connections from Docker network IP range
- Charts show 'No data' despite successful queries: Clear Redis cache by restarting redis container and check for timezone mismatches in date fields

