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 [2021/04/20 10:40]
val [prometheus-snmp-exporter]
сервис_prometheus [2023/10/12 16:54] (current)
val [Сервис Prometheus]
Line 4: Line 4:
   * [[https://​habr.com/​ru/​company/​southbridge/​blog/​455290/​|Полное руководство по Prometheus в 2019 году]]   * [[https://​habr.com/​ru/​company/​southbridge/​blog/​455290/​|Полное руководство по Prometheus в 2019 году]]
   * [[https://​www.shellhacks.com/​ru/​prometheus-delete-time-series-metrics/​|Prometheus:​ Удаление Метрик Временных Рядов]]   * [[https://​www.shellhacks.com/​ru/​prometheus-delete-time-series-metrics/​|Prometheus:​ Удаление Метрик Временных Рядов]]
 +  * [[https://​habr.com/​ru/​companies/​tochka/​articles/​683608/​|Человеческим языком про метрики]]
 +  * [[https://​selectel.ru/​blog/​tutorials/​monitoring-in-k8s-with-prometheus/​|Мониторинг в K8s с помощью Prometheus]]
  
-===== Установка в Debian ​10 ===== +===== Установка в Debian/​Ubuntu ​=====
- +
-  * [[Сервис MTA#​Установка и настройка MTA на обработку почты домена hostname]]+
  
 <​code>​ <​code>​
 # apt install prometheus # apt install prometheus
 +
 +# less /​etc/​prometheus/​prometheus.yml
 +</​code><​code>​
 +...
 +global:
 +  scrape_interval: ​    15s
 +...
 </​code>​ </​code>​
  
Line 24: Line 31:
  
   * [[http://​server.corpX.un:​9090/​targets]]   * [[http://​server.corpX.un:​9090/​targets]]
 +  * [[http://​server:​9090/​classic/​targets]]
   * [[http://​192.168.X.10:​9090/​metrics]]   * [[http://​192.168.X.10:​9090/​metrics]]
   * [[http://​10.5.N.100+X:​9090/​graph]]   * [[http://​10.5.N.100+X:​9090/​graph]]
Line 36: Line 44:
   * [[https://​www.digitalocean.com/​community/​tutorials/​how-to-use-alertmanager-and-blackbox-exporter-to-monitor-your-web-server-on-ubuntu-16-04|How To Use Alertmanager And Blackbox Exporter To Monitor Your Web Server On Ubuntu 16.04]]   * [[https://​www.digitalocean.com/​community/​tutorials/​how-to-use-alertmanager-and-blackbox-exporter-to-monitor-your-web-server-on-ubuntu-16-04|How To Use Alertmanager And Blackbox Exporter To Monitor Your Web Server On Ubuntu 16.04]]
   * [[https://​awesome-prometheus-alerts.grep.to/​|Awesome Prometheus alerts]]   * [[https://​awesome-prometheus-alerts.grep.to/​|Awesome Prometheus alerts]]
 +
 +  * [[Сервис MTA#​Установка и настройка MTA на обработку почты домена hostname]]
  
 <​code>​ <​code>​
Line 47: Line 57:
   smtp_from: '​prometheus@server.corpX.un'​   smtp_from: '​prometheus@server.corpX.un'​
   smtp_require_tls:​ false   smtp_require_tls:​ false
 +#  smtp_auth_username:​ '​alertmanager'​
 +#  smtp_auth_password:​ '​password'​
 ... ...
   # A default receiver   # A default receiver
Line 59: Line 71:
 ... ...
 </​code><​code>​ </​code><​code>​
 +# service prometheus-alertmanager restart
 +
 # cat /​etc/​prometheus/​first_rules.yml # cat /​etc/​prometheus/​first_rules.yml
 </​code><​code>​ </​code><​code>​
Line 82: Line 96:
  
   - alert: CriticalTraffic   - alert: CriticalTraffic
-    expr: rate(if_in_octets{instance="​router"​}[1m])>​125000+    expr: rate(ifInOctets{instance="​router"​}[1m])>​125000
     for: 1m     for: 1m
     labels:     labels:
Line 114: Line 128:
 ... ...
 </​code>​ </​code>​
 +
 +  * [[http://​192.168.X.10:​9090/​alerts]]
 ===== Exporters ===== ===== Exporters =====
  
 ==== prometheus-node-exporter ==== ==== prometheus-node-exporter ====
  
-  * В Debian ставится как зависимость к пакету prometheus и добавлен в конфигурацию+  * В Debian/​Ubuntu ​ставится как зависимость к пакету prometheus и добавлен в конфигурацию
   * [[http://​server.corpX.un:​9100/​metrics]]   * [[http://​server.corpX.un:​9100/​metrics]]
  
Line 135: Line 151:
 == node_network_receive_bytes_total == == node_network_receive_bytes_total ==
 <​code>​ <​code>​
-$ cat /​sys/​class/​net/​eth1/​statistics/​rx_bytes+$ cat /​sys/​class/​net/​eth0/​statistics/​rx_bytes 
 +  или 
 +$ cat /​sys/​class/​net/​bond0/​statistics/​rx_bytes
  
 # TYPE node_network_receive_bytes_total counter # TYPE node_network_receive_bytes_total counter
-node_network_receive_bytes_total{device="​eth1"}+node_network_receive_bytes_total{device="​bond0"}
 </​code>​ </​code>​
  
Line 157: Line 175:
 8*rate(node_network_receive_bytes_total[1m]) 8*rate(node_network_receive_bytes_total[1m])
  
-8*rate(node_network_receive_bytes_total{device="​eth1"​}[1m])+8*rate(node_network_receive_bytes_total{device="​bond0"​}[1m])
  
-8*rate(node_network_receive_bytes_total{device="​eth1",​instance="​localhost:​9100",​job="​node"​}[1m])+8*rate(node_network_receive_bytes_total{device="​eth0",​instance="​localhost:​9100",​job="​node"​}[1m])
 </​code>​ </​code>​
  
Line 187: Line 205:
 # cat /​etc/​prometheus/​prometheus.yml # cat /​etc/​prometheus/​prometheus.yml
 </​code><​code>​ </​code><​code>​
 +...
   - job_name: check_http   - job_name: check_http
     metrics_path:​ /probe     metrics_path:​ /probe
Line 193: Line 212:
     static_configs:​     static_configs:​
       - targets:       - targets:
-        - http://val.bmstu.ru+        - https://google.com
         - https://​ya.ru         - https://​ya.ru
     relabel_configs:​     relabel_configs:​
Line 201: Line 220:
         target_label:​ instance         target_label:​ instance
       - target_label:​ __address__       - target_label:​ __address__
-        replacement: ​127.0.0.1:9115+        replacement: ​localhost:9115
  
   - job_name: check_ssh   - job_name: check_ssh
Line 218: Line 237:
         target_label:​ instance         target_label:​ instance
       - target_label:​ __address__       - target_label:​ __address__
-        replacement: ​127.0.0.1:9115+        replacement: ​localhost:9115
 </​code>​ </​code>​
  
Line 264: Line 283:
 </​code><​code>​ </​code><​code>​
 # cat /​etc/​prometheus/​switchs.yml # cat /​etc/​prometheus/​switchs.yml
 +</​code><​code>​
 - targets: - targets:
   - switch1   - switch1
Line 278: Line 298:
 <​code>​ <​code>​
 # apt install prometheus-snmp-exporter # apt install prometheus-snmp-exporter
 +</​code>​
  
 +=== Создание файла конфигурации "​вручную"​ ===
 +
 +<​code>​
 # cat /​etc/​prometheus/​snmp.yml # cat /​etc/​prometheus/​snmp.yml
 </​code><​code>​ </​code><​code>​
Line 291: Line 315:
   - 1.3.6.1.2.1.2.2.1.2   - 1.3.6.1.2.1.2.2.1.2
   metrics:   metrics:
-  - name: if_in_octets+  - name: ifInOctets
     oid: 1.3.6.1.2.1.2.2.1.10     oid: 1.3.6.1.2.1.2.2.1.10
     type: counter     type: counter
Line 303: Line 327:
       oid: 1.3.6.1.2.1.2.2.1.2       oid: 1.3.6.1.2.1.2.2.1.2
       type: DisplayString       type: DisplayString
-  - name: if_out_octets+  - name: ifOutOctets
     oid: 1.3.6.1.2.1.2.2.1.16     oid: 1.3.6.1.2.1.2.2.1.16
     type: counter     type: counter
Line 315: Line 339:
       oid: 1.3.6.1.2.1.2.2.1.2       oid: 1.3.6.1.2.1.2.2.1.2
       type: DisplayString       type: DisplayString
-</​code><​code>​+</​code>​ 
 + 
 +=== Создание файла конфигурации через "​generator"​ === 
 + 
 +<​code>​ 
 +# cp /​usr/​share/​doc/​prometheus-snmp-exporter/​examples/​generator.yml . 
 + 
 +# prometheus-snmp-generator generate 
 + 
 +# cp snmp.yml /​etc/​prometheus/​snmp.yml 
 +</​code>​ 
 + 
 +=== Примеры использования === 
 + 
 +<​code>​
 # service prometheus-snmp-exporter restart # service prometheus-snmp-exporter restart
 </​code>​ </​code>​
Line 323: Line 361:
 <​code>​ <​code>​
 # curl --noproxy 127.0.0.1 '​http://​127.0.0.1:​9116/​snmp?​target=router&​module=snmp_in_out_octets'​ # curl --noproxy 127.0.0.1 '​http://​127.0.0.1:​9116/​snmp?​target=router&​module=snmp_in_out_octets'​
 +  или
 +# curl '​http://​127.0.0.1:​9116/​snmp?​target=router'​
 </​code><​code>​ </​code><​code>​
 # cat /​etc/​prometheus/​prometheus.yml # cat /​etc/​prometheus/​prometheus.yml
Line 332: Line 372:
         - router         - router
     metrics_path:​ /snmp     metrics_path:​ /snmp
-    params: +    params: ​                              # no need  
-      module: [snmp_in_out_octets]+      module: [snmp_in_out_octets] ​       # if if_mib
     relabel_configs:​     relabel_configs:​
       - source_labels:​ [__address__]       - source_labels:​ [__address__]
Line 346: Line 386:
  
 <​code>​ <​code>​
-rate(if_in_octets{ifDescr="​FastEthernet1/​1",​ifIndex="​3",​instance="​router",​job="​snmp"​}[1m])+rate(ifInOctets{ifDescr="​FastEthernet0/0",​ifIndex="​1",instance="​router",​job="​snmp"​}[1m]) 
 +  или 
 +rate(ifOutOctets{ifIndex="​5",​instance="​router",​job="​snmp"​}[1m])
  
-8*rate(if_in_octets{ifDescr="​FastEthernet1/1",​instance="​router"​}[1m])+8*rate(ifInOctets{ifDescr="​FastEthernet0/0",​instance="​router"​}[1m]) 
 +  или 
 +8*rate(ifOutOctets{ifDescr="​Port-channel1",​instance="​router"​}[1m])
 </​code>​ </​code>​
  
Line 360: Line 404:
 </​code><​code>​ </​code><​code>​
 ... ...
-  - job_name: 'Pushgateway'+  - job_name: 'pushgateway'
     honor_labels:​ true     honor_labels:​ true
     static_configs:​     static_configs:​
Line 388: Line 432:
 </​code><​code>​ </​code><​code>​
 ip_dhcp_binding{dhcp_server="​router",​job="​cisco_dhcp",​net="​192.168"​} ip_dhcp_binding{dhcp_server="​router",​job="​cisco_dhcp",​net="​192.168"​}
 +</​code><​code>​
 +# crontab -l
 +</​code><​code>​
 +* * * * * /​root/​ip_dhcp_binding.sh
 </​code>​ </​code>​
сервис_prometheus.1618904420.txt.gz · Last modified: 2021/04/20 10:40 by val