Skip to main content

Glances can't start --export prometheus with the -w

Your current Glances systemd service is trying to start both the Web UI (-w) and the Prometheus exporter (--export prometheus) at the same time, but Glances doesn’t natively support running both in a single process.

Solution: Run Two Separate Instances of Glances

You'll need to create two systemd service files, one for the Web UI and another for the Prometheus Exporter.

Create a Service for Glances Web UI

Run

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

Paste

[Unit]
Description=Glances Web UI
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/glances -w
Restart=on-failure

[Install]
WantedBy=multi-user.target

Save and exit.

Create a Service for Glances Prometheus Exporter

run

sudo nano /etc/systemd/system/glances-prometheus.service

paste

[Unit]
Description=Glances Prometheus Exporter
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/glances --export prometheus
Restart=on-failure

[Install]
WantedBy=multi-user.target

Save and exit.

Reload Systemd and Start Services

sudo systemctl daemon-reload
sudo systemctl enable glances-prometheus
sudo systemctl start glances-prometheus

Verify That Both Are Running

systemctl status glances-web glances-prometheus

Now, you can access:

  • Web UI at http://<your-ip>:61208
  • Prometheus metrics at http://<your-ip>:9091/metrics

This should work smoothly. 

Useful commands:

Show log path and version

glances -V