Logo of patwoz.de

Redash with Coolify

In this guide, we’ll walk through setting up Redash using Coolify, a platform that simplifies the deployment of containerized applications. Redash is a powerful tool for querying databases and visualizing data, making it great for analytics. Coolify will help you run Redash in a containerized environment using Docker Compose.

Docker Compose File

We’ll start with the docker-compose.yml file for Redash, which includes Redash services, Redis, and Postgres (with automatic upgrades).

x-redash-service:
  image: 'redash/redash:latest'
  depends_on:
    - postgres
    - redis
  restart: always
services:
  server:
    image: 'redash/redash:latest'
    depends_on:
      - postgres
      - redis
    restart: always
    command: server
    environment:
      REDASH_WEB_WORKERS: 4
  scheduler:
    image: 'redash/redash:latest'
    depends_on:
      - server
    restart: always
    command: scheduler
  scheduled_worker:
    image: 'redash/redash:latest'
    depends_on:
      - server
    restart: always
    command: worker
    environment:
      QUEUES: 'scheduled_queries,schemas'
      WORKERS_COUNT: 1
  adhoc_worker:
    image: 'redash/redash:latest'
    depends_on:
      - server
    restart: always
    command: worker
    environment:
      QUEUES: queries
      WORKERS_COUNT: 2
  redis:
    image: 'redis:7-alpine'
    restart: unless-stopped
  postgres:
    image: 'pgautoupgrade/pgautoupgrade:latest'
    volumes:
      - '/opt/redash/postgres-data:/var/lib/postgresql/data'
    restart: unless-stopped
  worker:
    image: 'redash/redash:latest'
    depends_on:
      - postgres
      - redis
    restart: always
    command: worker
    environment:
      QUEUES: 'periodic,emails,default'
      WORKERS_COUNT: 1

Explanation:

  • Redash services: Includes server, scheduler, scheduled_worker, adhoc_worker, and worker with specific roles for handling queries, scheduling, and periodic tasks.
  • Redis: A lightweight and fast in-memory data structure store, required for Redash.
  • Postgres: The PostgreSQL database service that Redash will use to store data. This setup uses the pgautoupgrade image for automated upgrades.
  • Volumes: Data from Postgres is persisted in the /opt/redash/postgres-data directory.

Environment Variables

Next, you need to define the environment variables for Redash. Some sensitive fields (like secrets) should be filled with random values, which you can generate with tools like pwgen.

PYTHONUNBUFFERED=0
REDASH_LOG_LEVEL=INFO
REDASH_REDIS_URL=redis://redis:6379/0
REDASH_COOKIE_SECRET=
REDASH_SECRET_KEY=
POSTGRES_PASSWORD=
REDASH_DATABASE_URL=postgresql://postgres:__POSTGRES_PASSWORD__@postgres/postgres
REDASH_ENFORCE_CSRF=true
REDASH_GUNICORN_TIMEOUT=60

Filling the Variables:

  • REDASH_COOKIE_SECRET and REDASH_SECRET_KEY: These should be securely generated random strings. You can generate them with pwgen -1s 32.
  • POSTGRES_PASSWORD: Set a password for your PostgreSQL database.
  • REDASH_DATABASE_URL: Replace POSTGRES_PASSWORD with your chosen PostgreSQL password from the previous step.

Make sure to update these values in your Coolify environment settings.

Initialize the database

After setting up the containers and services, you need to create the necessary database tables for Redash.

  1. Go to Execute Command in Coolify’s interface.
  2. Select the container labeled server-<someid>.
  3. Enter the following command to create the database tables:
/app/manage.py database create_tables

This will set up the required tables and make the Redash instance functional.

Configure the server

Now, let’s finalize the server configuration:

  1. Navigate to the Service Stack section in Coolify.
  2. Under Services, select Server.
  3. In the Settings tab, find the Domains field and enter a domain name for your Redash instance. This will be the public URL where your Redash instance will be accessible.

Done!

That’s it! You have successfully deployed Redash using Coolify. You can now access Redash via the domain you configured, start connecting databases, and run your queries. If you run into any issues or need additional configurations, check the Redash documentation for further guidance. Done