1. TOP
  2. Raspberry Pi
  3. Setup
  4. Metabase

日本語 English

Metabase Setup (Raspberry Pi)

Metabase is an open-source BI tool that turns database data into graphs and tables in the browser. You can create summary screens without writing SQL, so it is convenient for quickly visualizing PLC data recorded in MariaDB.

This page describes the steps to run Metabase on a Raspberry Pi and connect it to MariaDB on the same Raspberry Pi. Everything stays within the company LAN with no internet connection.

Prerequisite: this assumes the static IP and MariaDB setup (creating testDB and testuser) have been completed following "Initial Setup and Server Construction".
If you also want to view it from outside or on a smartphone, consider "Grafana Cloud (free tier)", which runs in the cloud.

Environment

ItemDescription
HardwareRaspberry Pi 4 Model B(4GB)
OSRaspberry Pi OS(64-bit)
JavaEclipse Temurin 25(JRE)
MetabaseOSS edition (jar file)
Accesshttp://192.168.0.100:3000/
Metabase runs on Java and uses a lot of memory (about 1 GB after startup). Run it on a Raspberry Pi 4/5 with 4 GB or more.

Installing Java 25

The latest Metabase requires Java 25. It is not in the standard Raspberry Pi OS repositories, so install it from the Eclipse Temurin (Adoptium) repository.

$ sudo apt install -y wget apt-transport-https gpg
$ wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/adoptium.gpg > /dev/null
$ echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | sudo tee /etc/apt/sources.list.d/adoptium.list
$ sudo apt update
$ sudo apt install -y temurin-25-jre
$ /usr/lib/jvm/temurin-25-jre-arm64/bin/java -version
The default-jdk (Java 17) installed in the initial setup remains as is, and only Metabase runs on the Java 25 at the path above. Older versions of Metabase (v0.43 etc.) also work with Java 17.

Download and check operation

Here, create a metabase directory in the home of user pi and put the jar file in it.

$ mkdir -p ~/metabase
$ cd ~/metabase
$ wget -O metabase.jar https://downloads.metabase.com/latest/metabase.jar

To download with a browser, get it from the Metabase official site (OSS edition) and copy it to the directory above.

First start it manually to check operation (stop with Ctrl+C).

$ /usr/lib/jvm/temurin-25-jre-arm64/bin/java -jar metabase.jar

Open http://192.168.0.100:3000/ in a browser on your PC. The first startup takes a few minutes on a Raspberry Pi, so wait until the log shows "Metabase Initialization COMPLETE".

Autostart as a service

Creating the unit definition file

Register it as a systemd service so it starts automatically when the Raspberry Pi boots.

$ sudo nano /etc/systemd/system/metabase.service
/etc/systemd/system/metabase.service
[Unit]
Description=Metabase server
After=network-online.target mariadb.service
Wants=network-online.target

[Service]
WorkingDirectory=/home/pi/metabase
ExecStart=/usr/lib/jvm/temurin-25-jre-arm64/bin/java -Xmx1g -jar /home/pi/metabase/metabase.jar
# Environment variable file (port change etc.). The leading "-" means no error if the file does not exist
EnvironmentFile=-/etc/default/metabase
User=pi
Type=simple
SyslogIdentifier=metabase
SuccessExitStatus=143
TimeoutStopSec=120
Restart=always

[Install]
WantedBy=multi-user.target
-Xmx1g is the upper limit of memory used by Metabase. It is a guideline for running alongside other services on a 4 GB model, so adjust it to your environment.
To change the port from 3000, write something like MB_JETTY_PORT=8080 in /etc/default/metabase.

Registering and starting the service

$ sudo systemctl daemon-reload
$ sudo systemctl enable --now metabase.service
$ systemctl status metabase.service

Checking logs

On current Raspberry Pi OS, logs can be checked with journald (the systemd log).

$ journalctl -u metabase -f

If you want to write logs to a file with rsyslog as on older OSes, install rsyslog and add routing settings.

$ sudo apt install -y rsyslog
$ sudo nano /etc/rsyslog.d/metabase.conf
/etc/rsyslog.d/metabase.conf
if $programname == 'metabase' then /var/log/metabase.log
& stop
$ sudo systemctl restart rsyslog

Connecting to MariaDB

After creating an admin user on the Metabase initial setup screen, enter the following under "Add a database" to graph MariaDB data.

ItemSetting
Database typeMySQL (choose this for MariaDB too)
Hostlocalhost
Port3306
Database nametestDB
Username/passwordtestuser/passwd

Summary

Now, just by opening http://192.168.0.100:3000/ in a browser on a PC in the company LAN, you can check PLC data recorded in MariaDB as tables and graphs.
Create graphs with Metabase "Questions" and combine them in a "Dashboard" to check equipment status on one screen.

Related pages

Initial Setup and Server Construction

Initial setup and server construction

Setup steps for static IP, Apache, PHP and MariaDB

Grafana Cloud Free Tier Setup

Grafana Cloud (free tier)

Visualize the Raspberry Pi's MariaDB from Grafana in the cloud without opening ports

What Is a Raspberry Pi?

What is a Raspberry Pi

Introduces the history, specs of current models and PLC integration configurations

Reference

Raspberry Pi is a trademark of Raspberry Pi Ltd.

Comments