Need to migrate your e-mails to a new server? Free and paid versions of our online tool available.
Hero Image

Install Prometheus on Gentoo Linux

Install Prometheus on Gentoo Linux

Step 1 – Install

VERSION=2.51.2
wget https://github.com/prometheus/prometheus/releases/download/v${VERSION}/prometheus-${VERSION}.linux-amd64.tar.gz
tar xvf prometheus-${VERSION}.linux-amd64.tar.gz
cp prometheus-${VERSION}.linux-amd64/prometheus /usr/local/bin/
cp prometheus-${VERSION}.linux-amd64/promtool  /usr/local/bin/

Step 2 – Create user and directories

useradd -r -s /sbin/nologin prometheus 2>/dev/null || useradd -r -s /usr/sbin/nologin prometheus
mkdir -p /etc/prometheus /var/lib/prometheus
chown prometheus:prometheus /etc/prometheus /var/lib/prometheus

Step 3 – /etc/prometheus/prometheus.yml

global:
  scrape_interval: 15s

scrape_configs:
  - job_name: "prometheus"
    static_configs:
      - targets: ["localhost:9090"]
  - job_name: "node"
    static_configs:
      - targets: ["localhost:9100","192.168.1.11:9100","192.168.1.12:9100"]
  - job_name: "nginx"
    static_configs:
      - targets: ["localhost:9113"]
  - job_name: "mysql"
    static_configs:
      - targets: ["localhost:9104"]

Step 4 – systemd unit

[Unit]
Description=Prometheus
After=network.target
[Service]
User=prometheus
ExecStart=/usr/local/bin/prometheus \
    --config.file=/etc/prometheus/prometheus.yml \
    --storage.tsdb.path=/var/lib/prometheus \
    --storage.tsdb.retention.time=30d \
    --web.listen-address=:9090
Restart=on-failure
[Install]
WantedBy=multi-user.target
systemctl daemon-reload && systemctl enable --now prometheus

Verify

curl http://localhost:9090/-/healthy