Skip to content
Snippets Groups Projects
Commit ae1ec42e authored by mgy20's avatar mgy20
Browse files

Edit Prometheus.md

parent 34df2c63
No related branches found
No related tags found
No related merge requests found
# Sistema de Monitoramento de SGDB's # Sistema de Monitoramento de SGDB's
- [Prometheus-Grafana](#prometheus-grafana)
- [Alertas](#alertas-grafana-discord)
- [Dashboards](#dashboards-grafana)
## Objetivo ## Objetivo
Criar um painel (dashboard) que apresente as métricas de vários servidores Postgresql, Clickhouse e que envie notificações de alerta para o discord ou telegram. Criar um painel (dashboard) que apresente as métricas de vários servidores Postgresql, Clickhouse e que envie notificações de alerta para o discord ou telegram.
## Links ## Links
1. [Prometheus](https://schh.medium.com/monitoring-postgresql-databases-using-postgres-exporter-along-with-prometheus-and-grafana-1d68209ca687) 1. [Prometheus](https://schh.medium.com/monitoring-postgresql-databases-using-postgres-exporter-along-with-prometheus-and-grafana-1d68209ca687)
2. [Prometheus](https://www.ashnik.com/monitoring-postgresql-with-prometheus-and-grafana/) 2. [Prometheus](https://www.ashnik.com/monitoring-postgresql-with-prometheus-and-grafana/)
...@@ -14,10 +12,12 @@ Criar um painel (dashboard) que apresente as métricas de vários servidores Pos ...@@ -14,10 +12,12 @@ Criar um painel (dashboard) que apresente as métricas de vários servidores Pos
4. [Clickhouse Dashboard](https://grafana.com/grafana/dashboards/14192-clickhouse/) 4. [Clickhouse Dashboard](https://grafana.com/grafana/dashboards/14192-clickhouse/)
5. [Grafana alert template](https://faun.pub/overview-of-grafana-alerting-and-message-templating-for-slack-6bb740ec44af) 5. [Grafana alert template](https://faun.pub/overview-of-grafana-alerting-and-message-templating-for-slack-6bb740ec44af)
## Dependências ## Dependências
1. postgres_exporter, 0.15.0, conectar e selecionar as metricas a serem exportadas do cluster postgres. 1. postgres_exporter, 0.17.0, Exportador de métricas do Postgres
2. promehteus, 2.48.1, receber dados de multiplas fontes como postgres_exporter e armazená-las em timeseries. 2. promehteus, 2.48.1, Sistema de monitoramento e Banco de Dados Timeseries
3. grafana, 10.2.3, receber dados do prometheus e criar dashboards de visualização e criação de alarmes. 3. grafana, 10.2.3, Dashboards
## Casos de reporte ## Casos de reporte
- Alto uso de CPU - Alto uso de CPU
...@@ -26,29 +26,21 @@ Criar um painel (dashboard) que apresente as métricas de vários servidores Pos ...@@ -26,29 +26,21 @@ Criar um painel (dashboard) que apresente as métricas de vários servidores Pos
- Alto uso de arquivos abertos - Alto uso de arquivos abertos
- Número de conexões - Número de conexões
## Prometheus - Grafana
#### Info geral ## Prometheus - Grafana
- Use wget para fazer o download do github
- Descompacte
- Crie o arquivo de configuração
- Crie o arquivo service
- Inicie o server com systemctl
#### postgres_exporter #### postgres_exporter
```bash ```bash
# Download binaries # Download binaries
cd /opt cd /opt
wget https://github.com/prometheus-community/postgres_exporter/releases/download/v0.15.0/postgres_exporter-0.15.0.linux-amd64.tar.gz wget https://github.com/prometheus-community/postgres_exporter/releases/download/v0.17.0/postgres_exporter-0.17.0.linux-amd64.tar.gz
tar -xzf postgres_exporter-0.15.0.linux-amd64.tar.gz tar -xzf postgres_exporter-0.17.0.linux-amd64.tar.gz
mv postgres_exporter-0.15.0.linux-amd64/ postgres_exporter mv postgres_exporter-0.17.0.linux-amd64 postgres_exporter
rm postgres_exporter-0.15.0.linux-amd64.tar.gz rm postgres_exporter-0.17.0.linux-amd64.tar.gz
# Change permissions # Change permissions
chown -R postgres:postgres postgres_exporter chown -R postgres:postgres postgres_exporter
cd postgres_exporter/ cd postgres_exporter/
# Copy binaries
cp postgres_exporter /usr/local/bin
chown postgres:postgres /usr/local/bin/postgres_exporter
``` ```
Crie o arquivo `/opt/postgres_exporter/postgres_exporter.env` para configurar o acesso ao banco (localhost no exemplo abaixo). Crie o arquivo `/opt/postgres_exporter/postgres_exporter.env` para configurar o acesso ao banco (localhost no exemplo abaixo).
...@@ -70,7 +62,7 @@ User=postgres ...@@ -70,7 +62,7 @@ User=postgres
Group=postgres Group=postgres
WorkingDirectory=/opt/postgres_exporter WorkingDirectory=/opt/postgres_exporter
EnvironmentFile=/opt/postgres_exporter/postgres_exporter.env EnvironmentFile=/opt/postgres_exporter/postgres_exporter.env
ExecStart=/usr/local/bin/postgres_exporter ExecStart=/opt/postgres_exporter/postgres_exporter
Restart=always Restart=always
[Install] [Install]
...@@ -99,7 +91,7 @@ User=postgres ...@@ -99,7 +91,7 @@ User=postgres
Group=postgres Group=postgres
WorkingDirectory=/opt/postgres_exporter WorkingDirectory=/opt/postgres_exporter
EnvironmentFile=/opt/postgres_exporter/postgres_exporter.env EnvironmentFile=/opt/postgres_exporter/postgres_exporter.env
ExecStart=/usr/local/bin/postgres_exporter --collector.postmaster ExecStart=/opt/postgres_exporter/postgres_exporter --collector.postmaster
Restart=always Restart=always
[Install] [Install]
...@@ -115,6 +107,7 @@ mkdir /etc/prometheus ...@@ -115,6 +107,7 @@ mkdir /etc/prometheus
mkdir /var/lib/prometheus mkdir /var/lib/prometheus
chown prometheus:prometheus /etc/prometheus chown prometheus:prometheus /etc/prometheus
chown prometheus:prometheus /var/lib/prometheus chown prometheus:prometheus /var/lib/prometheus
# Download source # Download source
cd /opt cd /opt
wget https://github.com/prometheus/prometheus/releases/download/v2.48.1/prometheus-2.48.1.linux-amd64.tar.gz wget https://github.com/prometheus/prometheus/releases/download/v2.48.1/prometheus-2.48.1.linux-amd64.tar.gz
...@@ -191,6 +184,7 @@ systemctl daemon-reload ...@@ -191,6 +184,7 @@ systemctl daemon-reload
systemctl start prometheus systemctl start prometheus
``` ```
#### Clickhouse #### Clickhouse
Para adicionar o clickhouse ao coletor de metricas do prometheus primeiro deve-se configurar o exportador de metricas do clickhouse. \ Para adicionar o clickhouse ao coletor de metricas do prometheus primeiro deve-se configurar o exportador de metricas do clickhouse. \
Acesse o arquivo de configuração `config.xml` e descomente a tag prometheus com a porta especificada e reinicie o serviço. Acesse o arquivo de configuração `config.xml` e descomente a tag prometheus com a porta especificada e reinicie o serviço.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment