Installation guides

Installing Prometheus on RHEL

Step-by-Step Guide

  1. Update the Package Index
    Open a terminal and update the package index to ensure you have the latest information about available packages:
   sudo yum update -y
  1. Download Prometheus
    Go to the Prometheus download page and get the latest version URL for Linux. Download the Prometheus tarball using wget:
   wget https://github.com/prometheus/prometheus/releases/download/v2.32.1/prometheus-2.32.1.linux-amd64.tar.gz

(Replace the URL with the latest version if necessary.)

  1. Extract the Tarball
    Extract the downloaded tarball:
   tar -xvf prometheus-*.tar.gz
  1. Move Prometheus Files
    Move the extracted files to /usr/local/bin and /etc/prometheus directories:
   sudo mv prometheus-*/prometheus /usr/local/bin/
   sudo mv prometheus-*/promtool /usr/local/bin/
   sudo mv prometheus-*/consoles /etc/prometheus/
   sudo mv prometheus-*/console_libraries /etc/prometheus/
   sudo mv prometheus-*/prometheus.yml /etc/prometheus/
  1. Create a Prometheus User
    Create a new Prometheus user and set ownership of the Prometheus files:
   sudo useradd --no-create-home --shell /bin/false prometheus
   sudo chown prometheus:prometheus /usr/local/bin/prometheus
   sudo chown prometheus:prometheus /usr/local/bin/promtool
   sudo chown -R prometheus:prometheus /etc/prometheus/
  1. Create Prometheus Service File
    Create a systemd service file for Prometheus:
   sudo nano /etc/systemd/system/prometheus.service

Add the following content:

   [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.console.templates=/etc/prometheus/consoles \
       --web.console.libraries=/etc/prometheus/console_libraries

   [Install]
   WantedBy=multi-user.target

Save and close the file.

  1. Create Prometheus Data Directory
    Create a directory for Prometheus data and set the appropriate ownership:
   sudo mkdir /var/lib/prometheus
   sudo chown prometheus:prometheus /var/lib/prometheus
  1. Start and Enable Prometheus
    Reload systemd to recognize the new service file:
   sudo systemctl daemon-reload

Start the Prometheus service:

   sudo systemctl start prometheus

Enable Prometheus to start on boot:

   sudo systemctl enable prometheus
  1. Verify Prometheus Installation
    Check the Prometheus service status to ensure it is running:
   sudo systemctl status prometheus

If Prometheus is running, you should see an active (running) status.

  1. Access the Prometheus Web Interface
    Open your web browser and navigate to http://your_server_ip:9090. You should see the Prometheus web interface.
  2. Configure Prometheus (Optional)
    Edit the prometheus.yml configuration file to add new scrape targets or alter existing configurations: sudo nano /etc/prometheus/prometheus.yml After making changes, restart Prometheus to apply them: sudo systemctl restart prometheus
  3. Install Prometheus Node Exporter (Optional)
    To monitor your server’s hardware and OS metrics, install the Prometheus Node Exporter. Download the latest version from the Prometheus Node Exporter download page, extract the tarball, and move the binary to /usr/local/bin. Create a systemd service file for it, start, and enable the service similar to the steps above.

This post should guide users through the process of installing and setting up Prometheus on a RHEL system. Shall we proceed with the next one, Zabbix, or do you have any specific preferences for modifications to this format?

Other Recent Posts