Forgejo

Appearance

Make haypack comfortable for you.

Theme
Font
Contrast
Text size
Layout

Saved in this browser. No cookies.

Monitoring (Prometheus, Grafana)

Prometheus collects the metrics of every guest with the module node-exporter – from files or automatically from NetBox via iac-provisioner – Alertmanager mails alerts, Grafana shows them with ready dashboards.

Install

On the Proxmox node as root:

bash -c "$(curl -fsSL https://haypack.dev/monitoring/ct.sh)"

Container from the Debian 13 template · default: 2 CPU, 2048 MiB RAM, 16 GiB disk

Customise the commandYour own values for CPU, RAM, network and modules – no dialog

Then: Grafana: http://<IP>:3000/ – login: admin, password in the guest: grep grafana_admin_password /etc/iac/settings.env – Prometheus queries for other guests: https://<IP>:9443/api/v1/query, token: grep prometheus_read_token /etc/iac/settings.env

More steps are needed outside the guest – see the setup guide.

Settings per instance

SettingMeaning
provisioner_urliac-provisioner URL – optional, e.g. http://10.0.0.7:8686 – the guests with node-exporter come from NetBox
provisioner_sd_token secretiac-provisioner token – grep provisioner_sd_token /etc/iac/settings.env in the provisioner guest

When creating a container, as var_<setting>:

var_provisioner_url="<value>" bash -c "$(curl -fsSL https://haypack.dev/monitoring/ct.sh)"

Set or change later, in the guest (for VMs the only way so far): a line provisioner_url=<value> in /etc/iac/settings.env – no quotes, the last line of a setting wins – then:

update

With NetBox: the same line provisioner_url=<value> in the field Settings of the VM – it takes effect at the next update. Secrets stay in the guest.

Missing or empty = the app's default. Do not edit the configuration files haypack writes – update overwrites them; their first lines name the file for local changes.

Setup guide

Grafana works right after the install – with this guest as the first target. To watch your other guests, they need the module node-exporter, and Prometheus has to learn about them: from files, or automatically from NetBox through iac-provisioner.

guests (node-exporter, :9100) ◀──scrape── Prometheus ──▶ Alertmanager ──▶ mail (mail-relay)
                                              ▲
                     iac-provisioner (NetBox) ┘ list of guests      Grafana :3000 ──▶ you

1. The node exporter on every guest

In each guest you want to watch, as root:

update --add-modules node-exporter

Port 9100 opens for private networks only. New guests get it with var_modules=…,node-exporter or the tick in the dialog.

2. Tell Prometheus about the guests

From NetBox (recommended with iac-provisioner): every active guest with the tag iac-managed and the module node-exporter comes by itself, with its NetBox name as instance.

  1. In the provisioner guest: update (creates the token), then grep provisioner_sd_token /etc/iac/settings.env

  2. In the monitoring guest, in /etc/iac/settings.env:

    provisioner_url=http://<provisioner IP>:8686
    provisioner_sd_token=<the token from step 1>
    
  3. update in the monitoring guest. Prometheus asks every 5 minutes.

From files: for guests outside NetBox, Proxmox nodes and other servers, in /etc/prometheus/targets.d/servers.yml – read within a minute, no restart:

- targets: ["10.0.0.5:9100", "10.0.0.6:9100"]
- targets: ["10.0.0.20:9100"]
  labels:
    instance: pve1

Proxmox nodes: apt install prometheus-node-exporter on the node, allow port 9100 there for the monitoring guest only, and add the node as a file target like above.

3. Alerts by mail

The rules of iac: a target does not answer for 5 minutes, a file system is over 90 % full, less than 10 % memory is available. They go out by mail once the guest has the module mail-relay:

update --add-modules mail-relay

then set the smarthost (mail_relay_host, …) as described on the module page. The alerts go to mail_root_to. Without the module they are only visible in Grafana under Alerting → Alert list.

4. Check it

In Grafana: Dashboards → iac → Node Exporter Full, pick an instance at the top. In the guest:

curl -s http://127.0.0.1:9090/api/v1/targets | jq -r '.data.activeTargets[] | "\(.labels.instance) \(.health) \(.lastError)"'

Your own changes

WhatWhere
More targets of the node exporter/etc/prometheus/targets.d/*.yml
Other exporters (own scrape jobs)/etc/prometheus/scrape.d/*.yml – a file with scrape_configs: like prometheus.yml, then systemctl reload prometheus
Own alert rules/etc/prometheus/rules.d/*.yml, then systemctl reload prometheus
Other receivers (ntfy, Slack, …)/etc/prometheus/alertmanager.local.yml – replaces the iac configuration, then update
Retention (default 30 days)systemctl edit prometheus – ExecStart= empty, then your own ExecStart= with all flags
Grafana settings/etc/grafana/grafana.ini, or GF_… with systemctl edit grafana-server

The dashboards in the folder iac cannot be changed in the UI – save a copy to change one.

Troubleshooting

SymptomCause
A guest is down with “connection refused”no module node-exporter there
down with a timeoutport 9100 not open from the monitoring guest – the guest’s firewall only allows private networks
No guests from NetBoxprovisioner_url or the token wrong: journalctl -u prometheus | grep 'discovery=http' (403: token wrong); in NetBox the guest needs status Active, a primary IPv4 and node-exporter in its modules
update stops at “provisioner_sd_token is missing”provisioner_url is set without the token
No mailsmodule mail-relay missing or its smarthost not set: mailq in the guest

Source: docs/GUIDE.md of iac-monitoring – corrections welcome.

Update

In the guest:

update

Debian packages, Monitoring (Prometheus, Grafana), modules and the haypack configuration. Major versions never change automatically.

Add modules – any time, in containers and VMs alike:

update --list-modules
update --add-modules node-exporter

All modules · More about update