Skip to main content

Running Prometheus and Alertmanager

note

Note: This guide is based on a conversation with our AI assistant and includes details specific to your setup.

Prerequisites

  • A Linux-based system (e.g., Ubuntu)
  • Terminal access with administrative privileges

Step 1: Download Prometheus and Alertmanager

  1. Open a terminal on your Linux system.

  2. Navigate to the directory where you want to download Prometheus and Alertmanager.

  3. Download Prometheus and Alertmanager archive files using the following commands:

    • Prometheus:

      wget https://github.com/prometheus/prometheus/releases/download/<PROMETHEUS_VERSION>/prometheus-<PROMETHEUS_VERSION>.linux-amd64.tar.gz
    • Alertmanager:

      wget https://github.com/prometheus/alertmanager/releases/download/<ALERTMANAGER_VERSION>/alertmanager-<ALERTMANAGER_VERSION>.linux-amd64.tar.gz

    Replace <PROMETHEUS_VERSION> and <ALERTMANAGER_VERSION> with the appropriate version numbers.

Step 2: Extract Archive Files

  1. Extract Prometheus archive:

    tar -xvzf prometheus-<PROMETHEUS_VERSION>.linux-amd64.tar.gz
  2. Extract Alertmanager archive:

    tar -xvzf alertmanager-<ALERTMANAGER_VERSION>.linux-amd64.tar.gz

Step 3: Create Systemd Service Units

  1. Create a systemd service unit file for Prometheus:

    sudo nano /etc/systemd/system/prometheus.service
  2. Add the following content (adjust paths):

    [Unit]
    Description=Prometheus Monitoring Service
    After=network.target

    [Service]
    User=ubuntu
    ExecStart=/home/ubuntu/prometheus/prometheus --config.file=/home/ubuntu/prometheus/prometheus.yml

    [Install]
    WantedBy=default.target
  3. Create a systemd service unit file for Alertmanager:

    sudo nano /etc/systemd/system/alertmanager.service
  4. Add the following content (adjust paths):

    [Unit]
    Description=Alertmanager Service
    After=network.target

    [Service]
    User=ubuntu
    ExecStart=/home/ubuntu/alertmanager/alertmanager --config.file=/home/ubuntu/alertmanager/alertmanager.yml

    [Install]
    WantedBy=default.target

Step 4: Enable and Start Services

  1. Enable and start Prometheus service:

    sudo systemctl enable prometheus
    sudo systemctl start prometheus
  2. Enable and start Alertmanager service:

    sudo systemctl enable alertmanager
    sudo systemctl start alertmanager

Step 5: Verify Service Status

  1. Check Prometheus service status:

    sudo systemctl status prometheus
  2. Check Alertmanager service status:

    sudo systemctl status alertmanager

Conclusion

You have successfully installed Prometheus and Alertmanager on your Linux system and configured them to run as systemd services. These services will start automatically when the system boots up and run in the background.

If you encounter any issues during the process, refer to this documentation or seek assistance. Happy monitoring and alerting!