
Инсталация от source
- Ъпдейт на репозиторито
yum update -y
Отваряме страницата на проекта Prometheus и сваляме последната катуална версия
Сваляме нужнитя ни пакет
cd /opt/
curl -LO https://github.com/prometheus/prometheus/releases/download/v2.12.0/prometheus-2.12.0.linux-amd64.tar.gz
tar -xvf prometheus-2.3.2.linux-amd64.tar.gz
mv prometheus-2.3.2.linux-amd64 prometheus-files
- Създаваме потребител prometheus, нужните директории и техните права
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
- Копираме бинарните файлове от директория prometheus-files във /usr/bin/
cp prometheus-files/prometheus /usr/local/bin/
cp prometheus-files/promtool /usr/local/bin/
chown prometheus:prometheus /usr/local/bin/prometheus
chown prometheus:prometheus /usr/local/bin/promtool
- Преместваме директориите consoles и console_libraries в /etc/prometheus
cp -r prometheus-files/consoles /etc/prometheus
cp -r prometheus-files/console_libraries /etc/prometheus
chown -R prometheus:prometheus /etc/prometheus/consoles
chown -R prometheus:prometheus /etc/prometheus/console_libraries
Конфигурация на prometheus
Необходимата конфигурация се намира във файла /etc/prometheus/prometheus.yml.
- Създаваме фйала prometheus.yml
touch /etc/prometheus/prometheus.yml
- Копирайте следните редове във вашият prometheus.yml файл.
global:
scrape_interval: 10s
scrape_configs:
- job_name: 'prometheus'
scrape_interval: 5s
static_configs:
- targets: ['localhost:9090']
- Оправяме правата на файла:
chown prometheus:prometheus /etc/prometheus/prometheus.yml
Създаваме Prometheus Service файл
- Създаваме фйала /etc/systemd/system/prometheus.service
touch /etc/systemd/system/prometheus.service
- Копирайте следните редове във вашият prometheus.service файл.
[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
- Презареждаме systemd service и стартираме prometheus
systemctl daemon-reload
systemctl start prometheus
Access Prometheus Web UI
Достъп до Web UI може да направите на вашият IP и порт 9090http://prometheus-ip>:9090/graph