Prometheus is an open-source system monitoring and alerting toolkit. It was originally developed at SoundCloud and is now a part of the Cloud Native Computing Foundation. In this tutorial, we will learn how to install Prometheus on Arch Linux.
Before we begin, we need to make sure that our Arch Linux system is up-to-date. To do this, run the following command:
sudo pacman -Syu
Prometheus is written in the Go programming language. We need to install Go on our system to be able to use Prometheus. To install Go, run the following command:
sudo pacman -S go
Visit the official Prometheus website http://prometheus.io/ and download the latest version of Prometheus for Linux.
Extract the downloaded file by running the following command:
tar -xvf prometheus-*.tar.gz
Move the extracted directory to /opt
folder:
sudo mv prometheus-* /opt/prometheus
Create a new user for Prometheus:
sudo useradd -rs /bin/false prometheus
This will create a new user called prometheus
and assign /bin/false
as the user's shell.
Create a configuration file for Prometheus:
sudo nano /opt/prometheus/prometheus.yml
And paste the following configuration:
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.
evaluation_interval: 15s # By default, evaluate rules every 15 seconds.
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'node-exporter'
static_configs:
- targets: ['localhost:9100']
This configuration file tells Prometheus to scrape itself (localhost:9090) and the Node Exporter (localhost:9100).
Change the ownership of /opt/prometheus
directory to prometheus
user:
sudo chown -R prometheus:prometheus /opt/prometheus
Create a systemd unit file for Prometheus:
sudo nano /etc/systemd/system/prometheus.service
And paste the following systemd unit file:
[Unit]
Description=Prometheus Server
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/opt/prometheus/prometheus
[Install]
WantedBy=multi-user.target
This systemd unit file tells systemd to run Prometheus as the prometheus
user.
Enable the Prometheus service:
sudo systemctl enable prometheus
Start the Prometheus service:
sudo systemctl start prometheus
Open a web browser and navigate to http://localhost:9090
. You should see the Prometheus web interface.
Click on the "Status" dropdown in the top navigation bar and select "Targets". You should see two targets: prometheus
and node-exporter
.
Congratulations, you have successfully installed Prometheus on your Arch Linux system. You can now start monitoring your system with Prometheus.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!