Self-hosted business intelligence with Metabase

By Karolis Rusenas · Nov 11, 2021

Metabase

It is always useful to know how your business or projects are doing and for that, there are a bunch of tools available such as Excel spreadsheets, Google DataStudio, Apache Superset, etc. I personally am a fan of Metabase as it is the easiest to deploy and use. When paired with the right technologies, this setup becomes trivial to anything from a small organization to a big company.

In this article, we will use a setup that works exactly the same way on both an Intel NUC (for some of my projects) and on a large VM that is managed by a VMware.

Prerequisites

  • Webhook Relay account - will be used to expose the Metabase to the internet, so we can access it.
  • Synpse account - a lightweight and fantastic platform to manage and run software on your own hardware. Offers management of up to 5 devices for free.

1. Install Synpse into your server/machine

Once you log into Synpse Cloud, select your project and then head to the “Devices” page. From there you will be able to find the auto-generated command that you need to run on the device to add it to your project.

There are multiple ways to do it however initially you can just SSH into the machine via local network. Once you run the command, after a few seconds (depends on your internet speed) you should see the magic happen and device appear in your “Devices” page in Synpse :)

2. Create a Webhook Relay tunnel for your Metabase app

Our Metabase deployment will need to be reachable from outside so we can actually view reports. For this, we are creating a Webhook Relay tunnel that will be established by a webhookrelayd container.

Go to your https://my.webhookrelay.com/tunnels page and create a new tunnel with these details:

  • name: ‘whr-metabase’ (webhookrelayd agent will need to know which tunnel to use)
  • destination: ‘http://metabase:3000' (metabase is reachable using container’s name)

3. Get your access token key and secret

Head to the tokens page here https://my.webhookrelay.com/tokens and create a new pair. Save the key and secret before closing the window.

Go to the secrets page in Synpse and create both relayKey and relaySecret secrets:

Create Synpse secrets

4. Deploy Metabase via Synpse

Last step is to create a Synpse application.

name: metabase
description: metabase + WHR
scheduling:
  type: Conditional
  selectors:
    type: controller
spec:
  containers:
    - name: metabase
      image: metabase/metabase:latest
      volumes:
        - /data/metabase:/metabase-data
      env:
        - name: MB_DB_FILE
          value: /metabase-data/metabase.db
        - name: MB_REDIRECT_ALL_REQUESTS_TO_HTTPS
          value: "false"
    - name: relayd
      image: webhookrelay/webhookrelayd:1
      args:
        - --mode
        - tunnel
        - -t
        - whr-metabase # <--- if you have chosen a different name for the tunnel, change it here too
      env:
        - name: RELAY_KEY
          fromSecret: relayKey
        - name: RELAY_SECRET
          fromSecret: relaySecret

Once deployed, use your tunnel URL to access it. You can also configure Google OAuth to make the login easier, however that’s out of scope in this article.

Enjoy!