Prometheus. Almalinux 8. Install Prometheus + Grafana: различия между версиями
Cless (обсуждение | вклад) |
Cless (обсуждение | вклад) |
||
| Строка 135: | Строка 135: | ||
[[Файл:Import prometheus dashboard 1-5.jpg|без|мини]] | [[Файл:Import prometheus dashboard 1-5.jpg|без|мини]] | ||
[[Файл:Import prometheus dashboard 1-6.jpg|без|мини]] | [[Файл:Import prometheus dashboard 1-6.jpg|без|мини]] | ||
[[Категория:Grafana]] | |||
Текущая версия на 20:04, 1 мая 2024
Prometheus
Install
dnf update -y
wget https://github.com/prometheus/prometheus/releases/download/v2.37.0/prometheus-2.37.0.linux-amd64.tar.gz
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
tar -xvzf prometheus-*
mv prometheus-2.37.0.linux-amd64 prometheuspackage
cp prometheuspackage/prometheus /usr/local/bin/
cp prometheuspackage/promtool /usr/local/bin/
chown prometheus:prometheus /usr/local/bin/prometheus
chown prometheus:prometheus /usr/local/bin/promtool
Copy consoles and console_libraries directories from the prometheuspackage to /etc/prometheus folder
cp -r prometheuspackage/consoles /etc/prometheus
cp -r prometheuspackage/console_libraries /etc/prometheus
cp -r prometheuspackage/prometheus.yml /etc/prometheus/prometheus.yml
chown -R prometheus:prometheus /etc/prometheus/consoles
chown -R prometheus:prometheus /etc/prometheus/console_libraries
chown -R prometheus:prometheus /etc/prometheus/prometheus.yml
nano /etc/prometheus/prometheus.yml
... global: scrape_interval: 10s scrape_configs: - job_name: 'prometheus_master' scrape_interval: 5s static_configs: - targets: ['localhost:9090'] ...
chown prometheus:prometheus /etc/prometheus/prometheus.yml
nano /etc/systemd/system/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
systemctl daemon-reload
systemctl start prometheus
systemctl status prometheus
firewall-cmd --zone=public --add-port=9090/tcp --permanent
systemctl reload firewalld
Go to web
http://<Server-IP>:9090/graph
Grafana
Install
Grafana is a free and open-source, general-purpose graph and dashboard composer.
It supports many third party software applications such as Prometheus, PNP, InfluxDB, Graphite, etc.
Grafana runs as a web application at default port 3000/tcp.
We will use Grafana Web UI to create a dashboard for Prometheus metrics.
nano /etc/yum.repos.d/grafana.repo
[grafana] name=grafana baseurl=https://rpm.grafana.com repo_gpgcheck=1 enabled=1 gpgcheck=1 gpgkey=https://rpm.grafana.com/gpg.key sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crt
dnf install -y grafana
systemctl enable --now grafana-server.service
firewall-cmd --permanent --add-port=3000/tcp
firewall-cmd --reload
Go to web
http://<prometheus-IP>:3000
login: admin, password: admin
Change password at first sign in
Link Prometheus to Grafana
- Click on Add Data Source
- Click on Prometheus
- Add a Prometheus data source: http://localhost:9090
- Click on Save and Test