Install Grafana with Prometheus on Ubuntu 22.04

Prometheus is an open-source systems monitoring and alerting toolkit designed to collect and store metrics as time series data.

Prerequisite:

Ubuntu 22.04

Prometheus: 2.31.2

Grafana: 11.0

To update and upgrade the package lists from the repositories, run the following command:

sudo apt-get update -y
sudo apt-get upgrade -y
  1. Install Prometheus using the following command:

sudo apt-get install prometheus -y
  1. Install Grafana:

Add the Grafana repository to your system. Open a terminal and run the following commands:

sudo apt-get install -y software-properties-common
sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"

Add the Grafana package signing key and Install Grafana

curl https://packages.grafana.com/gpg.key | sudo apt-key add -
sudo apt-get update && sudo apt-get install -y grafana
  1. Start the Grafana/Prometheus service and enable it to start automatically at system reboot using the following commands:

sudo systemctl start prometheus
sudo systemctl enable prometheus
  1. Start and enable Grafana service:

sudo systemctl start grafana-server
sudo systemctl enable grafana-server

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.

prometheus --version

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.

Configure Prometheus as a data source in Grafana:

  • Go to Configuration -> Data Sources -> Add data source.

  • Choose Prometheus as the type.

  • Set the URL to http://Your_Server_IP:9090

  • Click Save & Test.

Key Features of Prometheus:

  • Multi-dimensional Data Model: Uses key-value pairs for labels to identify metrics uniquely.

  • Powerful Query Language (PromQL): Allows for flexible and high-dimensional querying of the data.

  • 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.\

Last updated