> ## Documentation Index
> Fetch the complete documentation index at: https://help.freakhosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Monitor a Server with Prometheus and Grafana

> Install Prometheus and node exporter from the Ubuntu or Debian repositories, add Grafana, connect them and import the Node Exporter Full dashboard (ID 1860).

To monitor a Linux server with Prometheus and Grafana, install `prometheus` and `prometheus-node-exporter` with `sudo apt install` (Ubuntu/Debian), add Grafana from Grafana's APT repository, then in Grafana add a Prometheus data source at `http://localhost:9090` and import dashboard ID `1860` (Node Exporter Full). node\_exporter exposes system metrics on port 9100, Prometheus stores them, and Grafana draws the charts on port 3000.

| Difficulty | Time | Works on | Needs |
| - | - | - | - |
| Intermediate | 30 minutes | Ubuntu 22.04 / 24.04, Debian 12 / 13 | sudo access; 1 GB or more RAM recommended |

## Before you start

* [Connect with SSH](https://help.freakhosting.com/portals/other/how-to-connect-to-a-linux-server-with-ssh.md) as a user with `sudo`. Root users can leave out `sudo`.
* How the parts fit together:

| Component | Job | Default port |
| - | - | - |
| **node\_exporter** | Reads CPU, memory, disk, network and file system stats and publishes them as metrics | `9100` |
| **Prometheus** | Collects ("scrapes") metrics every few seconds and stores them as time series | `9090` |
| **Grafana** | Dashboards and graphs on top of Prometheus | `3000` |

* All three listen on every network interface by default. This guide binds them to localhost and reaches them through an SSH tunnel, so nothing is exposed.
* On AlmaLinux or Rocky Linux, Grafana installs from Grafana's RPM repository, but Prometheus and node\_exporter are not in the base repositories. Use the official release binaries from [prometheus.io/download](https://prometheus.io/download/) or run them with [Docker](https://help.freakhosting.com/portals/other/how-to-install-docker.md).

## How to install Prometheus and node\_exporter

**1. Install the packages**

```bash theme={null}
sudo apt update
sudo apt install prometheus prometheus-node-exporter
```

Both services start automatically. Ubuntu 24.04 ships Prometheus 2.45 and node\_exporter 1.7.

**2. Check the scrape config**

The packaged `/etc/prometheus/prometheus.yml` already scrapes Prometheus itself and node\_exporter:

```yaml theme={null}
scrape_configs:
  - job_name: 'prometheus'
    scrape_interval: 5s
    scrape_timeout: 5s
    static_configs:
      - targets: ['localhost:9090']
  - job_name: node
    static_configs:
      - targets: ['localhost:9100']
```

After any edit, validate the file:

```bash theme={null}
promtool check config /etc/prometheus/prometheus.yml
```

**3. Keep both on localhost**

Edit `/etc/default/prometheus` and set:

```bash theme={null}
ARGS="--web.listen-address=127.0.0.1:9090"
```

Edit `/etc/default/prometheus-node-exporter` and set:

```bash theme={null}
ARGS="--web.listen-address=127.0.0.1:9100"
```

**4. Restart**

```bash theme={null}
sudo systemctl restart prometheus prometheus-node-exporter
```

Check node\_exporter answers:

```bash theme={null}
curl -s http://127.0.0.1:9100/metrics | grep -E "^node_load1 |^node_memory_MemAvailable_bytes"
```

```text theme={null}
node_load1 0.19
node_memory_MemAvailable_bytes 7.133995008e+09
```

## How to install Grafana

**1. Add Grafana's signing key and repository**

```bash theme={null}
sudo apt-get install -y apt-transport-https wget gnupg
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
echo "deb [signed-by=/etc/apt/keyrings/grafana.asc] https://apt.grafana.com stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
```

**2. Install Grafana OSS**

```bash theme={null}
sudo apt-get update
sudo apt-get install grafana
```

**3. Bind Grafana to localhost**

Open `/etc/grafana/grafana.ini`, find the `[server]` section and set:

```ini theme={null}
[server]
http_addr = 127.0.0.1
```

Remove the `;` in front of the line if there is one; a leading `;` means the line is a comment.

**4. Start Grafana and enable it at boot**

```bash theme={null}
sudo systemctl daemon-reload
sudo systemctl start grafana-server
sudo systemctl enable grafana-server.service
```

## How to connect Grafana to Prometheus

**1. Open an SSH tunnel**

On your own computer:

```bash theme={null}
ssh -L 3000:localhost:3000 alex@203.0.113.10
```

Leave it open and browse to `http://localhost:3000`.

**2. Sign in and change the password**

Sign in with username `admin` and password `admin`. Grafana asks you to set a new password straight away. Do it.

**3. Add the Prometheus data source**

Go to **Connections**, add a new connection, search for **Prometheus** and select **Prometheus data source**, then add a new data source. Set **Prometheus server URL** to `http://localhost:9090` and click **Save & test**. You should see `Successfully queried the Prometheus API.`

**4. Import the Node Exporter Full dashboard**

Click **Dashboards**, then **New** > **Import dashboard**. Enter `1860`, click **Load**, select your Prometheus data source and click **Import**.

The dashboard shows CPU, load, memory, disk space, disk I/O and network traffic for the `node` job. Some panels (systemd units, process counts) stay empty unless node\_exporter runs with `--collector.systemd --collector.processes`; add them to `ARGS` in `/etc/default/prometheus-node-exporter` if you want those panels.

> [!WARNING]
>
> Don't open ports 9090, 9100 or 3000 to the whole internet. Prometheus and node\_exporter have no login by default, and an exposed Grafana with the default password is taken over quickly. If you need remote access without a tunnel, put Grafana behind [Nginx with HTTPS](https://help.freakhosting.com/portals/other/how-to-set-up-nginx-as-a-reverse-proxy.md) and allow only your IP in [UFW](https://help.freakhosting.com/portals/other/how-to-set-up-a-firewall-with-ufw.md).

## How to monitor more servers

Install `prometheus-node-exporter` on each extra server, let it listen on its private or public address, and allow port 9100 **only** from your Prometheus server's IP in that server's firewall. Then add the target to `/etc/prometheus/prometheus.yml` on the Prometheus server:

```yaml theme={null}
  - job_name: node
    static_configs:
      - targets: ['localhost:9100', '198.51.100.20:9100']
```

Validate with `promtool check config` and run `sudo systemctl reload prometheus`.

## How to check it worked

```bash theme={null}
sudo ss -tlnp | grep -E ":(9090|9100|3000)\b"
```

All three lines should show `127.0.0.1`. In Prometheus (tunnel port 9090, then `http://localhost:9090`), open **Status** > **Targets**: both jobs should be `UP`.

## Frequently asked questions

### How long does Prometheus keep data?

15 days unless you change it. Set `--storage.tsdb.retention.time=30d` in `ARGS` in `/etc/default/prometheus` to keep 30 days, and check you have the disk space.

### Can Prometheus send alerts?

Yes, through Alertmanager (`sudo apt install prometheus-alertmanager`) and alerting rules. Grafana also has its own alerting. For a simple "server is down" email, an external checker is easier: see [email alerts when your server goes down](https://help.freakhosting.com/portals/other/how-to-get-email-alerts-when-your-server-goes-down.md).

### Should I run Prometheus on the server I monitor?

It is fine for one server. If that server goes down, so does your monitoring, so for several servers run Prometheus and Grafana on a separate small server.

### Is there a simpler option?

[Netdata](https://help.freakhosting.com/portals/other/how-to-set-up-netdata-monitoring.md) gives live dashboards with one install script and no configuration.

## Related guides

> [card] [VPS and dedicated server guides](https://help.freakhosting.com/portals/other/vps-and-dedicated-server-guides.md)
>
> Every server guide in one place.

> [card] [Set up Netdata](https://help.freakhosting.com/portals/other/how-to-set-up-netdata-monitoring.md)
>
> One-script real-time dashboards.

> [card] [Email alerts when your server goes down](https://help.freakhosting.com/portals/other/how-to-get-email-alerts-when-your-server-goes-down.md)
>
> Uptime checks from outside.

> [card] [Nginx as a reverse proxy](https://help.freakhosting.com/portals/other/how-to-set-up-nginx-as-a-reverse-proxy.md)
>
> Publish Grafana with HTTPS.

> [card] [Set up a firewall with UFW](https://help.freakhosting.com/portals/other/how-to-set-up-a-firewall-with-ufw.md)
>
> Keep metric ports closed.

***

> [!NOTE]
>
> **Checked against the official [Prometheus](https://prometheus.io/docs/introduction/overview/) and [Grafana installation](https://grafana.com/docs/grafana/latest/setup-grafana/installation/debian/) documentation and the [Node Exporter Full dashboard page](https://grafana.com/grafana/dashboards/1860-node-exporter-full/)** on 4 November 2026; Prometheus and node\_exporter packages, config check and listen flags tested on Ubuntu 24.04 LTS. The Grafana steps follow Grafana's documentation and were not run. Commands can differ on other distributions or releases.

> [!NOTE]
>
> ### Need Extra Help?
>
> If you encounter any issues, our support team is ready to assist:
>
> * **Live Chat:** Quick assistance via our website.
> * **Support Ticket:** [Open a Ticket](https://freakhosting.com/clientarea/submitticket.php)
> * **Discord:** [Join our Community](https://discord.gg/freakhosting)
> * **Email:** [support@freakhosting.com](mailto:support@freakhosting.com)

> [!TIP]
>
> ### Save on Your Hosting
>
> Ready to upgrade your hosting? Use code **KB20** at checkout for **20% off** your first order!

***

**Last Updated:** November 2026


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.