Integrating PostHog with your Metabase instance.
Why is this useful?
Metabase is an open-source data explorer and Business Intelligence tool that lets you derive insights and build charts from your data with ease.
To follow this tutorial along, you should:
- Have deployed PostHog.
Integrating with Metabase currently works only for self-hosted PostHog instances. Additionally, since Metabase does not support ClickHouse, you are only able to integrate it directly with your PostHog database if your PostHog instance uses PostgreSQL for event data (i.e. you're not using our Enterprise Edition).
If you're on EE, we still use Postgres for certain types of data which you could explore with Metabase, but you'll have no access to event data, for example. If using Metabase is essential to you, you could export the ClickHouse data to another Metabase-supported database.
Download and run Metabase (it's free!)
The easiest way to get started is with the Docker one-liner, getting you from 0 to Metabase in about 1 minute:docker run -d -p 3000:3000 --name metabase metabase/metabase
Running Metabase will start a server running in port 3000, but you can change this if you prefer to use another port. Access your instance by navigating to
This will open up a Metabase setup page where you can select your preferred language and create a new user.
Connecting to PostHog
After you've create your user, Metabase will prompt you with a screen to connect to a database:
On this screen, you should select 'PostgreSQL' as the database, and add the details of your PostHog instance.
If you're hosting Metabase and PostHog on the same server, your can use
localhostas your 'Host'. Otherwise, this should be the address of your PostHog instance.
Unless you have made changes to this during deployment, PostgreSQL listens on port 5432 by default.
The username you used to create your database. Read the next section if your deployed PostHog with Docker.
The password you used to create your database. Read the next section if your deployed PostHog with Docker.
Finish the setup and you're ready to start using Metabase! By default, the platform will already give you some views for the available data, but it's up to you how to go from there.
For PostHog Docker deployments
If you deployed PostHog with Docker, some additional setup is necessary to make the connection with Metabase work.
For security reasons, with our standard Docker deployment, we do not expose a port to connect to the database from outside the Docker container. As such, you need to edit your
docker-compose.yml file to do this.
First, you need to add a port mapping and a secure password to your
services:db:container_name: posthog_dbenvironment:POSTGRES_DB: posthogPOSTGRES_PASSWORD: <your_db_password_here>POSTGRES_USER: posthogimage: postgres:alpinevolumes:- postgres-data:/var/lib/postgresql/dataports: # Add port mapping here- 5432:5432# ...
Pro tip: You can generate a secure password with the following command:
openssl rand -hex 32
You can also change the username by modifying the
Then, you need to update your
web service according to the credential changes you just made, like so:
# ...web:container_name: posthog_webdepends_on:- db- redisenvironment:DATABASE_URL: postgres://<new_username>:<new_password>@db:5432/posthog# ...
After restarting your container, your Postgres intance should now be accessible from outside, so you can connect to it from Metabase.