Skip to content
DevOps devops monitoring 5 min read

Visualizing with Grafana

Prometheus is great at collecting and storing metrics (numbers about how your servers and apps behave over time), but its built-in web page is plain and hard to read. Grafana is the tool that fixes that. Grafana is an open-source dashboard tool: it connects to a data source (a place where your metrics live, like Prometheus), runs queries for you, and draws the results as graphs, gauges, and tables you can actually understand at a glance. This is the payoff page of monitoring, where raw numbers finally become a picture.

What is Grafana?

Grafana is a web application you run on a server. You open it in your browser, point it at one or more data sources, and build dashboards (a screen full of panels, where each panel is one chart or stat). It does not store metrics itself. Instead, it asks Prometheus (or another source) for the data every few seconds and renders it live.

A few terms you will see:

  • Data source — a backend Grafana reads from. Prometheus is the most common for metrics.
  • Panel — a single visualization (a line graph, a gauge, a table, a single big number).
  • Dashboard — a collection of panels arranged on one page.
  • Query — the question Grafana asks the data source. For Prometheus this is written in PromQL (Prometheus Query Language).

When to use Grafana (and when not to)

SituationUse Grafana?
You want shared, always-on dashboards on a TV or browserYes
You need to correlate metrics from many servers in one viewYes
You want to explore metrics ad hoc and tweak queries visuallyYes
You only need a one-off PromQL query right nowNo, just use the Prometheus UI
You want to store or alert on logs/traces onlyGrafana can, but pair it with Loki/Tempo; for pure log storage other tools fit better

Grafana is the visualization and alerting layer. It is not a replacement for Prometheus, which still does the collecting and storing.

Install Grafana on Ubuntu

These steps work on Ubuntu 22.04 LTS and 24.04 LTS. We install Grafana from its official APT repository (APT is Ubuntu’s package manager) so you get signed updates over time.

First, add the prerequisites and Grafana’s signing key (a cryptographic key that proves the packages are genuine):

sudo apt-get update
sudo apt-get install -y apt-transport-https software-properties-common wget
sudo mkdir -p /etc/apt/keyrings
wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/grafana.gpg > /dev/null

Now add the repository and install the open-source edition:

echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
sudo apt-get update
sudo apt-get install -y grafana

Start Grafana and tell systemd (Ubuntu’s service manager) to launch it automatically on every boot:

sudo systemctl daemon-reload
sudo systemctl enable --now grafana-server
sudo systemctl status grafana-server

Output:

● grafana-server.service - Grafana instance
     Loaded: loaded (/lib/systemd/system/grafana-server.service; enabled; preset: enabled)
     Active: active (running) since Mon 2026-06-15 10:12:44 UTC; 3s ago
   Main PID: 4821 (grafana)
      Tasks: 12 (limit: 4915)
     Memory: 64.2M
        CPU: 980ms

Grafana listens on port 3000 by default. If you run the ufw firewall (Uncomplicated Firewall, Ubuntu’s simple firewall front-end), open that port:

sudo ufw allow 3000/tcp

Port 3000 has no encryption by default. For anything beyond a private test box, put Grafana behind a reverse proxy (a server that sits in front of your app and forwards requests to it) such as Nginx with HTTPS, and restrict port 3000 so it is only reachable on localhost.

Open http://YOUR_SERVER_IP:3000 in a browser. Log in with the default username admin and password admin. Grafana forces you to set a new password on first login. Choose a strong one immediately.

Add Prometheus as a data source

Grafana needs to know where Prometheus lives. We assume Prometheus is running on the same machine at its default port 9090.

  1. In the left sidebar, click Connections, then Data sources.
  2. Click Add data source and choose Prometheus.
  3. In the Connection section, set the Prometheus server URL to:
http://localhost:9090
  1. Leave authentication off if Prometheus is local and unprotected.
  2. Scroll down and click Save & test.

You should see a green confirmation:

Output:

Successfully queried the Prometheus API.

If it fails, confirm Prometheus is actually running with sudo systemctl status prometheus and that the URL and port are correct.

Doing this as code (provisioning)

Clicking is fine to start, but real teams define data sources in a file so the setup is repeatable. Create /etc/grafana/provisioning/datasources/prometheus.yaml:

apiVersion: 1
datasources:
  - name: Prometheus
    type: prometheus
    access: proxy
    url: http://localhost:9090
    isDefault: true
    editable: false

Then restart Grafana to apply it:

sudo systemctl restart grafana-server

Now any fresh install gets the same data source with no clicking. This is the preferred approach for servers you manage long term.

Import a community dashboard

You do not have to build dashboards from scratch. Grafana has a public library of ready-made dashboards, each with a numeric ID. The most popular one for Linux server metrics is Node Exporter Full, ID 1860. It pairs perfectly with the Node Exporter agent that feeds CPU, memory, disk, and network metrics into Prometheus.

To import it:

  1. In the left sidebar, click Dashboards, then New, then Import.
  2. In the Import via grafana.com box, type the ID 1860 and click Load.
  3. At the bottom, under Prometheus, select the data source you just created.
  4. Click Import.

Within seconds you get a full dashboard: gauges for CPU and memory usage, graphs for disk I/O, network traffic, load average, and more, all updating live.

Output:

Dashboard "Node Exporter Full" imported.
Showing data for instance localhost:9100 over the last 1 hour.
CPU Busy: 7%   Memory used: 38%   Root FS used: 22%

If panels say “No data”, the usual cause is that Node Exporter is not installed or Prometheus is not scraping it. Check that the instance dropdown at the top of the dashboard lists your server.

Best Practices

  • Change the default admin password immediately and create individual logins for each teammate instead of sharing one account.
  • Never expose port 3000 to the public internet directly. Use Nginx with HTTPS and a firewall rule limiting access.
  • Provision data sources and key dashboards as YAML files so your setup is version-controlled and reproducible.
  • Set a sensible auto-refresh (such as 30 seconds) on dashboards; refreshing every second hammers Prometheus for no benefit.
  • Organize dashboards into folders by team or service so they stay findable as you add more.
  • Keep Grafana updated with sudo apt-get update && sudo apt-get upgrade grafana to get security fixes.
Last updated June 15, 2026
Was this helpful?