WIUNIX ACADEMY
Build a Prometheus + Grafana monitoring stack
Page 4 of 6. Review the earlier steps and prerequisites before continuing.
YOUR SYSTEM. YOUR STEPS.
Where are you working?
Choose your OS and version. The prerequisites, commands and troubleshooting follow your environment.
USE YOUR OWN VALUES
Configure this tutorial
Set the example values for your environment; related explanations and copy panels update together. Never enter passwords, private keys or tokens. Values stay in this tab and are not sent to the server or share links. Check actual DNS, certificates and network policy before running commands.
Different IP addresses, domains or ports? Open the settings below, change the values and select “Apply to tutorial”, then copy the updated commands.
Set values for my environment2 editable values
LET’S BUILD
Start Grafana and verify its health endpoint
Restart once after saving provisioning; enabling an already running service does not reload it. Require exact HTTP 200 and database ok, then inspect the listener: it must be 127.0.0.1:3000 before you sign in.
Monitoring server terminal.
(
set -euo pipefail
sudo chown root:grafana /etc/grafana/provisioning/datasources/prometheus.yaml
sudo chmod 0640 /etc/grafana/provisioning/datasources/prometheus.yaml
sudo systemctl daemon-reload
sudo systemctl unmask grafana
sudo systemctl enable grafana
sudo systemctl restart grafana
systemctl is-active grafana
ok=0
for attempt in $(seq 1 12); do
if code=$(curl --noproxy '*' -sS --connect-timeout 2 --max-time 5 -o /dev/null -w '%{http_code}' http://127.0.0.1:3000/api/health); then
if [ "$code" = 200 ]; then ok=1; break; fi
fi
sleep 2
done
[ "$ok" = 1 ] || { echo 'Endpoint did not become ready: http://127.0.0.1:3000/api/health' >&2; exit 1; }
printf '%s -> 200\n' 'http://127.0.0.1:3000/api/health'
curl --noproxy '*' -fsS --connect-timeout 2 --max-time 5 http://127.0.0.1:3000/api/health | jq -e '.database == "ok"'
sudo ss -lntp 'sport = :3000'
)Illustrative excerpt:
active
http://127.0.0.1:3000/api/health -> 200
true
Listener: 127.0.0.1:3000The grafana-server unit is active, the health endpoint prints an exact 200, and the JSON response reports database ok.
Grafana does not return HTTP 200
Inspect the Grafana service log and verify that the provisioning directory contains the expected data source file.
sudo journalctl -u grafana -n 100 --no-pager
sudo ls -l /etc/grafana/provisioning/datasources
sudo sed -n "1,120p" /etc/grafana/provisioning/datasources/prometheus.yamlLET’S BUILD
Sign in to Grafana and confirm the data source
On your workstation, replace the two SSH placeholders with your existing login and server address. Keep the tunnel terminal open. Open http://127.0.0.1:13000 in your browser; the remote service remains private and the network leg is encrypted by SSH.
For a fresh installation, sign in with username admin and initial password admin, then immediately set a unique strong password. Do not reuse these defaults or put the new password in commands, source files or screenshots. The SSH server must permit local forwarding.
In Connections, find the provisioned Prometheus source. In Explore select it and run up. Both local instances must be 1; /api/health alone does not prove the data source works.
Workstation terminal, not the monitoring server. Replace YOUR_SSH_USER and MONITORING_SERVER before running.
ssh -N -o ExitOnForwardFailure=yes -L 127.0.0.1:13000:127.0.0.1:3000 YOUR_SSH_USER@MONITORING_SERVERYou can sign in, change the initial password, and see the provisioned Prometheus data source available in Grafana.
LET’S BUILD
Create a first dashboard with practical PromQL panels
Create separate panels for CPU utilization, the approximate share of memory in use and filesystem available bytes. Paste one PromQL expression per panel and select matching units.
The MemAvailable ratio is not PSI or a direct measurement of memory pressure. Assess pressure with the relevant signals and application behavior separately.
Grafana dashboard panel editor in the browser.
100 - (avg by(instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)
100 * (1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes))
node_filesystem_avail_bytes{fstype!~"tmpfs|overlay"}Each panel shows live data instead of an empty or error state, proving that Grafana can query Prometheus successfully.
Optional: reserve a fresh remote exporter identity
On a separate fresh disposable x86_64 systemd VM, repeat only the selected base-tools installation, then use this guard/account panel. Repeat the verified node_exporter download and exporter-only unit editor/content panels, retaining loopback initially. Do not repeat the main monitoring-host account panel, install Prometheus/Grafana, or start a public exporter. Continue below with the actual remote firewall before changing its listener.
Optional remote VM only · sudo
sudo bash <<'ROOT'
set -euo pipefail
test "$(uname -m)" = x86_64
for path in /usr/local/bin/node_exporter /etc/systemd/system/node_exporter.service /etc/systemd/system/node_exporter.service.d; do
if test -e "$path" || test -L "$path"; then echo "STOP: existing exporter state $path" >&2; exit 1; fi
done
if getent passwd node_exporter >/dev/null || getent group node_exporter >/dev/null; then echo 'STOP: existing exporter identity' >&2; exit 1; fi
for unit in node_exporter node-exporter; do
test "$(systemctl show "$unit" -p LoadState --value)" = not-found || { echo 'STOP: existing exporter unit' >&2; exit 1; }
done
useradd --system --user-group --no-create-home --home-dir /nonexistent --shell /usr/bin/nologin node_exporter
ROOT
Fresh exporter identity exists; verified binary and loopback unit are prepared using the earlier exporter-only steps.
Optional: prepare the remote node safely
This panel is for ALREADY active UFW with default-deny ingress and preserved SSH. Arch/Manjaro mandates no firewall manager: if the lab uses nftables/firewalld, have the existing policy owner prepare an equivalent source/destination TCP9100 rule before changing the listener. Do not install/switch firewall managers to run the panel. Use a trusted private network/VPN and inspect broad existing allows.
Optional remote exporter VM only · sudo; monitoring host address is 10.20.30.10
(
set -euo pipefail
sudo env LC_ALL=C ufw status verbose
sudo env LC_ALL=C ufw status verbose | grep -q '^Status: active'
sudo env LC_ALL=C ufw status verbose | grep -q '^Default: deny (incoming)'
sudo ufw allow proto tcp from 10.20.30.10 to 10.20.30.41 port 9100
sudo ufw status numbered
sudo install -d -m 0755 /etc/systemd/system/node_exporter.service.d
sudo nano /etc/systemd/system/node_exporter.service.d/private.conf
)The command completes successfully; stop and inspect any error before continuing.
Remote exporter private listener
On the remote node, save this override with its actual private IP. Clearing ExecStart is required before replacing it. The private network carries unauthenticated metrics: use a trusted network/VPN, or configure exporter TLS/auth separately.
File contents; save in the named file, not in the shell.
[Service]
ExecStart=
ExecStart=/usr/local/bin/node_exporter --web.listen-address=10.20.30.41:9100
The override selects only the private address.