Setting up prometheus to monitor VMs

In a another file I looked at a basic setup of microstack for running VMs with a GPU passed throught to perform work on-premises, laying a foundation for further work with VMs.

In this file I’d like to take a look at setting up some monitoring of those VMs, including some Prometheus exporters and Grafana for monitoring and charting. Overall getting a basic setup is pretty easy.

ssl certs

microstack does not have a non-tls api, so we can trust the default microstack certs on the controller in order to avoid configuring things to ignore tls. These are generated using the hostname as the subject.

You can find them in /var/snap/microstack/common/etc/ssl/certs, move them to /usr/local/share/ca-certificates/selfsigned.crt, and update the system certs with sudo update-ca-certificates. Or you can just use them to configure whatever you’re running.

openstack exporter

Here’s an openstack exporter built on a golang library that we will use in a later article. Conveniently, it has a docker image. So we can can run it with the following command:

docker run -it -p 9180:9180 --network host \
    -v "$HOME/.config/openstack/clouds.yaml":/etc/openstack/clouds.yaml \
    ghcr.io/openstack-exporter/openstack-exporter:latest microstack

libvirt exporter

There are lots of exporters and grafana dashboards for use with libvirt and openstack. Finding some compatible ones though, is a little difficult… especially when we are not even using full openstack. I found this exporter and tweaked this grafana dashboard to match.

I set these up with a docker-compose and a systemd unit file. It was all pretty easy from there, and the Grafana UI is, of course, just point-and-click.