ITMan Documents

This Weblog Just Created For Document Sysadmin Challenges

Prometheus Installation

Configure basic settings

# Install utilities
yum install vim wget bash-compeletion-extras ntpdate 

# Sync Time
ntpdate pool.ntp.org
systemctl start ntpdate
systemctl enable ntpdate

hostnamectl set-hostname prometheus-server
timdatectl set-timezone Asia/Tehran
hwclock --systohc

Install prometheus from source

useradd --no-create-home --shell /bin/false prometheus
mkdir /etc/prometheus
mkdir /var/lib/prometheus
chown prometheus:prometheus /etc/prometheus
chown prometheus:prometheus /var/lib/prometheus/

wget https://github.com/prometheus/prometheus/releases/download/v2.21.0/prometheus-2.21.0.linux-amd64.tar.gz
tar xzvf prometheus-*.linux-amd64.tar.gz
cd prometheus-*.linux-amd64/
cp prometheus /usr/local/bin/
cp promtool /usr/local/bin/
chown prometheus:prometheus /usr/local/bin/prometheus
chown prometheus:prometheus /usr/local/bin/promtool
cp -R consoles /etc/prometheus/
cp -R console_libraries/ /etc/prometheus/
chown -R prometheus:prometheus /etc/prometheus/

Edit prometheus.yml

nano /etc/prometheus/promethues.yml
global:
  scrape_interval: 10s
scrape_configs:
  - job_name: Prometheus_master
    static_configs:
      - targets: ['localhost:9090']

Configure systemd

nano /etc/systemd/system/prometheus.service
[Unit]
Description=Promethues
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

Start and enable prometheus with systemd

systemctl daemon-reload
systemctl start prometheus
systemctl status prometheus
systemctl enable prometheus

Configure firewalld for prometheus

firewall-cmd --add-port=9090/tcp --permanent
firewall-cmd --reload
Last updated on 14 Nov 2020
Published on 14 Nov 2020