User Tools

Site Tools


сервис_prometheus

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
сервис_prometheus [2026/05/07 15:17]
val [Создание правил]
сервис_prometheus [2026/05/14 15:48] (current)
val [prometheus-apache-exporter]
Line 49: Line 49:
  
   * [[Сервис MTA#​Установка и настройка MTA на обработку почты домена hostname]]   * [[Сервис MTA#​Установка и настройка MTA на обработку почты домена hostname]]
-==== Настройка ====+  * [[Сервис adnanh/​webhook]] 
 +==== Настройка ​маршрутизации уведомлений ​====
 <​code>​ <​code>​
 # apt install prometheus-alertmanager # apt install prometheus-alertmanager
Line 88: Line 89:
 </​code>​ </​code>​
  
-==== Тестирование ====+==== Тестирование ​alertmanager ​====
 <​code>​ <​code>​
 $ curl -H "​Content-Type:​ application/​json"​ -d '[ $ curl -H "​Content-Type:​ application/​json"​ -d '[
Line 104: Line 105:
 ]' http://​localhost:​9093/​api/​v2/​alerts ]' http://​localhost:​9093/​api/​v2/​alerts
 </​code>​ </​code>​
-==== Создание правил ====+==== Подключение ​готовых ​правил ​alertmanager ​====
  
   * [[Управление сервисами в Linux#​Управление юнитами Systemd]] reset-failed   * [[Управление сервисами в Linux#​Управление юнитами Systemd]] reset-failed
Line 110: Line 111:
 <​code>​ <​code>​
 # wget -qO - https://​raw.githubusercontent.com/​samber/​awesome-prometheus-alerts/​master/​dist/​rules/​host-and-hardware/​node-exporter.yml | tee /​etc/​prometheus/​node_exporter_rules.yml # wget -qO - https://​raw.githubusercontent.com/​samber/​awesome-prometheus-alerts/​master/​dist/​rules/​host-and-hardware/​node-exporter.yml | tee /​etc/​prometheus/​node_exporter_rules.yml
 +</​code>​
  
 +==== Создание правил alertmanager ====
 +
 +<​code>​
 # cat /​etc/​prometheus/​first_rules.yml # cat /​etc/​prometheus/​first_rules.yml
 </​code><​code>​ </​code><​code>​
Line 148: Line 153:
 #    annotations:​ #    annotations:​
 #      summary: "​Endpoint {{ $labels.instance }} down" #      summary: "​Endpoint {{ $labels.instance }} down"
 +#      dashboard_url:​ "​http://​server.corpX.un:​3000/​.../​refresh=auto"​
 </​code>​ </​code>​
  
Line 165: Line 171:
   - "​first_rules.yml"​   - "​first_rules.yml"​
   # - "​second_rules.yml"​   # - "​second_rules.yml"​
 +  # - "​node_exporter_rules.yml"​
  
 ... ...
Line 456: Line 463:
   или   или
 8*rate(ifOutOctets{ifDescr="​Port-channel1",​instance="​router"​}[1m]) 8*rate(ifOutOctets{ifDescr="​Port-channel1",​instance="​router"​}[1m])
 +</​code>​
 +
 +===== prometheus-apache-exporter =====
 +
 +<​code>​
 +root@server:​~#​ apt install prometheus-apache-exporter
 +
 +root@server:​~#​ prometheus-apache-exporter --scrape_uri="​http://​localhost/​server-status?​auto"​
 +
 +root@server:​~#​ cat /​etc/​default/​prometheus-apache-exporter
 +...
 +ARGS=""​
 +
 +rate(apache_accesses_total[1m])
 </​code>​ </​code>​
  
Line 474: Line 495:
  
   * [[#​Проверка конфигурации и перезапуск]]   * [[#​Проверка конфигурации и перезапуск]]
-==== Пример ​prometheus pushgateway ​на bash ====+==== Отправка ​метрик из приложения ==== 
 + 
 +=== Пример 1 ===
  
   * [[https://​vinayakpandey-7997.medium.com/​pushing-bash-script-result-to-prometheus-using-pushgateway-a0760cd261e|Scrape data using Bash script and push it to Prometheus using PushGateway]]   * [[https://​vinayakpandey-7997.medium.com/​pushing-bash-script-result-to-prometheus-using-pushgateway-a0760cd261e|Scrape data using Bash script and push it to Prometheus using PushGateway]]
Line 499: Line 522:
 </​code><​code>​ </​code><​code>​
 * * * * * /​root/​ip_dhcp_binding.sh * * * * * /​root/​ip_dhcp_binding.sh
 +</​code>​
 +
 +=== Пример 2 ===
 +
 +  * Web интерфейс к почте [[Web интерфейс к почте#​Roundcube]]
 +  * [[Средства программирования shell#​Тестирование Web приложения на shell]]
 +  * [[Технология cgroup]]
 +
 +<​code>​
 +root@server:​~#​ cat /​usr/​local/​bin/​roundcube_monitor_stat_log.sh
 +</​code><​code>​
 +#!/bin/bash
 +
 +start=$(date +%s.%N)
 +/​usr/​local/​bin/​roundcube_monitor.sh 2>&1 | logger -t roundcube_monitor
 +test ${PIPESTATUS[0]} -eq 0 && end=$(date +%s.%N) || end=$start
 +
 +runtime=$(echo "$end - $start"​ | bc)
 +echo "​roundcube_login_logout_runtime ${runtime}"​ | \
 +  curl --data-binary @- http://​localhost:​9091/​metrics/​job/​roundcube_monitor/​host/​$(hostname)
 +echo "​Выполнено за $runtime сек."​
 +</​code><​code>​
 +root@server:​~#​ crontab -l
 +</​code><​code>​
 +* * * * * /​usr/​local/​bin/​roundcube_monitor_stat_log.sh >/​dev/​null
 </​code>​ </​code>​
сервис_prometheus.1778156259.txt.gz · Last modified: 2026/05/07 15:17 by val