How to Install Metabase and Use It with Mautic

If you’re looking to take your analytics to the next level, integrating Metabase with your Mautic instance is a powerful way to do just that. Metabase is an open-source business intelligence tool that lets you visualize your marketing data without writing code. Once connected, you’ll be able to generate clean dashboards, track KPIs, and get deeper insights into your Mautic campaigns.

🔧 Step 1: Preparing Your Server Environment

First, make sure your server is up to date:

sudo apt update && sudo apt upgrade -y

Then, install Nginx and MariaDB:

sudo apt install nginx mariadb-server mariadb-client -y
sudo systemctl enable nginx
sudo systemctl start nginx
sudo systemctl enable mariadb
sudo systemctl start mariadb

Secure your MariaDB installation:

sudo mysql_secure_installation

Test Nginx:

nginx -v

📁 Step 2: Configure Nginx

Remove the default config:

sudo rm /etc/nginx/sites-enabled/default

Create a basic default config:

sudo nano /etc/nginx/conf.d/default.conf

Paste the following:

server {
  listen 80;
  listen [::]:80;
  server_name _;

  root /usr/share/nginx/html/;
  index index.php index.html index.htm;

  location / {
    try_files $uri $uri/ /index.php;
  }

  location ~ \.php$ {
    fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    include snippets/fastcgi-php.conf;
  }

  location ~* \.(jpg|jpeg|gif|png|webp|svg|woff2?|ttf|css|js|ico|xml)$ {
    access_log off;
    log_not_found off;
    expires 360d;
  }

  location ~ /\.ht {
    deny all;
  }
}

Then reload Nginx:

sudo nginx -t && sudo systemctl restart nginx

Set up Nginx to always restart:

sudo mkdir -p /etc/systemd/system/nginx.service.d/
sudo nano /etc/systemd/system/nginx.service.d/restart.conf

Paste:

[Service]
Restart=always
RestartSec=5s

Reload systemd:

sudo systemctl daemon-reload

☕ Step 3: Install Java

Metabase runs on Java. Install it using:

sudo apt install default-jre default-jdk -y
java -version

📦 Step 4: Download and Set Up Metabase

wget https://downloads.metabase.com/v0.43.3/metabase.jar
sudo mkdir -p /opt/metabase
sudo mv metabase.jar /opt/metabase/
cd /opt/metabase
sudo mv metabase.jar metabase.jar

🗄️ Step 5: Create the Metabase Database

sudo mysql -u root -p

Inside the MySQL prompt:

CREATE DATABASE metabase DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
GRANT ALL ON metabase.* TO 'metabase_user'@'localhost' IDENTIFIED BY 'M3t4B4s3';
FLUSH PRIVILEGES;
EXIT;

🌐 Step 6: Configure Nginx for Metabase

Paste your server block (replace domain accordingly):

server {
    listen 80;
    listen [::]:80;
    server_name bi.yourdomain.com;

    access_log  /var/log/nginx/bi.access.log;
    error_log   /var/log/nginx/bi.error.log warn;

    location / {
        proxy_pass http://127.0.0.1:3000/;
    }
}
Reload Nginx:
sudo nginx -t && sudo systemctl restart nginx

🔒 Step 7: Secure with SSL (Let’s Encrypt)

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email your@email.com -d bi.yourdomain.com

⚙️ Step 8: Run Metabase as a Service

Create a log file:

sudo touch /var/log/metabase.log
sudo chown syslog:adm /var/log/metabase.log
Environment config:
sudo touch /etc/default/metabase
sudo chmod 640 /etc/default/metabase

Add the following environment variables:

sudo nano /etc/default/metabase
MB_PASSWORD_COMPLEXITY=normal
MB_PASSWORD_LENGTH=10
MB_JETTY_HOST=127.0.0.1
MB_JETTY_PORT=3000
MB_DB_TYPE=mysql
MB_DB_DBNAME=metabase
MB_DB_PORT=3306
MB_DB_USER=metabase_user
MB_DB_PASS=M3t4B4s3
MB_DB_HOST=localhost
MB_EMOJI_IN_LOGS=true

Create the systemd service file:

sudo nano /etc/systemd/system/metabase.service

Paste:

[Unit]
Description=Metabase server
After=syslog.target
After=network.target

[Service]
WorkingDirectory=/opt/metabase/
ExecStart=/usr/bin/java -Xms1g -Xms2g -jar /opt/metabase/metabase.jar
EnvironmentFile=/etc/default/metabase
User=metabase
Type=simple
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=metabase
SuccessExitStatus=143
TimeoutStopSec=120
Restart=always

[Install]
WantedBy=multi-user.target

Configure logging:

sudo nano /etc/rsyslog.d/metabase.conf

Paste:

if $programname == 'metabase' then /var/log/metabase.log
& stop

Restart syslog:

sudo systemctl restart rsyslog.service

Start Metabase:

sudo systemctl daemon-reload
sudo systemctl start metabase.service
sudo systemctl status metabase.service

🔌 Step 9: Connect Metabase to Mautic

To connect Metabase with your Mailertizer database, you’ll need SSH tunneling:
1. Copy your private SSH key into:

vim ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
2.  Make the first connection to your server to accept the key:
ssh root@your-mailertizer-server.com
3.  Then edit your SSH config:
vim ~/.ssh/config

Add:

Host mailertizer-db
  HostName your-mailertizer-server.com
  User root
  IdentityFile ~/.ssh/id_rsa
  LocalForward 3307 127.0.0.1:3306
4.  Start the tunnel:
ssh -Nv mailertizer-db &

Now in Metabase, connect to a MySQL database using:
• Host: 127.0.0.1
• Port: 3307
• DB Name, User, and Password: your Mailertizer database credentials

✅ Done!

You now have a fully working Metabase dashboard system hooked into your Mailertizer instance. You can start creating reports and dashboards to track open rates, user activity, campaign performance, and much more—all visually and in real-time.

📚 References

Install Java on Ubuntu

Install Nginx

Metabase Documentation

Share the Post: