# Metabase Analytics Platform

> Metabase BI tool with PostgreSQL backend for self-service analytics.

- Category: Database Stacks
- Difficulty: beginner
- Components: metabase, postgresql
- Tags: metabase, bi, analytics, dashboard, visualization
- Source: https://docker.recipes/databases/metabase-analytics

## Overview

Metabase is an open-source business intelligence platform that transforms raw data into interactive dashboards, reports, and visualizations without requiring SQL knowledge. Created in 2015, Metabase democratizes data analytics by providing a user-friendly interface that enables non-technical users to explore data, create charts, and build comprehensive dashboards through intuitive drag-and-drop functionality. Its self-service approach eliminates the bottleneck of waiting for technical teams to generate reports, empowering business users to answer their own questions with data.

This configuration pairs Metabase with PostgreSQL as its application database, creating a robust analytics platform where PostgreSQL stores Metabase's metadata, user accounts, dashboard definitions, and cached query results. PostgreSQL's advanced SQL capabilities, ACID compliance, and excellent performance characteristics make it an ideal backend for Metabase's complex metadata operations and concurrent user sessions. The combination leverages PostgreSQL's reliability for storing critical business intelligence configurations while Metabase connects to your various data sources for analysis.

This stack serves organizations seeking to implement self-service business intelligence without the complexity and cost of enterprise BI solutions like Tableau or Power BI. Small to medium businesses, startups with growing data needs, and teams requiring quick insights from multiple databases will find this combination particularly valuable. The setup provides enterprise-grade analytics capabilities while maintaining the flexibility to scale and integrate with existing data infrastructure.

## Features

- Interactive dashboard builder with 40+ visualization types including maps, funnels, and pivot tables
- SQL query interface with visual query builder for users without SQL expertise
- Automated email and Slack alerts based on data thresholds and schedules
- Multi-database connectivity supporting MySQL, PostgreSQL, MongoDB, BigQuery, and 20+ other sources
- User permission system with collection-based access control and row-level security
- Embedded analytics with signed embedding for integrating dashboards into applications
- PostgreSQL-powered metadata storage ensuring ACID compliance for user configurations and cached results
- Mobile-responsive dashboards accessible on tablets and smartphones

## Use cases

- SaaS companies tracking key metrics like MRR, churn rate, and user engagement across multiple databases
- E-commerce businesses monitoring sales performance, inventory levels, and customer behavior analytics
- Marketing teams analyzing campaign performance, lead conversion rates, and ROI across advertising platforms
- Operations teams creating real-time dashboards for monitoring system performance and business KPIs
- Financial reporting and budget tracking with automated monthly and quarterly report generation
- Customer success teams monitoring product usage, support ticket trends, and user satisfaction metrics
- Startups needing affordable business intelligence without licensing costs of enterprise BI tools

## Prerequisites

- Minimum 2GB RAM recommended for concurrent users and dashboard rendering performance
- Port 3000 available for Metabase web interface access
- Basic understanding of your data sources and connection credentials for database setup
- 10GB+ disk space for PostgreSQL data storage and Metabase query caching
- Network access to external databases you plan to connect for analysis
- Docker and Docker Compose installed with ability to run persistent containers

## docker-compose.yml

```yaml
services:
  postgres:
    image: postgres:16-alpine
    container_name: metabase-postgres
    restart: unless-stopped
    environment:
      POSTGRES_USER: ${POSTGRES_USER:-metabase}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-metabase}
      POSTGRES_DB: ${POSTGRES_DB:-metabase}
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - metabase-network

  metabase:
    image: metabase/metabase:latest
    container_name: metabase
    restart: unless-stopped
    ports:
      - "${METABASE_PORT:-3000}:3000"
    environment:
      MB_DB_TYPE: postgres
      MB_DB_DBNAME: ${POSTGRES_DB:-metabase}
      MB_DB_PORT: 5432
      MB_DB_USER: ${POSTGRES_USER:-metabase}
      MB_DB_PASS: ${POSTGRES_PASSWORD:-metabase}
      MB_DB_HOST: postgres
    depends_on:
      - postgres
    networks:
      - metabase-network

volumes:
  postgres_data:

networks:
  metabase-network:
    driver: bridge
```

## .env

```bash
# Metabase
METABASE_PORT=3000
POSTGRES_USER=metabase
POSTGRES_PASSWORD=metabase
POSTGRES_DB=metabase
```

## Usage notes

- Metabase at http://localhost:3000
- Complete setup wizard on first run
- Connect your data sources in settings
- Create dashboards with drag-and-drop

## Troubleshooting

- Metabase shows 'Database connection failed' on startup: Check PostgreSQL container is fully initialized before Metabase starts, increase depends_on or add health checks
- Out of memory errors during large query execution: Increase Docker container memory limits and adjust MB_JETTY_MAXTHREADS environment variable
- Slow dashboard loading with multiple charts: Enable Metabase query caching and consider upgrading PostgreSQL shared_buffers configuration
- Setup wizard redirects to localhost instead of server IP: Set MB_SITE_URL environment variable to your server's actual hostname or IP address
- PostgreSQL connection pool exhausted errors: Adjust MB_DB_CONNECTION_TIMEOUT and ensure PostgreSQL max_connections setting accommodates concurrent users

