Pada kesempatan ini saya akan akan membahas cara Install Prometheus pada Rocky Linux.
- membuat user
useradd -M -r -s /bin/false prometheus
- membuat direktori
mkdir /etc/prometheus
mkdir /var/lib/prometheus
- download prometheus
VER=2.28.1
wget https://github.com/prometheus/prometheus/releases/download/v$VER/prometheus-$VER.linux-amd64.tar.gz -P /tmp
- extract
cd /tmp
tar -xzf prometheus-$VER.linux-amd64.tar.gz
ls prometheus-2.14.0.linux-amd64
console_libraries consoles LICENSE NOTICE prometheus prometheus.yml promtool tsdb
- copy file
cp prometheus-$VER.linux-amd64/{prometheus,promtool} /usr/local/bin/
cp -r prometheus-$VER.linux-amd64/{consoles,console_libraries} /etc/prometheus/
- config prometehus
cp prometheus-$VER.linux-amd64/prometheus.yml /etc/prometheus/
vi /etc/prometheus/prometheus.yml
- tambahkan di firewall
firewall-cmd --add-port=9090/tcp --permanent
firewall-cmd --reload
- membuat permission file
chown -R prometheus:prometheus /etc/prometheus
chown -R prometheus:prometheus /var/lib/prometheus
chown prometheus.prometheus /usr/local/bin/{prometheus,promtool}
- start service
prometheus --config.file=/etc/prometheus/prometheus.yml
- akses web
http://ipaddr:9090
- membuat service prometheus
cat > /etc/systemd/system/prometheus.service << 'EOL'
[Unit]
Description=Prometheus Time Series Collection and Processing Server
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
EOL
- start service
systemctl daemon-reload
systemctl enable --now prometheus
systemctl status prometheus