# Prometheus

## Установка из tarника в случае с Rocky Linux 9

Сразу ставим пакеты (вдруг их нет)
```bash
dnf install wget tar
```

Кидаем переменную и качаем файлик с тарником
```bash
VER=2.28.1
wget https://github.com/prometheus/prometheus/releases/download/v$VER/prometheus-$VER.linux-amd64.tar.gz -P /tmp
cd /tmp
tar -xzf prometheus-$VER.linux-amd64.tar.gz
```

Далее перекидываем по папкам
```bash
cp prometheus-$VER.linux-amd64/{prometheus,promtool} /usr/local/bin/
cp -r prometheus-$VER.linux-amd64/{consoles,console_libraries} /etc/prometheus/
cp prometheus-$VER.linux-amd64/prometheus.yml /etc/prometheus/
```

Накидываем права
```bash
chown -R prometheus:prometheus /etc/prometheus
chown -R prometheus:prometheus /var/lib/prometheus
chown prometheus.prometheus /usr/local/bin/{prometheus,promtool}
```

Открываем порт 9090
```bash
firewall-cmd --add-port=9090/tcp --permanent
firewall-cmd --reload
```

Тестовый запуск
```bash
/usr/local/bin/prometheus --config.file=/etc/prometheus/prometheus.yml
```

Создаем systemd сервис с содержимым:
```
[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target

[Service]
User=prometheus
Group=prometheus
Restart=on-failure
ExecStart=/usr/local/bin/prometheus \
  --config.file=/etc/prometheus/prometheus.yml \
  --storage.tsdb.path=/var/lib/prometheus \
  --storage.tsdb.retention.time=30d

[Install]
WantedBy=multi-user.target
```

Рестартим systemd и запускаем сервис:
```bash
systemctl daemon-reload
systemctl start prometheus
systemctl enable prometheus
```
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9