Prometheus. Almalinux 8. Install Prometheus + Grafana: различия между версиями

Материал из Wiki
Перейти к навигации Перейти к поиску
(Новая страница: «Категория:Prometheus __ОБЯЗАТЕЛЬНОЕ_ОГЛАВЛЕНИЕ__»)
 
 
(не показано 9 промежуточных версий этого же участника)
Строка 1: Строка 1:
[[Категория:Prometheus]]
[[Категория:Prometheus]]
__ОБЯЗАТЕЛЬНОЕ_ОГЛАВЛЕНИЕ__
__ОБЯЗАТЕЛЬНОЕ_ОГЛАВЛЕНИЕ__
== Prometheus ==
=== Install ===
<code>dnf update -y</code>
<code>wget <nowiki>https://github.com/prometheus/prometheus/releases/download/v2.37.0/prometheus-2.37.0.linux-amd64.tar.gz</nowiki></code>
<code>useradd --no-create-home --shell /bin/false prometheus</code>
<code>mkdir /etc/prometheus</code>
<code>mkdir /var/lib/prometheus</code>
<code>chown prometheus:prometheus /etc/prometheus</code>
<code>chown prometheus:prometheus /var/lib/prometheus</code>
<code>tar -xvzf prometheus-*</code>
<code>mv prometheus-2.37.0.linux-amd64 prometheuspackage</code>
<code>cp prometheuspackage/prometheus /usr/local/bin/</code>
<code>cp prometheuspackage/promtool /usr/local/bin/</code>
<code>chown prometheus:prometheus /usr/local/bin/prometheus</code>
<code>chown prometheus:prometheus /usr/local/bin/promtool</code>
Copy consoles and console_libraries directories from the prometheuspackage to /etc/prometheus folder
<code>cp -r prometheuspackage/consoles /etc/prometheus</code>
<code>cp -r prometheuspackage/console_libraries /etc/prometheus</code>
<code>cp -r prometheuspackage/prometheus.yml /etc/prometheus/prometheus.yml</code>
<code>chown -R prometheus:prometheus /etc/prometheus/consoles</code>
<code>chown -R prometheus:prometheus /etc/prometheus/console_libraries</code>
<code>chown -R prometheus:prometheus /etc/prometheus/prometheus.yml</code>
<code>nano /etc/prometheus/prometheus.yml</code>
...
global:
  scrape_interval: 10s
scrape_configs:
  - job_name: 'prometheus_master'
     scrape_interval: 5s
     static_configs:
       - targets: ['localhost:9090']
...
<code>chown prometheus:prometheus /etc/prometheus/prometheus.yml</code>
<code>nano /etc/systemd/system/prometheus.service</code>
[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
<code>systemctl daemon-reload</code>
<code>systemctl start prometheus</code>
<code>systemctl status prometheus</code>
<code>firewall-cmd --zone=public --add-port=9090/tcp --permanent</code>
<code>systemctl reload firewalld</code>
Go to web
<code>http://<Server-IP>:9090/graph</code>
== 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.
<code>nano /etc/yum.repos.d/grafana.repo</code>
[grafana]
name=grafana
baseurl=<nowiki>https://rpm.grafana.com</nowiki>
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=<nowiki>https://rpm.grafana.com/gpg.key</nowiki>
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
<code>dnf install -y grafana</code>
<code>systemctl enable --now grafana-server.service</code>
<code>firewall-cmd --permanent --add-port=3000/tcp</code>
<code>firewall-cmd --reload</code>
Go to web
<code>http://<prometheus-IP>:3000</code><blockquote>login: admin,
password: admin</blockquote>Change password at first sign in
=== Link Prometheus to Grafana ===
* Click on Add Data Source
* Click on Prometheus
* Add a Prometheus data source: '''<nowiki>http://localhost:9090</nowiki>'''
* Click on Save and Test
=== Import Default Prometheus 2.0 Dashboard in Grafana ===
[[Файл:Import prometheus dashboard 1-1.jpg|без|мини]]
[[Файл:Import prometheus dashboard 1-2.jpg|без|мини]]
[[Файл:Import prometheus dashboard 1-3.jpg|без|мини]]
[[Файл:Import prometheus dashboard 1-4.jpg|без|мини]]
[[Файл:Import prometheus dashboard 1-5.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

Import Default Prometheus 2.0 Dashboard in Grafana

Import prometheus dashboard 1-1.jpg
Import prometheus dashboard 1-2.jpg
Import prometheus dashboard 1-3.jpg
Import prometheus dashboard 1-4.jpg
Import prometheus dashboard 1-5.jpg
Import prometheus dashboard 1-6.jpg