Install Grafana and Prometheus on Ubuntu 22.04
In this guide, we will walk you through how to install Grafana and Prometheus on an Ubuntu Instance for easy monitoring and visualization. Follow these simple steps!
Last updated
In this guide, we will walk you through how to install Grafana and Prometheus on an Ubuntu Instance for easy monitoring and visualization. Follow these simple steps!
Last updated
Ubuntu 22.04
Prometheus: 2.31.2
Grafana: 11.0
Step-by-step instructions to install Grafana and Prometheus
To update and upgrade the package lists from the repositories, run the following command:
Add the Grafana repository to your system. Open a terminal and run the following commands:
Add the Grafana package signing key and Install Grafana
After adding the keys, update the system and install Grafana
Start the Grafana service and enable it to start automatically at system reboot using the following commands:
Install Prometheus using the following command:
Start the Prometheus service and enable it to start automatically at system reboot using the following commands:
Checking the Grafana Version
To check the version of Grafana, run the curl command using the server IP and Grafana port number.
curl http://your_server_ip:3000/api/health
Check the version of Prometheus
To check the version of Prometheus, run these commands.
Access Grafana through a web browser: Open a web browser and go to http://Your_Server_IP:3000. Log in with the default username and password (admin/admin). Follow the on-screen instructions to set up Grafana. Once loaded, you should see the Grafana login page. The default credentials are:
username: admin
password: admin
You'll be prompted to create a new password. Input a secure password, confirm it, and click the "Submit" button.
Add Prometheus as a data source
Click on the Grafana icon in the top left corner to show the main menu
Select Data Sources.
Click Add Data Source.
Choose Prometheus as the type.
Set the URL to http://localhost:9090 (or the appropriate URL if Prometheus is on a different server).
You need to replace the localhost with the IP address of your server.
Now click on the Save & Test.
Now create a dashboard.
Click on the Import Dashboard.
Import the dashboard and save the dashboard back to the dashboard section click on the created dashboard and add visualization.
After selecting Prometheus now configure the dashboard.
Select the matrix, define the labels, select the value, and run the query.
Upon running the queries, the status is displayed, and if you wish to modify the GRAF, simply click on the right side of the time series.
Key Features of Prometheus:
Multi-dimensional Data Model: Uses key-value pairs for labels to identify metrics uniquely.
Powerful Query Language (PromQL): Allows flexible and high-dimensional data querying.
Pull-based Collection: Scrapes metrics from HTTP endpoints at the targets' intervals.
Alerting: Integrated alert manager that handles alerts based on PromQL expressions.
Compatibility: Works well with containerized environments like Kubernetes.\