How To Install Prometheus On Ubuntu 22.04
To Install Prometheus On Ubuntu 22.04
Introduction
Prometheus is an open-source technology intended to deliver monitoring and alerting capabilities for cloud-native environments, such as Kubernetes. It is capable of collecting and storing metrics in the form of time-series data, systematically recording information with associated timestamps.
Procedure
Step – 1: Check the OS version
root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy
Step – 2 : Before installing Prometheus, update the repository by using following command
root@linuxhelp:~# apt update -y
Hit:1 http://in.archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://security.ubuntu.com/ubuntu jammy-security InRelease [129 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu jammy-updates InRelease [128 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu jammy-backports InRelease [127 kB]
Get:5 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages [1,729 kB]
Get:6 http://security.ubuntu.com/ubuntu jammy-security/main i386 Packages [524 kB]
Get:7 http://in.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [1,948 kB]
Get:8 http://security.ubuntu.com/ubuntu jammy-security/main Translation-en [287 kB]
Get:9 http://security.ubuntu.com/ubuntu jammy-security/main amd64 DEP-11 Metadata [43.2 kB]
Get:10 http://security.ubuntu.com/ubuntu jammy-security/main DEP-11 48x48 Icons [16.9 kB]
Fetched 17.0 MB in 10s (1,658 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
350 packages can be upgraded. Run 'apt list --upgradable' to see them.
Step – 3 : Now install Prometheus by using the following command
root@linuxhelp:~# apt install prometheus prometheus-node-exporter -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
libflashrom1 libftdi1-2 libllvm13
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
fonts-glyphicons-halflings javascript-common libio-pty-perl libipc-run-perl libjs-bootstrap libjs-bootstrap4 libjs-d3
libjs-eonasdan-bootstrap-datetimepicker libjs-jquery libjs-jquery-hotkeys libjs-moment libjs-moment-timezone libjs-mustache libjs-popper.js
libjs-rickshaw libjs-sizzle libtime-duration-perl moreutils node-jquery prometheus-node-exporter-collectors smartmontools
Suggested packages:
apache2 | lighttpd | httpd gsmartcontrol smart-notifier mailx | mailutils
Setting up prometheus (2.31.2+ds1-1ubuntu1.22.04.2) ...
Created symlink /etc/systemd/system/multi-user.target.wants/prometheus.service → /lib/systemd/system/prometheus.service.
Processing triggers for fontconfig (2.13.1-4.2ubuntu5) ...
Processing triggers for man-db (2.10.2-1) ...
Step – 4 : Edit the Prometheus configuration file using vim editor
root@linuxhelp:~# vim /etc/prometheus/prometheus.yml
change the line from
- targets: [localhost:9093']
to
- targets: ['<SERVER-IP>:9093']
Step – 5 : Restart the Prometheus to apply changes
root@linuxhelp:~# systemctl restart prometheus
Step – 6 : Check the Prometheus status by using the following command
root@linuxhelp:~# systemctl status prometheus
● prometheus.service - Monitoring system and time series database
Loaded: loaded (/lib/systemd/system/prometheus.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2024-08-19 03:43:01 IST; 17s ago
Docs: https://prometheus.io/docs/introduction/overview/
man:prometheus(1)
Main PID: 5470 (prometheus)
Tasks: 9 (limit: 4556)
Memory: 21.1M
CPU: 963ms
CGroup: /system.slice/prometheus.service
└─5470 /usr/bin/prometheus
Step – 7 : Open the browser and search your ip address with 9090 port number http://
Step – 8 : You will see the following dashboard page of the Prometheus monitoring tool.
Conclusion
We have reached the end of this article. In this guide, we have walked you through the steps required to installation of Prometheus on Ubuntu 22.04. Your feedback is much welcome.
Monitoring application performance and availability
Tracking infrastructure metrics (e.g., CPU usage, memory utilization)
Collecting logs from applications and services
Detecting anomalies and alerting on unusual patterns
Scraping: Prometheus pulls data from web servers using HTTP or other protocols.
Push: Applications push metrics directly to Prometheus.
Pull: Prometheus fetches metrics from other systems, like databases or message queues.
Grafana: A visualization platform for creating dashboards.
Alertmanager: A module for managing alerts and notifications.
Kubernetes: Prometheus provides built-in support for monitoring Kubernetes environments.
Loki: A logging system that complements Prometheus' metrics collection.