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

  1. Visit the official Prometheus website http://prometheus.io/ and download the latest version of Prometheus for Linux.

  2. Extract the downloaded file by running the following command:

    tar -xvf prometheus-*.tar.gz
    
  3. Move the extracted directory to /opt folder:

    sudo mv prometheus-* /opt/prometheus
    

Step 3: Configure Prometheus

  1. 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.

  2. 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).

  3. Change the ownership of /opt/prometheus directory to prometheus user:

    sudo chown -R prometheus:prometheus /opt/prometheus
    
  4. 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.

Step 4: Enable and Start Prometheus

  1. Enable the Prometheus service:

    sudo systemctl enable prometheus
    
  2. Start the Prometheus service:

    sudo systemctl start prometheus
    

Step 5: Test Prometheus

  1. Open a web browser and navigate to http://localhost:9090. You should see the Prometheus web interface.

  2. 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!