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/11/27 12:46]
val [Service Discovery]
сервис_prometheus [2026/12/02 16:39] (current)
val [Создание правил alertmanager]
Line 7: Line 7:
   * [[https://​selectel.ru/​blog/​tutorials/​monitoring-in-k8s-with-prometheus/​|Мониторинг в K8s с помощью Prometheus]]   * [[https://​selectel.ru/​blog/​tutorials/​monitoring-in-k8s-with-prometheus/​|Мониторинг в K8s с помощью Prometheus]]
   * [[https://​www.dmosk.ru/​instruktions.php?​object=prometheus-linux|Установка Prometheus + Alertmanager + node_exporter на Linux]]   * [[https://​www.dmosk.ru/​instruktions.php?​object=prometheus-linux|Установка Prometheus + Alertmanager + node_exporter на Linux]]
 +
 +  * [[https://​habr.com/​ru/​companies/​rkt/​articles/​1111642/​|Сотни алертов в день: почему дежурные перестают их читать]]
  
 ===== Установка в Debian/​Ubuntu ===== ===== Установка в Debian/​Ubuntu =====
Line 48: Line 50:
 ==== Service Discovery ==== ==== Service Discovery ====
  
-  * [[#Пример использования ​file-based service discovery ​и сервиса ping]]+  * [[#​file-based service discovery]]
  
   * [[Hashicorp Consul]]   * [[Hashicorp Consul]]
  
-  * Устанавливаем сборку с поддержкой Consul+=== Сборка с поддержкой Consul ​===
 <​code>​ <​code>​
 # wget https://​github.com/​prometheus/​prometheus/​releases/​download/​v2.53.4/​prometheus-2.53.4.linux-amd64.tar.gz # wget https://​github.com/​prometheus/​prometheus/​releases/​download/​v2.53.4/​prometheus-2.53.4.linux-amd64.tar.gz
Line 85: Line 87:
  
 ==== Prometheus Federation ==== ==== Prometheus Federation ====
 +<​code>​
 +prom.isp.un#​ curl -sG '​http://​192.168.X.10:​9090/​federate'​\
 +  --data-urlencode '​match[]={__name__=~"​.*"​}' ​ # |wc-l
 +
 +prom.isp.un#​ cat /​etc/​prometheus/​prometheus.yml
 +</​code><​code>​
 +...
 +scrape_configs:​
 +  - job_name: '​federate-corp'​
 +    scrape_interval:​ 15s
 +    honor_labels:​ true
 +    metrics_path:​ '/​federate'​
 +    params:
 +      '​match[]':​
 +        - '​{__name__=~"​node_filesystem_free_bytes|windows_logical_disk_free_bytes"​}'​
 +    static_configs:​
 +      - targets:
 +        - '​192.168.1.10:​9090'​
 +        - ...
 +        - '​192.168.M.10:​9090'​
 +</​code>​
 +
 +==== Prometheus Remote Write ====
 <​code>​ <​code>​
 prom.isp.un#​ cat /​etc/​default/​prometheus prom.isp.un#​ cat /​etc/​default/​prometheus
Line 94: Line 119:
 ... ...
 remote_write:​ remote_write:​
-  - url: '​http://​10.5.12.64:​9090/​api/​v1/​write'​+  - url: '​http://​172.16.1.254:​9090/​api/​v1/​write'​
     write_relabel_configs:​     write_relabel_configs:​
       - source_labels:​ [__name__]       - source_labels:​ [__name__]
Line 217: Line 242:
 #    annotations:​ #    annotations:​
 #      summary: "​Сервис Roundcube не доступен"​ #      summary: "​Сервис Roundcube не доступен"​
-#      dashboard_url:​ "​http://​server.corpX.un:​3000/​n/​nnnnnnnn/​mail-app"+#      dashboard_url:​ "​http://​server.corpX.un:​3000/​n/​nnnnnnnn/​monitoring-servisa-roundcube"
 </​code>​ </​code>​
  
Line 255: Line 280:
   * Поле annotations.dashboard форматируется как гиперссылка   * Поле annotations.dashboard форматируется как гиперссылка
 <​code>​ <​code>​
-cat /​etc/​prometheus/​alertmanager_templates/​minimal_link.tmpl/+cat /​etc/​prometheus/​alertmanager_templates/​minimal_link.tmpl
 </​code><​code>​ </​code><​code>​
 {{ define "​email.default.html"​ }} {{ define "​email.default.html"​ }}
Line 291: Line 316:
   * В Debian/​Ubuntu ставится как зависимость к пакету prometheus и добавлен в конфигурацию   * В Debian/​Ubuntu ставится как зависимость к пакету prometheus и добавлен в конфигурацию
   * [[http://​server.corpX.un:​9100/​metrics]]   * [[http://​server.corpX.un:​9100/​metrics]]
 +
 +<​code>​
 +# apt install prometheus-node-exporter
 +</​code>​
  
 == Примеры метрик == == Примеры метрик ==
Line 344: Line 373:
  
   * Счетчики (Counters) ​   * Счетчики (Counters) ​
 +  * набор значений за период (range vector): node_network_receive_bytes_total[1m]
 <​code>​ <​code>​
 8*rate(node_network_receive_bytes_total[1m]) 8*rate(node_network_receive_bytes_total[1m])
Line 379: Line 408:
  
 === Windows === === Windows ===
 +=== windows_exporter ===
  
   * [[https://​github.com/​prometheus-community/​windows_exporter/​releases/​download/​v0.31.3/​windows_exporter-0.31.3-amd64.msi]]   * [[https://​github.com/​prometheus-community/​windows_exporter/​releases/​download/​v0.31.3/​windows_exporter-0.31.3-amd64.msi]]
Line 384: Line 414:
  
 <​code>​ <​code>​
-windows_logical_disk_free_bytes+gate# curl -s 192.168.X.10N:​9182/​metrics # | grep windows_logical_disk_free_bytes
 </​code>​ </​code>​
 ==== prometheus-blackbox-exporter ==== ==== prometheus-blackbox-exporter ====
Line 407: Line 437:
 </​code><​code>​ </​code><​code>​
 # service prometheus-blackbox-exporter restart # service prometheus-blackbox-exporter restart
 +</​code>​
  
 +=== check_http ===
 +
 +<​code>​
 # cat /​etc/​prometheus/​prometheus.yml # cat /​etc/​prometheus/​prometheus.yml
 </​code><​code>​ </​code><​code>​
Line 432: Line 466:
  
 <​code>​ <​code>​
 +# curl "​http://​localhost:​9115/​probe?​target=val.bmstu.ru&​module=http_2xx"​
 +
 probe_success... probe_success...
  
Line 439: Line 475:
 </​code>​ </​code>​
  
-=== Пример использования ​file-based service discovery ​и сервиса ping ===+=== file-based service discovery ​=== 
 +=== check_ping ​===
  
   * [[https://​www.robustperception.io/​icmp-pings-with-the-blackbox-exporter|ICMP Pings with the Blackbox exporter]], [[https://​github.com/​prometheus/​blackbox_exporter?​tab=readme-ov-file#​permissions|github blackbox_exporter permissions]],​ [[POSIX capabilities]] или [[Управление ядром и модулями в Linux#​Переменные ядра]]   * [[https://​www.robustperception.io/​icmp-pings-with-the-blackbox-exporter|ICMP Pings with the Blackbox exporter]], [[https://​github.com/​prometheus/​blackbox_exporter?​tab=readme-ov-file#​permissions|github blackbox_exporter permissions]],​ [[POSIX capabilities]] или [[Управление ядром и модулями в Linux#​Переменные ядра]]
сервис_prometheus.1795772766.txt.gz · Last modified: 2026/11/27 12:46 by val