Prometheus
Prometheus is monitoring system and time series database.
Note: In the following we will assume that your instance is called hello
(default) as well as that the hostname is hello as well.
Installing the Prometheus Node Exporter
If all you want to do is monitor your gokrazy installation, just add the Prometheus node exporter:
Installing the Prometheus Time Series Database
To install the prometheus monitoring system, add the prometheus program to
your gokrazy instance:
We need a valid prometheus config for prometheus to start successfully. Start
with the default prometheus.yml from the prometheus
repository.
Save it to your gokrazy instance directory, e.g.
~/gokrazy/hello/prometheus.yml.
Open your instance’s config.json in your editor:
To use the prometheus config file, we need to do two things in the gokrazy config:
- Copy over the
prometheus.ymlwith Package config: Extra files - Add Package config: Command-line flags
- We also add
WaitForClockto get accurate timestamps for our timeseries data
Your config should look something like this:
Then, deploy as usual:
In theory, this is enough to deploy prometheus, but unfortunately we are missing the web assets for the web UI which are not included in our build of prometheus.
You can use prometheus as is, if you never want to go to the web UI on
hello:9090. If you visit the web UI anyway, you will get this (or a similar)
error:
To get the web UI to work, we first need the missing files. You have two options:
Option A: Build Web Assets
Follow Prometheus → Building from source, meaning:
Instruct gokrazy to use this build of Prometheus:
Configure gokrazy to build Prometheus with the builtinassets Go build
tag:
To update Prometheus, you’ll need to update your Prometheus dir instead of using
gok get:
Option B: Download Web Assets
The web assets are released with every prometheus release and you need to update them by hand with every new version.
- Go to https://github.com/prometheus/prometheus/releases
- Expand the section “Assets” for the lastest release
- Download
prometheus-web-ui-VERSION.tar.gzwithVERSIONbeing something like2.46.0(example url for version 2.46.0: https://github.com/prometheus/prometheus/releases/download/v2.46.0/prometheus-web-ui-2.46.0.tar.gz) - Extract the archive file:
tar xf prometheus-web-ui-2.46.0.tar.gz - Enable breakglass via gokrazy web
- Create the right folder on your device:
ssh hello mkdir -p /perm/home/prometheus/web/ui - Copy over the
static/directory you exctracted from the tar file:scp -r static/ hello:/perm/home/prometheus/web/ui - Go to
hello:9090to check if the web UI is working