This document describes how to install and configure Prometheus and Grafana on a Debian/Ubuntu-based system.
- A Debian/Ubuntu-based system.
- Access to an account with administrative privileges.
- Internet connection.
-
Update system repositories:
apt update apt upgrade -y
-
Install Prometheus:
Run the following command to install Prometheus from the official repositories:
apt install prometheus -y
-
Verify Prometheus status:
Ensure the service is active and running:
systemctl status prometheus
If it is not active, you can start it with:
systemctl start prometheus
-
Enable auto-start:
sudo systemctl enable prometheus
-
Configuration files:
The main configuration file is located at:
/etc/prometheus/prometheus.yml
You can edit it to add custom monitoring targets:
nano /etc/prometheus/prometheus.yml
-
Access Prometheus web interface:
The web interface will be available at:
http://<SERVER_IP>:9090
-
Add Grafana repository:
Import the GPG key and add the official repository:
apt install -y software-properties-common wget -q -O - https://packages.grafana.com/gpg.key | apt-key add - echo "deb https://packages.grafana.com/oss/deb stable main" | tee /etc/apt/sources.list.d/grafana.list
-
Update repositories and install Grafana:
apt update apt install grafana -y
-
Start Grafana service:
systemctl start grafana-server
-
Enable auto-start:
systemctl enable grafana-server
-
Access Grafana web interface:
The web interface will be available at:
http://<SERVER_IP>:3000
Default credentials are:
- Username:
admin
- Password:
admin
You will be prompted to change the password upon first login.
- Username:
-
Log in to the Grafana interface.
-
Go to Configuration > Data Sources.
-
Click Add data source.
-
Select Prometheus.
-
Set the Prometheus URL:
http://<SERVER_IP>:9090
-
Click Save & Test to verify the connection.
- Go to Create > Dashboard.
- Add a new panel and select metrics from Prometheus.
- Customize your graphs as needed.
- The code for the Grafana dashboard, which extracts the metrics, is as follows:1860
- Scripts: Also, i've created a script to automatice this process, check it out here! (You must be with administrative privileges.)
- Security: Configure firewalls and authentication to secure your services.
- Metric Checks: In this link, there are some checks I’ve been doing on the go, in case you want to check that it works
- Official Documentation:
You are all set! Prometheus and Grafana are now installed and configured on your server.