Skip to content

Prometheus And Grafana#

Author Oskar Sinkkilä
Last updated 12.2.2025

Prometheus is an open-source systems monitoring and alerting toolkit originally built at SoundCloud. Since its inception in 2012, many companies and organizations have adopted Prometheus, and the project has a very active developer and user community. It is now a standalone open source project and maintained independently of any company.

Prometheus collects and stores its metrics as time series data, i.e. metrics information is stored with the timestamp at which it was recorded, alongside optional key-value pairs called labels.

Link to Prometheus documentation

Link to Grafana documentation

Prometheus Installation#

Make sure ports 9090 (Prometheus), 9100 (Node Exporter), and 3000 (Grafana) are open.

The way I have this set up is that I use two VMs, k6 with prometheus and grafana, and Prestashop that has prestashop. Both machines have node_exporter for data collection.

Download Prometheus#

wget https://github.com/prometheus/prometheus/releases/download/v3.1.0/prometheus-3.1.0.linux-amd64.tar.gz
Downloads the Prometheus archive. At the time of writing Prometheus 3.1.0 is the latest stable version.

Extract the archive#

tar xvfz prometheus-*.tar.gz
Extracts the Prometheus files.

Remove the archive#

rm prometheus-*.tar.gz
Deletes the compressed file to save space.

Create directories for Prometheus#

sudo mkdir /etc/prometheus /var/lib/prometheus
Creates directories for configuration and data storage.

cd prometheus-3.1.0.linux-amd64/
Moves into the Prometheus folder.

Move Prometheus binaries to system path#

sudo mv prometheus promtool /usr/local/bin/
Moves the prometheus and promtool binaries to /usr/local/bin/ for global access.

Move configuration file#

sudo mv prometheus.yml /etc/prometheus/prometheus.yml
Moves the prometheus.yml configuration file to /etc/prometheus/.

Verify Prometheus installation#

prometheus --version
Confirms that Prometheus is installed.

Create a Prometheus system user#

sudo useradd -rs /bin/false prometheus
Creates a system user prometheus without login access.

Set permissions for Prometheus files#

sudo chown -R prometheus: /etc/prometheus /var/lib/prometheus
Grants ownership of Prometheus directories to the prometheus user.

Create a systemd service file for Prometheus#

sudo nano /etc/systemd/system/prometheus.service
Defines a service to run Prometheus automatically.

Contents of prometheus.service:#

[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target

[Service]
User=prometheus
Group=prometheus
Type=simple
Restart=on-failure
RestartSec=5s
ExecStart=/usr/local/bin/prometheus \
    --config.file /etc/prometheus/prometheus.yml \
    --storage.tsdb.path /var/lib/prometheus/ \
    --web.console.templates=/etc/prometheus/consoles \
    --web.console.libraries=/etc/prometheus/console_libraries \
    --web.listen-address=0.0.0.0:9090 \
    --web.enable-lifecycle \
    --log.level=info

[Install]
WantedBy=multi-user.target

Reload systemd and start Prometheus#

sudo systemctl daemon-reload
sudo systemctl enable prometheus
sudo systemctl start prometheus

Check Prometheus status#

sudo systemctl status prometheus
Ensures Prometheus is running.

Prometheus Version

Access Prometheus Web UI#

  • Open http://<public_ip>:9090/query in a browser.
  • Ensure port 9090 is open.

Prometheus Target Health

Node Exporter Installation#

Download Node Exporter#

wget https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-amd64.tar.gz

At the time of writing version 1.8.2 is the latest.

Extract Node Exporter#

tar xvfz node_exporter-*.tar.gz

Move the Node Exporter binary#

sudo mv node_exporter-1.8.2.linux-amd64/node_exporter /usr/local/bin

Remove extracted files#

rm -r node_exporter-1.8.2.linux-amd64*

Run Node Exporter (for testing)#

node_exporter

Create a system user for Node Exporter#

sudo useradd -rs /bin/false node_exporter

Create a systemd service file for Node Exporter#

sudo nano /etc/systemd/system/node_exporter.service

Enable and start Node Exporter#

sudo systemctl enable node_exporter
sudo systemctl daemon-reload
sudo systemctl start node_exporter

Check Node Exporter status#

sudo systemctl status node_exporter
Should show a green status.

Verify Node Exporter Web UI#

  • Open http://<public_ip>:9100 and check metrics.

Node Exporter

Configure Prometheus to Monitor Node Exporter#

Edit Prometheus configuration file#

sudo nano /etc/prometheus/prometheus.yml

Prometheus YML

Restart Prometheus#

sudo systemctl restart prometheus

Check Target Health in Prometheus UI#

  • Open http://<public_ip>:9090/targets
  • Ensure Node Exporter appears as a monitored target.

Prometheus Endpoints

Note, If Prestashop is on another machine, install Node Exporter there and configure Prometheus accordingly

Grafana Installation#

Grafana version used in this guide at the time of writing is 11.5.0

Install required dependencies#

sudo apt-get install -y apt-transport-https software-properties-common

Add Grafana repository key#

sudo wget -q -O /usr/share/keyrings/grafana.key https://apt.grafana.com/gpg.key

Add Grafana repository#

echo "deb [signed-by=/usr/share/keyrings/grafana.key] https://apt.grafana.com stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list

Update package list#

sudo apt-get update

Install Grafana#

sudo apt-get install grafana -y

Enable and start Grafana service#

sudo systemctl daemon-reload
sudo systemctl enable grafana-server.service
sudo systemctl start grafana-server

Check Grafana status#

sudo systemctl status grafana-server
Should show a green status.

Accessing Grafana#

  • Open http://<public_ip>:3000
  • Default login credentials:
    • Username: admin
    • Password: admin (prompted to change after first login)
  • Add Prometheus as a data source.
  • Create dashboards to visualize metrics.