Prometheus and Grafana on Ubuntu 24.04

This image gives you a monitoring server on Ubuntu 24.04: Prometheus collecting metrics, Node Exporter reporting on the server itself, and Grafana with Prometheus connected as a data source and a host dashboard ready to open. Add your other servers as scrape targets and you see CPU, memory, disk and network for all of them in one place.

Image facts

Image
Prometheus and Grafana on Ubuntu 24.04
Type
App image (Ubuntu 24.04 with the app set up)
Architectures
x86-64 and Arm64 (all four families)
Price
Free on every plan
Login
root over SSH with your key, or a one-time root password
Locations
All 15

Sizes that suit it

PlanWhySizePer monthOrder from
P2Ten to twenty hosts with default retention1 vCPU, 2 GB RAM, 40 GB NVMe$6.95$41.70 for 6 months
S4Longer retention and app exporters in Europe2 vCPU, 4 GB RAM, 40 GB NVMe$4.25$51.00 for 12 months
P4Larger fleets outside Europe2 vCPU, 4 GB RAM, 80 GB NVMe$12.05$72.30 for 6 months

What runs on the Prometheus and Grafana image?

Three services, each a systemd unit you can check with systemctl status:

  • Prometheus on port 9090, scraping targets every 15 seconds and storing samples in its local time-series database.
  • Node Exporter on port 9100, exposing the metrics of this server (CPU, load, memory, disk space and I/O, network) for Prometheus to collect.
  • Grafana on port 3000, with Prometheus already added as the default data source and a dashboard for Node Exporter metrics.

The Prometheus configuration lives in prometheus.yml (normally under /etc/prometheus), and Grafana reads /etc/grafana/grafana.ini. Alerting is available in Grafana itself; you add contact points such as email or a chat webhook when you need them.

How do I log in to Grafana the first time?

Open http://your-server-ip:3000. The admin login for Grafana is shown in the message of the day when you connect over SSH; Grafana asks you to set a new password on the first sign-in, and you should. Under Dashboards you find the host dashboard already showing this server's own metrics, which is a quick way to confirm Prometheus is scraping.

Prometheus has its own small web page at http://your-server-ip:9090. The Status, Targets page there lists every scrape target with its state. A target in UP state is being collected; DOWN shows the error, usually a firewall or a typo in the address.

Both pages should not stay open to the internet for long; the security section below closes them.

How do I add my other servers?

Install Node Exporter on each server you want to watch (apt install prometheus-node-exporter on Ubuntu and Debian), then list them in prometheus.yml:

scrape_configs:\n  - job_name: node\n    static_configs:\n      - targets: ['localhost:9100', '203.0.113.10:9100', '203.0.113.11:9100']

Check the file with promtool check config prometheus.yml and reload with systemctl reload prometheus. The new hosts show up in the same Grafana dashboard, with a selector for the instance.

On each monitored server, allow port 9100 only from the monitoring server: ufw allow from <monitor-ip> to any port 9100 proto tcp. Node Exporter metrics are not secret in a dramatic way, but they reveal more about a host than you want to share. The same pattern works for exporters of Nginx, Postgres, MySQL or Redis.

How much disk does Prometheus retention need?

Disk is set by three numbers: how many series you collect, how often, and how long you keep them. Prometheus stores a sample in about 1~2 bytes after compression. One Node Exporter host produces around 500~1,000 series; at a 15 second interval that is about 50~100 MB per host per month.

The default retention is 15 days. To keep more, set flags on the Prometheus service, for example --storage.tsdb.retention.time=90d, and add a size cap like --storage.tsdb.retention.size=30GB so the database deletes the oldest blocks before the disk fills. Leave at least 20% of the disk free for compaction.

With ten hosts and 90 days, expect roughly 2~3 GB. The 40 GB on S4 is plenty for that; application metrics with many labels grow much faster, and that is when S8 with 80 GB makes sense.

How much RAM and CPU does the monitoring server need?

Prometheus keeps the most recent two hours of data in memory, so RAM grows with the number of active series. A rough guide is 2~4 KB of memory per active series, plus Grafana at around 100~200 MB. Ten Node Exporter hosts are about 10,000 series and fit on 1 vCPU, 2 GB RAM, 40 GB NVMe with room to spare.

CPU use is low and comes in short bursts when Grafana renders a dashboard with long time ranges or Prometheus compacts blocks. Two vCPU keep dashboards quick when a few people open them at once. If you add exporters for busy databases or high-cardinality application metrics, watch the prometheus_tsdb_head_series metric and size up when it climbs past a few hundred thousand.

How do I secure Grafana and Prometheus?

Expose only Grafana, over HTTPS, and keep Prometheus private. Prometheus has no login of its own, and its query page lets anyone read every metric you collect.

  1. Point a name such as monitor.example.com at the server.
  2. Put Nginx in front of Grafana as a reverse proxy to 127.0.0.1:3000 and get a certificate with Certbot. Set root_url in grafana.ini to the HTTPS address.
  3. Allow 22, 80 and 443 in ufw; close 3000, 9090 and 9100 to the public.

To look at the Prometheus page, use an SSH tunnel: ssh -L 9090:127.0.0.1:9090 root@your-server-ip. In Grafana, turn off anonymous access and sign-ups, and give team members viewer roles unless they need to edit dashboards.

How are backups and upgrades handled?

What deserves a backup here is configuration, not the metrics. Copy prometheus.yml, any alert rule files, grafana.ini and Grafana's database (/var/lib/grafana/grafana.db, which holds users, dashboards and alert settings). Exporting important dashboards as JSON and keeping them in Git is a good habit too. Metric history can be lost without much harm in most setups. If it does matter, the backup add-on keeps seven daily disk copies for $1.39 a month on P2.

Grafana is installed from its own apt repository and upgrades with apt update && apt upgrade; the dashboards and data source survive upgrades. Prometheus and Node Exporter update the same way through apt. Read the release notes before a major Grafana version, because panel types and alerting settings sometimes change between majors.

Which plan and city suit a monitoring server?

Put the monitoring server in a different city from the servers it watches, so a problem in one location does not take out both the service and the view of it. With servers in Frankfurt, a monitor in Helsinki or Amsterdam works well; with servers in the US, use the other coast.

P2 at $6.95 a month watches ten to twenty hosts in any of the 15 cities. In Europe, S4 gives 2 vCPU, 4 GB RAM, 40 GB NVMe for $4.25, enough for longer retention and a few application exporters. Scrape traffic is tiny compared with the 20 TB that European plans include.

Prometheus and Grafana on Ubuntu 24.04 questions

Does the image monitor itself out of the box?

Yes. Node Exporter runs on the server and Prometheus scrapes it, so the host dashboard in Grafana shows data within a minute of the first login.

How long does Prometheus keep data?

15 days by default. Change it with --storage.tsdb.retention.time and cap the size with --storage.tsdb.retention.size.

Can I monitor servers that are not hosted with CheapVPS?

Yes. Any host that runs Node Exporter and lets the monitoring server reach port 9100 can be a target, wherever it is.

Can Grafana send alerts?

Yes. Grafana alerting is built in; add a contact point such as email or a chat webhook and create alert rules on your Prometheus queries.

Is Loki or log collection included?

No, the image covers metrics. Loki can be added later and connected to the same Grafana as a second data source.

What is the cheapest plan for a monitoring server?

P2 at $6.95 a month handles ten to twenty hosts with 15 days of history.

Start a Prometheus and Grafana server

Choose Prometheus and Grafana on Ubuntu 24.04 when you create the server, or rebuild an existing one with it.