How To Install Prometheus on Ubuntu 22.04 LTS
Prometheus is an open-source systems monitoring and alerting toolkit originally developed by SoundCloud in 2012. It is designed for reliability and scalability in modern, dynamic environments. Prometheus is part of the Cloud Native Computing Foundation (CNCF) and has gained widespread adoption in the field of system monitoring.
Prerequisites
- Server running Ubuntu 22.04
- User with sudo privileges
- Hardware requirements depend on the use case
Download Prometheus
Prometheus releases cater to a variety of CPU architectures and instruction sets to ensure compatibility with diverse hardware environments. You can choose the appropriate version based on your specific CPU architecture, such as AMD64, ARM64, ARMv7…
The official Prometheus GitHub releases page (https://github.com/prometheus/prometheus/releases) provides a comprehensive list of available versions, each tailored to specific CPU architectures and instruction sets.
In this article we will provide two examples (AMD64 and ARMv7)
Download Prometheus for AMD64 :
wget https://github.com/prometheus/prometheus/releases/download/v2.48.0/prometheus-2.48.0.linux-amd64.tar.gz
Download Prometheus ARMv7:
wget https://github.com/prometheus/prometheus/releases/download/v2.48.0/prometheus-2.48.0.linux-armv7.tar.gz
Extract the package:
tar vxf prometheus*.tar.gz
cd prometheus*/
Installation Steps
Create Prometheus User and Group:
sudo groupadd --system prometheus
sudo useradd -s /sbin/nologin --system -g prometheus prometheus
Create the directories for the binaries
sudo mkdir /etc/prometheus
sudo mkdir /var/lib/prometheus
Move prometheus and promtool and change their owner to the user prometheus
sudo mv prometheus /usr/local/bin
sudo mv promtool /usr/local/bin
sudo chown prometheus:prometheus /usr/local/bin/prometheus
sudo chown prometheus:prometheus /usr/local/bin/promtool
Move console, console_libraries and prometheus.yml and change their owner to the user prometheus
sudo mv consoles /etc/prometheus
sudo mv console_libraries /etc/prometheus
sudo mv prometheus.yml /etc/prometheus
sudo chown prometheus:prometheus /etc/prometheus
sudo chown -R prometheus:prometheus /etc/prometheus/consoles
sudo chown -R prometheus:prometheus /etc/prometheus/console_libraries
sudo chown -R prometheus:prometheus /var/lib/prometheus
Service Management
Create systemd service
sudo tee -a /etc/systemd/system/prometheus.service >/dev/null <<'EOF'
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \
--config.file /etc/prometheus/prometheus.yml \
--storage.tsdb.path /var/lib/prometheus/ \
--web.listen-address="0.0.0.0:9090" \
--web.console.templates=/etc/prometheus/consoles \
--web.console.libraries=/etc/prometheus/console_libraries
[Install]
WantedBy=multi-user.target
EOF
Enable prometheus service
sudo systemctl daemon-reload
sudo systemctl enable prometheus
sudo systemctl start prometheus
Verify that the service is running
sudo systemctl status prometheus
Accessing the Prometheus UI
The UI should be accessible with your browser using the IP of your server and port 9090.
Conclusion
Now that you have installed Prometheus successfully, you can start monitoring your servers with node exporter and Grafana.