Prometheus. Almalinux 8. Install Prometheus + Grafana: различия между версиями
Cless (обсуждение | вклад) м (Cless переименовал страницу Prometheus. Almalinux 8. Установка в Prometheus. Almalinux 8. Install без оставления перенаправления) |
Cless (обсуждение | вклад) |
||
| Строка 119: | Строка 119: | ||
<code>http://<prometheus-IP>:3000</code><blockquote>login: admin | <code>http://<prometheus-IP>:3000</code><blockquote>login: admin | ||
password: admin</blockquote>Change password at first sign in | password: admin</blockquote>Change password at first sign in | ||
Версия 18:53, 21 июля 2022
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://packages.grafana.com/oss/rpm repo_gpgcheck=1 enabled=1 gpgcheck=1 gpgkey=https://packages.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
Create Prometheus Dashboard in Grafana:
- Now, to add a dashboard for Prometheus, click on Dashboards tab
- Here, you can see the available dashboards related to Prometheus data source
- Import a dashboard by clicking on the Import button
- To customize this dashboard, click on Dashboards > Manage button from the left sidebar
- Click on the Prometheus 2.0 Stats dashboard
- Customize this dashboard according to your requirements