How to Install Prometheus on Arch Linux
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.
Prerequisites
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
Step 1: Install Go
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
Step 2: Download and Install Prometheus
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.gzMove the extracted directory to
/optfolder:sudo mv prometheus-* /opt/prometheus
Step 3: Configure Prometheus
Create a new user for Prometheus:
sudo useradd -rs /bin/false prometheusThis will create a new user called
prometheusand assign/bin/falseas the user's shell.Create a configuration file for Prometheus:
sudo nano /opt/prometheus/prometheus.ymlAnd 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/prometheusdirectory toprometheususer:sudo chown -R prometheus:prometheus /opt/prometheusCreate a systemd unit file for Prometheus:
sudo nano /etc/systemd/system/prometheus.serviceAnd 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.targetThis systemd unit file tells systemd to run Prometheus as the
prometheususer.
Step 4: Enable and Start Prometheus
Enable the Prometheus service:
sudo systemctl enable prometheusStart the Prometheus service:
sudo systemctl start prometheus
Step 5: Test 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:
prometheusandnode-exporter.
Congratulations, you have successfully installed Prometheus on your Arch Linux system. You can now start monitoring your system with Prometheus.