Install Prometheus and Grafana on Ubuntu 24.04

Aybars Altınyay
Aybars Altınyay
Platform Engineer & Technical Writer
IntermediateUpdated 19 min read~40 minutes total
PrometheusGrafanaNode ExporterUbuntu 24.04MonitoringObservabilityDevOps
Last reviewed:
Tutorial
Install Prometheus and Grafana on Ubuntu 24.04
rafftechnologies.com/learn

Prerequisites

  • Ubuntu 24.04 VM, SSH sudo access, working SSH connectivity, and enough disk capacity for the Prometheus retention period you choose.

Watch your servers with Prometheus and Grafana on your own Ubuntu 24.04 server.

Tested on 2 vCPU and 4 GB RAM: $17.99 a month

  1. 1Pick a Linux imageUbuntu, Debian and more, with your SSH key added.
  2. 2Choose a sizeFrom $4.99 a month. Resize when your app grows.
  3. 3Connect over SSHYour server is up in about 55 seconds.

Ubuntu, Debian and other Linux distributions with full root and SSH access, up and running in about 55 seconds.

To install Prometheus on Ubuntu 24.04 with Grafana, run Prometheus and Node Exporter as dedicated systemd services, keep their web interfaces private, install Grafana from its official stable APT repository, and verify that Grafana can query live host metrics from Prometheus.

This tutorial uses a Raff Technologies Linux VM as the reference Ubuntu server. The single-VM design intentionally binds Prometheus, Node Exporter, and Grafana to 127.0.0.1, so ports 9090, 9100, and 3000 are not exposed directly to the public internet. Administrators reach Grafana through an SSH tunnel.

The previous version of this tutorial used Prometheus 3.5.5 LTS. That LTS line reached end of support on July 31, 2026. As of October 27, 2026, this tutorial pins the supported Prometheus 3.13.5 LTS release (published October 21). It contains security fixes in Go and HTTP/2 dependencies. Use the verified official Linux AMD64 checksum included below and consult the upstream changelog before upgrading existing installations. Node Exporter remains at 1.12.1. Grafana is installed from the official stable APT repository instead of being pinned to a manual package, so normal package maintenance can deliver stable Grafana updates.

The original monitoring workflow was tested on a Raff Ubuntu 24.04 VM with 2 vCPU and 4 GB RAM. Prometheus 3.13.5 and its official checksum were independently verified against upstream release records on October 27, 2026; Node Exporter 1.12.1 and Grafana stable APT instructions remain unchanged. No new end-to-end Raff VM test is claimed for the updated binaries.

Prerequisites:

  • An Ubuntu 24.04 Linux VM on Raff
  • SSH access with a non-root sudo user
  • SSH key authentication recommended
  • Enough disk capacity for your chosen Prometheus retention period
  • A recovery path before changing firewall rules

Step 1 — Prepare Ubuntu 24.04

Update packages and install the utilities used in this tutorial:

Bash
sudo apt update sudo apt upgrade -y sudo apt install -y curl wget tar gnupg ca-certificates ufw jq

If the upgrade requires a reboot, schedule it before continuing:

Bash
test -f /var/run/reboot-required && cat /var/run/reboot-required

Check the operating system and current resources:

Bash
lsb_release -ds nproc free -h df -h /

A 2 vCPU / 4 GB RAM VM is a practical starting point for this small single-node tutorial, but Prometheus storage and memory needs depend on scrape frequency, retention, target count, and metric cardinality.

Verify: Ubuntu should report 24.04 LTS and the VM should have enough CPU, memory, and free disk for the monitoring workload you intend to retain.

Step 2 — Create dedicated service users and Prometheus directories

Create non-login accounts for Prometheus and Node Exporter:

Bash
sudo useradd --system --no-create-home --shell /usr/sbin/nologin prometheus 2>/dev/null || true sudo useradd --system --no-create-home --shell /usr/sbin/nologin node_exporter 2>/dev/null || true

Create Prometheus configuration and data directories:

Bash
sudo install -d -o prometheus -g prometheus /etc/prometheus sudo install -d -o prometheus -g prometheus /var/lib/prometheus

Check the accounts and ownership:

Bash
getent passwd prometheus getent passwd node_exporter ls -ld /etc/prometheus /var/lib/prometheus

Verify: both service accounts should exist and the Prometheus directories should be owned by prometheus.

Step 3 — Install Prometheus 3.13.5 LTS and verify the download

Prometheus 3.13 is the current supported LTS line for this tutorial. Download the Linux AMD64 archive:

Bash
cd /tmp PROMETHEUS_VERSION="3.13.5" PROMETHEUS_ARCHIVE="prometheus-${PROMETHEUS_VERSION}.linux-amd64.tar.gz" curl -fLO "https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_VERSION}/${PROMETHEUS_ARCHIVE}"

Verify the SHA-256 checksum published by Prometheus:

Bash
echo "0388822ace519c5a3a8ef556a541ce1b536e21d872f82deded465bd27a5a0699 ${PROMETHEUS_ARCHIVE}" | sha256sum -c -

Expected output:

Text
prometheus-3.13.5.linux-amd64.tar.gz: OK

Extract and install the binaries:

Bash
tar -xzf "$PROMETHEUS_ARCHIVE" cd "prometheus-${PROMETHEUS_VERSION}.linux-amd64" sudo install -m 0755 prometheus promtool /usr/local/bin/

Verify both binaries:

Bash
prometheus --version | head -n 1 promtool --version | head -n 1

The output should report version 3.13.5.

Verify: the checksum should pass and both installed binaries should report Prometheus 3.13.5.

Step 4 — Configure Prometheus to scrape itself and Node Exporter

Create /etc/prometheus/prometheus.yml:

Bash
sudo tee /etc/prometheus/prometheus.yml > /dev/null <<'EOF' global: scrape_interval: 15s evaluation_interval: 15s scrape_configs: - job_name: "prometheus" static_configs: - targets: ["127.0.0.1:9090"] - job_name: "node_exporter" static_configs: - targets: ["127.0.0.1:9100"] EOF

Set ownership and validate the configuration:

Bash
sudo chown prometheus:prometheus /etc/prometheus/prometheus.yml promtool check config /etc/prometheus/prometheus.yml

Verify: promtool should report a successful configuration check and both localhost scrape targets should be present.

Step 5 — Run Prometheus under systemd on localhost only

Create the service unit:

Bash
sudo tee /etc/systemd/system/prometheus.service > /dev/null <<'EOF' [Unit] Description=Prometheus Monitoring Wants=network-online.target After=network-online.target [Service] User=prometheus Group=prometheus Type=simple ExecStart=/usr/local/bin/prometheus \ --config.file=/etc/prometheus/prometheus.yml \ --storage.tsdb.path=/var/lib/prometheus \ --storage.tsdb.retention.time=15d \ --web.listen-address=127.0.0.1:9090 Restart=on-failure RestartSec=5 [Install] WantedBy=multi-user.target EOF

The explicit 15d retention value makes the tutorial's starting policy visible instead of leaving it implicit. Change it only after checking disk growth and deciding how much incident history you need.

Start Prometheus:

Bash
sudo systemctl daemon-reload sudo systemctl enable --now prometheus

Check the service, readiness endpoint, and bind address:

Bash
systemctl is-active prometheus curl -fsS http://127.0.0.1:9090/-/ready ss -lntp | grep ':9090'

Expected listener:

Text
127.0.0.1:9090

Verify: Prometheus should be active and ready, with port 9090 bound only to localhost.

Step 6 — Install Node Exporter 1.12.1 and verify its checksum

Download Node Exporter:

Bash
cd /tmp NODE_EXPORTER_VERSION="1.12.1" NODE_EXPORTER_ARCHIVE="node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64.tar.gz" curl -fLO "https://github.com/prometheus/node_exporter/releases/download/v${NODE_EXPORTER_VERSION}/${NODE_EXPORTER_ARCHIVE}"

Verify the official Linux AMD64 checksum:

Bash
echo "b51d8a76aa2a9156a55d501aca6276fae09e262259a5e4e831d2c2222f084e63 ${NODE_EXPORTER_ARCHIVE}" | sha256sum -c -

Extract and install the binary:

Bash
tar -xzf "$NODE_EXPORTER_ARCHIVE" sudo install -m 0755 \ "node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64/node_exporter" \ /usr/local/bin/node_exporter

Verify the version:

Bash
node_exporter --version | head -n 1

Verify: the checksum should pass and Node Exporter should report version 1.12.1.

Step 7 — Run Node Exporter under systemd on localhost only

Create the service unit:

Bash
sudo tee /etc/systemd/system/node_exporter.service > /dev/null <<'EOF' [Unit] Description=Prometheus Node Exporter Wants=network-online.target After=network-online.target [Service] User=node_exporter Group=node_exporter Type=simple ExecStart=/usr/local/bin/node_exporter --web.listen-address=127.0.0.1:9100 Restart=on-failure RestartSec=5 [Install] WantedBy=multi-user.target EOF

Start the service:

Bash
sudo systemctl daemon-reload sudo systemctl enable --now node_exporter

Check its metrics and listener:

Bash
systemctl is-active node_exporter curl -fsS http://127.0.0.1:9100/metrics | head ss -lntp | grep ':9100'

Verify: Node Exporter should be active, its /metrics endpoint should return Prometheus-format metrics, and port 9100 should be bound only to localhost.

Step 8 — Verify Prometheus is scraping both targets

Wait for at least one scrape interval:

Bash
sleep 20

Inspect active targets:

Bash
curl -fsS http://127.0.0.1:9090/api/v1/targets | \ jq -r '.data.activeTargets[] | [.labels.job, .health, .lastError] | @tsv'

Expected health values:

Text
prometheus up node_exporter up

Confirm Prometheus has actual host metrics:

Bash
curl -fsSG http://127.0.0.1:9090/api/v1/query \ --data-urlencode 'query=node_uname_info' | \ jq -r '.data.result | length'

The result should be greater than 0.

Verify: both scrape targets should report up and a Node Exporter query should return at least one result.

Step 9 — Install Grafana from the official stable APT repository

Install the repository prerequisites:

Bash
sudo apt-get install -y apt-transport-https wget gnupg

Add the Grafana Labs signing key:

Bash
sudo mkdir -p /etc/apt/keyrings sudo wget -O /etc/apt/keyrings/grafana.asc https://apt.grafana.com/gpg-full.key sudo chmod 644 /etc/apt/keyrings/grafana.asc

Add the stable repository:

Bash
echo "deb [signed-by=/etc/apt/keyrings/grafana.asc] https://apt.grafana.com stable main" | \ sudo tee /etc/apt/sources.list.d/grafana.list

Install Grafana OSS:

Bash
sudo apt-get update sudo apt-get install -y grafana

Keep Grafana private by binding it to loopback:

Bash
sudo sed -i 's/^;\?http_addr =.*/http_addr = 127.0.0.1/' /etc/grafana/grafana.ini

Enable and start Grafana:

Bash
sudo systemctl enable --now grafana-server

Check its health and listener:

Bash
systemctl is-active grafana-server curl -fsS http://127.0.0.1:3000/api/health | jq ss -lntp | grep ':3000'

Verify: Grafana should be active, its health endpoint should respond, and port 3000 should be bound only to 127.0.0.1.

Step 10 — Review UFW safely without risking SSH lockout

Because all three monitoring services are already loopback-only, you do not need public firewall rules for 3000, 9090, or 9100.

Inspect UFW before changing it:

Bash
sudo ufw status verbose

Confirm the actual SSH listening port:

Bash
sudo sshd -T | awk '/^port / {print $2}'

If UFW is already active, verify the existing SSH rule is correct and confirm no monitoring-port allow rules are present:

Bash
sudo ufw status numbered

If UFW is inactive and you want to enable it, allow the actual SSH path first. For standard SSH with the OpenSSH profile:

Bash
sudo ufw allow OpenSSH

For a custom SSH port, allow that port instead, for example:

Bash
sudo ufw allow 2222/tcp

Keep your current SSH session open and create a second SSH session to verify access. Only after the second session succeeds should you enable UFW:

Bash
sudo ufw enable sudo ufw status numbered

Do not add public allow rules for ports 3000, 9090, or 9100.

Verify: SSH should remain reachable after the firewall change and the monitoring ports should still have no public UFW allow rules.

Step 11 — Open Grafana through an SSH tunnel

From your workstation, create a local tunnel:

Bash
ssh -L 3000:127.0.0.1:3000 your-user@your-server-ip

Keep the SSH session open and browse to:

Text
http://127.0.0.1:3000

Grafana's documented first-login defaults are:

Text
Username: admin Password: admin

Change the administrator password when prompted.

Grafana login page on Ubuntu 24.04 after installation

The screenshot is preserved from the original Raff-tested workflow. Labels or minor visual details may differ in newer stable Grafana releases, but the first-login flow remains the same.

From the server, confirm all monitoring listeners are private:

Bash
ss -lntp | grep -E ':3000|:9090|:9100'

Verify: Grafana should open through the SSH tunnel, and all three monitoring listeners should show 127.0.0.1.

Step 12 — Connect Grafana to Prometheus

In Grafana, open:

Text
Connections → Data sources → Add data source → Prometheus

Use this Prometheus server URL:

Text
http://127.0.0.1:9090

Click Save & test.

Grafana Prometheus data source showing a successful connection

The screenshot is retained from the original tested setup; navigation labels can move between Grafana releases.

Verify the same Prometheus API directly from Ubuntu:

Bash
curl -fsSG http://127.0.0.1:9090/api/v1/query \ --data-urlencode 'query=up' | jq -r '.status'

Expected result:

Text
success

Verify: Grafana should accept the data source and the local Prometheus query should succeed.

Step 13 — Import a Node Exporter dashboard

In Grafana, open:

Text
Dashboards → New → Import

The original Raff-tested workflow used Grafana.com dashboard ID:

Text
1860

Select your Prometheus data source and import the dashboard.

Grafana dashboard import screen for Node Exporter Full

Dashboard 1860 is a community dashboard rather than part of Prometheus itself. If it changes or becomes unavailable, the monitoring stack is still valid. Create a simple Grafana panel with a direct PromQL query such as:

Promql
100 - (avg by(instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)

Verify: either the imported dashboard or a manually created panel should return Node Exporter data from Prometheus.

Step 14 — Verify Prometheus and Grafana end to end

Open the Node Exporter dashboard through the SSH tunnel, use a recent time range such as Last 15 minutes, and refresh it.

Grafana Node Exporter dashboard showing live server metrics

Run the final server checks:

Bash
systemctl is-active prometheus systemctl is-active node_exporter systemctl is-active grafana-server prometheus --version | head -n 1 node_exporter --version | head -n 1 curl -fsS http://127.0.0.1:9090/-/ready curl -fsS http://127.0.0.1:9100/metrics >/dev/null curl -fsS http://127.0.0.1:3000/api/health | jq curl -fsS http://127.0.0.1:9090/api/v1/targets | \ jq -r '.data.activeTargets[] | [.labels.job, .health, .lastError] | @tsv' curl -fsSG http://127.0.0.1:9090/api/v1/query \ --data-urlencode 'query=node_uname_info' | \ jq -r '.data.result | length' ss -lntp | grep -E ':3000|:9090|:9100' sudo ufw status numbered

In Grafana, confirm that:

  • You can sign in through the SSH tunnel.
  • The Prometheus data source passes its connection test.
  • A Node Exporter dashboard or manual panel displays current host metrics.
  • The dashboard continues to update as new samples are scraped.

End-to-end verification is complete when Prometheus 3.13.5, Node Exporter 1.12.1, and Grafana are active; both Prometheus targets are up; Grafana can query Prometheus; live host metrics appear in a dashboard; and ports 3000, 9090, and 9100 remain loopback-only.

Monitor additional VMs over private network paths

The localhost design is intentionally limited to one server. To monitor additional Raff VMs, install Node Exporter on those target machines and make Prometheus reach them over a controlled private path such as a Raff VPC.

Do not simply bind Node Exporter to 0.0.0.0:9100 and expose it publicly. Decide which interface should listen, restrict network access to the Prometheus server, and add TLS or authentication when the threat model requires it.

For multiple production targets, also plan service discovery, alerting, retention, and Prometheus availability rather than treating this single-node tutorial as a complete observability architecture.

For a broader small-team monitoring roadmap covering metrics, logs, traces, and SLIs, see Application Observability for Small Teams.

Backup, recovery, and update planning

Prometheus configuration is stored under:

Text
/etc/prometheus

Prometheus time-series data is stored under:

Text
/var/lib/prometheus

Grafana configuration and local state commonly live under:

Text
/etc/grafana /var/lib/grafana

Preserve the Prometheus configuration and any Grafana dashboards, provisioning files, and local database state you need to rebuild the monitoring plane. Whether the full Prometheus TSDB must also be recoverable depends on your incident-history and compliance requirements.

Raff Data Protection can provide infrastructure-level recovery for the VM, but snapshots do not replace a deliberate application recovery plan. If Prometheus history matters, define what data must survive and test the recovery process you choose.

Installing a monitoring stack is only one production-readiness task. Use the Production VPS Checklist for SaaS Apps to review customer-facing health checks, alert ownership, recovery proof, and deployment rollback before launch.

Before updating Prometheus or Node Exporter, review their release notes, update the pinned version and checksum together, restart the service, and rerun the final verification. Grafana installed through its stable APT repository follows normal package-maintenance updates.

Troubleshooting

Prometheus does not start

Validate the configuration and inspect the service journal:

Bash
promtool check config /etc/prometheus/prometheus.yml sudo journalctl -u prometheus -n 100 --no-pager

Check file access:

Bash
sudo -u prometheus test -r /etc/prometheus/prometheus.yml && echo readable sudo -u prometheus test -w /var/lib/prometheus && echo writable

Node Exporter is down in Prometheus

Check Node Exporter directly:

Bash
systemctl is-active node_exporter curl -fsS http://127.0.0.1:9100/metrics | head

Then inspect Prometheus target errors:

Bash
curl -fsS http://127.0.0.1:9090/api/v1/targets | \ jq -r '.data.activeTargets[] | [.labels.job, .health, .lastError] | @tsv'

Grafana does not open through the SSH tunnel

Check the local Grafana listener on the server:

Bash
systemctl is-active grafana-server curl -fsS http://127.0.0.1:3000/api/health | jq ss -lntp | grep ':3000'

Recreate the workstation tunnel:

Bash
ssh -L 3000:127.0.0.1:3000 your-user@your-server-ip

Then browse to http://127.0.0.1:3000.

Grafana cannot query Prometheus

Check Prometheus readiness and query the API from the same host:

Bash
curl -fsS http://127.0.0.1:9090/-/ready curl -fsSG http://127.0.0.1:9090/api/v1/query \ --data-urlencode 'query=up' | jq

For this same-VM deployment, the Grafana data source URL should remain http://127.0.0.1:9090.

The dashboard opens but panels show no data

Confirm that Node Exporter samples exist:

Bash
curl -fsSG http://127.0.0.1:9090/api/v1/query \ --data-urlencode 'query=node_uname_info' | \ jq -r '.data.result | length'

A result greater than 0 proves that Prometheus has Node Exporter data. Then verify the Grafana panel uses the intended Prometheus data source and a time range that includes recent samples.

Prometheus disk usage grows too quickly

Check the TSDB and free disk space:

Bash
sudo du -sh /var/lib/prometheus df -h /

Scrape frequency, target count, metric cardinality, and retention all affect disk usage. Do not reduce retention only to silence a disk alert; first decide how much monitoring history your incident and operations process actually requires.

Enabling UFW could disconnect SSH

Do not enable UFW from a single remote session until you have confirmed the actual SSH port and added the matching allow rule. Keep the current session open, verify a second SSH connection, and use a provider console or other recovery path when available.

Cleanup and rollback

For a reversible shutdown, stop the monitoring services without deleting data:

Bash
sudo systemctl stop grafana-server prometheus node_exporter

Restart them later with:

Bash
sudo systemctl start node_exporter prometheus grafana-server

For permanent decommissioning, back up any Grafana state and Prometheus data you need before removing packages, binaries, unit files, /etc/prometheus, /var/lib/prometheus, /etc/grafana, or /var/lib/grafana.

Do not remove unrelated SSH or firewall configuration as part of monitoring cleanup.

Conclusion

You now have a current Prometheus and Grafana monitoring stack for Ubuntu 24.04. Prometheus 3.13.5 runs on the supported LTS line, Node Exporter supplies host metrics, Grafana queries Prometheus locally, and all three monitoring web interfaces stay bound to localhost.

The workflow also avoids blind firewall activation, keeps the existing SSH-tunnel security model, and leaves a clear path to multi-VM monitoring over private networking when the single-host pattern is no longer enough.

Deploy a Raff Ubuntu Linux VM to run a private Prometheus 3.13.5 LTS, Node Exporter, and Grafana monitoring stack. Keep dashboards off public interfaces and plan verified monitoring-state backups.

Tested on 2 vCPU and 4 GB RAM: $17.99 a month · 14-day money-back guarantee

Deploy Your Server

Sources

  • Prometheus documentation — downloads, LTS release cycle, configuration, and Node Exporter guide
  • Prometheus 3.13.5 release notes and official download checksums; Node Exporter 1.12.1 remains on the existing verified version
  • Grafana documentation — Debian/Ubuntu APT installation, server configuration, and first sign-in
  • Prometheus version, security advisories and Linux AMD64 SHA256 rechecked: 2026-10-27. Other workflow guidance last documentation-reviewed: 2026-09-07; no new VM retest claimed.
Was this article helpful?
Aybars Altınyay
Aybars Altınyay
Platform Engineer & Technical Writer

Aybars is a Platform Engineer & Technical Writer at Raff Technologies. He works on Linux VM templates, self-hosted application workflows, and security-focused deployment validation, turning tested infrastructure procedures into clear, practical tutorials for developers and teams.

Watch your servers with Prometheus and Grafana on your own Ubuntu 24.04 server.

Tested on 2 vCPU and 4 GB RAM: $17.99 a month

Ubuntu, Debian and other Linux distributions with full root and SSH access, up and running in about 55 seconds.

14-day money-back guarantee

Frequently asked questions

How do I install Prometheus and Grafana on Ubuntu 24.04?
Install Prometheus and Node Exporter as dedicated systemd services, install Grafana from Grafana Labs' stable APT repository, bind all monitoring web interfaces to localhost, then connect Grafana to Prometheus and verify live Node Exporter metrics.
Which Prometheus version should I use in this tutorial?
As of October 27, 2026, this tutorial pins Prometheus 3.13.5 from the supported 3.13 LTS line, released October 21 with multiple security fixes. The 3.13 LTS line is supported through July 31, 2027. Verify the official SHA256 and upgrade deliberately; this release update has not been retested on a fresh Raff VM.
Should Prometheus port 9090 or Grafana port 3000 be public?
Not for this single-VM pattern. Prometheus, Node Exporter, and Grafana are bound to 127.0.0.1, and Grafana is reached through an SSH tunnel. Multi-VM monitoring should use controlled private networking and appropriate authentication rather than opening exporter ports to the public internet.
How do I access Grafana without opening port 3000?
Create an SSH tunnel such as `ssh -L 3000:127.0.0.1:3000 user@server`, keep that session open, and browse to `http://127.0.0.1:3000` on your workstation.
Can one Prometheus server monitor multiple Raff VMs?
Yes. Run exporters on the target VMs and let Prometheus scrape them over controlled private network paths. Do not copy the localhost-only target from this single-host tutorial to remote machines without redesigning the network and access controls.
What should I back up in a Prometheus and Grafana deployment?
Preserve Prometheus configuration, Grafana configuration and state, and any dashboard provisioning files. Whether you also protect the Prometheus TSDB depends on your recovery objectives; infrastructure snapshots can help but should be matched to a deliberate monitoring recovery plan.