This sample code demonstrates using Metabase static embedding in Ruby using Sinatra.
- Have a running instance of Metabase. If you don't have one
- A dashboard to embed. If you don't have one, use X-Rays to let Metabase create one for you. Note down the dashboard id.
- Sign in to your Metabase instance as an admin.
- Go to admin settings and enabling embedding.
- Under admin settings/embedding, click on static embedding and copy the embedding secret key.
- Paste the secret key into an env var:
$ export METABASE_EMBEDDING_SECRET="PASTE_SECRET_HERE"
- Create an env var pointing to your Metabase site URL, if it's not on http://localhost:3000
$ export METABASE_SITE_URL="http://localhost:4000"
- Create an env var with the ID of the dashboard to embed:
$ export METABASE_EMBED_DASHBOARD_ID="8"
- Go to your dashboard, click on the share/embed button at the top
- Click on the "Publish" button
- Install the dependencies:
$ bundle install
- Start the server:
$ ruby app.rb
- Open the app in your browser at http://localhost:4567