主頁 >  其他 > 使用開源軟體Prometheus監控企業內部應用

使用開源軟體Prometheus監控企業內部應用

2021-08-20 09:41:59 其他

使用開源軟體Prometheus監控企業內部資源

1. 寫在前面

? 在公司行政管理大區內,因為業務體量小,業務變化相對少,之前公司采用的監控技術堆疊較為落后,只有簡單的北塔網路監控,基本沒有任何的監控平臺,

? 接觸Docker和kubernetes時間久了,開源的監控方案所接觸,網上也有不少Zabbix、Nagios、Open-Falcon、Prometheus、Influxdb的對比這里就不一一列舉了,最終公司選擇Prometheus+Grafana+explorer技術堆疊作為企業內部IT資源監控,Prometheus各型別采集器豐富,Grafana儀表板顏值高,基于Docker-compose部署方便,該專案自2018年實施已穩定運行三年,極大縮短了故障排查時間,

2. 監控資源分析

內部需要監控的資源有

  1. 網路資源:如交換機SNMP、交換機各埠流量
  2. Windows資源:Windows服務器運行時間、CPU使用率、記憶體使用率、磁盤使用率、磁盤IO、行程數、服務數、網路帶寬情況等
  3. Linux資源:Linux服務器運行時間、CPU使用率、打開檔案描述符、背景關系切換次數、記憶體使用率、磁盤使用率、磁盤IO、網路帶寬情況等
  4. Docker資源:各容器CPU使用率、記憶體使用率、網路帶寬情況、磁盤io等
  5. vSphere資源:vSphere物理節點記憶體、CPU、虛擬機、網路情況,各虛擬機CPU使用率、CPU就緒時間、網路封包、磁盤IO等,
  6. Oracle資料庫性能情況:資料庫狀態、執行統計、用戶提交/回滾數量、行程數量、表空間使用情況、IO、資源利用率等,
  7. JVM監控:Java版本、運行時間、加載類總數、執行緒數量、執行緒峰值、死鎖執行緒數量、gc次數等
  8. 存盤資源監控:Ceph OSD狀態等
  9. 其他型別監控:連通類監控如埠、HTTP,SSL證書狀態監控等

根據監控資源在GitHub以及Prometheus官網內收集推薦的exporter,總結如下:

監控資源exporter名稱部署方式專案地址
SNMPsnmp_exporter代理部署https://github.com/prometheus/snmp_exporter
Windowswindows_exporter實體部署https://github.com/prometheus-community/windows_exporter
Linuxnode_exporter實體部署https://github.com/prometheus/node_exporter
Dockercadvisor實體部署https://github.com/google/cadvisor/releases/latest
vSpherevmware_exporter代理部署https://github.com/pryorda/vmware_exporter
Oracleoracledb_exporter實體部署https://github.com/iamseth/oracledb_exporter
JVMjmx_exporter實體部署https://github.com/prometheus/jmx_exporter
Cephceph_mgr實體自帶
其他Blackbox_exporter代理部署https://github.com/prometheus/blackbox_exporter

這是官網上收錄的exporter:https://prometheus.io/docs/instrumenting/exporters/

也可以在GitHub上搜,比如Proxmox就沒有收錄在官方檔案內,

3. 整體架構及實施效果

本次采用Docker-Compose的方式搭建部署,參照Github上的https://github.com/vegasbrianc/prometheus.git進行二次開發,

拓撲如下:

在這里插入圖片描述

目錄結構如下:

.
├── alertmanager                              #alertmanager 告警模塊
│   ├── config.yml                              #alertmanager 組態檔
│   └── wechat.tmpl                             #alertmanager weChat通知配置
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── dashboards                                #Grafana默認Dashboard
│   ├── Grafana_Dashboard.json
│   ├── Grafana_Dashboard_prom_2.json
│   └── System_Monitoring.json
├── docker-compose.yml                        #主要Docker-compose檔案
├── docker-prometheus.dockerapp
│   └── docker-compose.yml
├── docker-stack.yml
├── docker-traefik-stack.yml
├── exporter                                  #explorer 模塊
│   ├── blackbox.yml                           #blackbox_exporter組態檔
│   ├── oracle_exporter.config                 #oracle_exporter組態檔
│   ├── snmp.yml                               #snmp_exporter組態檔
│   └── vmware_exporter.config                 #vmware_exporter組態檔
├── grafana                                   #Grafana 模塊
│   ├── config.monitoring                      #Grafana 組態檔夾
│   └── provisioning
│       ├── dashboards
│       │   ├── dashboard.yml
│       │   └── Docker Prometheus Monitoring-1571332751387.json
│       └── datasources
│           └── datasource.yml
├── Grafana_Dashboard.json
├── Grafana Dashboard With Service.json
├── HighLoadDashboard.json
├── images
│   ├── Add_Data_Source.png
│   ├── Dashboard.png
│   ├── Import_Dashboard.png
│   └── mac-filesystem.png
├── ISSUE_TEMPLATE.md
├── LICENSE
├── m3db
├── prometheus                               #prometheus 模塊
│   ├── alert.rules                           #prometheus 告警配置
│   └── prometheus.yml                        #prometheus 配置
├── pwd-stack.yml
└── README.md

我們主要關注prometheus、alertmanager、explorer、Grafana的配置以及docker-compose.yml 即可,在配置完成后,最終專案實施效果如下:

企業微信告警:

在這里插入圖片描述

監控大屏

在這里插入圖片描述

4. Docker-compose配置決議

Docker-compose 可以參照https://github.com/vegasbrianc/prometheus.git上的docker-compose.yml進行修改

該docker-compose主要配置prometheus服務、alertmanager服務、Grafana服務以及需要代理部署的exporter,

prometheus服務:

注:可在docker-compose中配置命令列引數 --storage.tsdb.retention,時間不建議配太長,容易造成磁盤IO高

通過ip:9090埠訪問

version: '3.7'

volumes:
    prometheus_data: {}
    grafana_data: {}

networks:
  front-tier:
  back-tier:

services:
  prometheus:
    image: prom/prometheus:v2.1.0
    volumes:
      - ./prometheus/:/etc/prometheus/
      - prometheus_data:/prometheus
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'                     #定義prometheus組態檔在容器內的地址
      - '--storage.tsdb.path=/prometheus'                                  #定義prometheus資料在容器內的地址
      - '--storage.tsdb.retention=30d'                                     #定義prometheus保存周期
      - '--web.console.libraries=/usr/share/prometheus/console_libraries'
      - '--web.console.templates=/usr/share/prometheus/consoles'

    ports:
      - 9090:9090
    links:
      - cadvisor:cadvisor
      - alertmanager:alertmanager
#      - m3db:m3db      
    depends_on:
      - cadvisor
#      - m3db:m3db
    networks:
      - back-tier
    restart: always
#  m3db:                                       預留m3db作為后端持久化存盤
#    image: quay.io/m3db/m3dbnode:latest
#    volumes:
#      - ./m3db/:/var/lib/m3db
#    ports:
#      - 7201:7201
#      - 7203:7203
#      - 9003:9003
#    networks:
#      - back-tier
#    restart: always
#    deploy:
#      mode: global

...

alertmanager服務

通過ip:9093埠訪問

...
  alertmanager:
    image: prom/alertmanager
    ports:
      - 9093:9093
    volumes:
      - ./alertmanager/:/etc/alertmanager/
    networks:
      - back-tier
    restart: always
    command:
      - '--config.file=/etc/alertmanager/config.yml'
      - '--storage.path=/alertmanager'

...

grafana服務

通過ip:3000埠訪問

...
grafana:
    image: grafana/grafana
    user: "472"
    depends_on:
      - prometheus
    ports:
      - 3000:3000
    volumes:
      - grafana_data:/var/lib/grafana
      - ./grafana/provisioning/:/etc/grafana/provisioning/
    env_file:
      - ./grafana/config.monitoring
    networks:
      - back-tier
      - front-tier
    restart: always

5. Prometheus及Exporter配置

根據Exporter性質,代理部署的Exporter可直接配置在Docker-compose.yml,與prometheus同一個主機,實體部署需要每個實體上部署單獨的Exporter,

建議每個Exporter都用Docker-compose進行納管,

5.1 Prometheus 配置決議

Prometheus 配置位于/prometheus/prometheus.yml 下,主要配置引數可以參考https://prometheus.io/docs/prometheus/latest/configuration/configuration/

5.1.1 組態檔指標說明

  • global: 全域配置(如果有內部單獨設定,會覆寫這個引數)
  • alerting: 告警插件定義,這里會設定alertmanager這個報警插件,
  • rule_files: 告警規則, 按照設定引數進行掃描加載,用于自定義報警規則,其報警媒介和route路由由alertmanager插件實作,
  • scrape_configs:采集配置,配置資料源,包含分組job_name以及具體target,采集配置又分為靜態配置和服務發現

原始組態檔內容:

# 全域配置
global:
  scrape_interval:     15s #  默認全域每次資料收集的間隔為15s.
  evaluation_interval: 15s #  規則掃描時間間隔是15秒,默認不填寫是 1分鐘
  # scrape_timeout: 10s    #默認收集超時時間為10s
 
# 告警配置
alerting:
  alertmanagers:
  - scheme: http
    static_configs:
    - targets:
      - alertmanager:9093 # 告警配置目標設定應與docker-compose中的alertmanager service名稱相同
 
#告警規則加載
rule_files:
  - 'alert.rules'
  # - "second_rules.yml"
 
# 采集配置(靜態)
scrape_configs:
  - job_name: 'prometheus'            #獨立部署配置
    static_configs:
    - targets: 
      - localhost:9090
    
  - job_name: '其他區域交換機'              #代理部署配置需要配上,relabel_configs
    metrics_path: /snmp                   #metrics_path指的是exporter訪問路徑 
    params:                               #exporter訪問引數 
      module: [if_mib]
    static_configs:
      - targets:
        - **.**.**.**
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: **.**.**.**:9116  # 替換引數名稱   
#通過配置file服務發現 獲取target 'test'
file_sd_configs:
    - files:
      - /etc/prometheus/file_config/host.json  

5.1 node_exporter 配置

5.1.1 實體部署

node_exporter采用go語言開發,專門用來收集*NIX系統中硬體、系統指標,需要在每個實體主機上部署Docker-compose.yml如下:

version: '3.7'

services:
  node_exporter:
    image: prom/node_exporter
    volumes:
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
    command: 
      - '--path.procfs=/host/proc' 
      - '--path.sysfs=/host/sys'
      - '--collector.filesystem.ignored-mount-points'
      - "^/(sys|proc|dev|host|etc|rootfs/var/lib/docker/containers|rootfs/var/lib/docker/overlay2|rootfs/run/docker/netns|rootfs/var/lib/docker/aufs)($$|/)"
    ports:
      - 9100:9100
    restart: always

可見,node_exporter默認開放埠9100,運行后訪問http://ip:9100/metrics,能夠成功回傳資料即可

配置參考:

–collector.diskstats.ignored-devices="^(ram|loop|fd|(h|s|v|xv)d[a-z]|nvme\d+n\d+p)\d+$"
#通過正則運算式忽略某些磁盤的資訊收集

–collector.filesystem.ignored-mount-points="^/(dev|proc|sys|var/lib/docker/.+)($|/)"
#通過正則運算式忽略某些檔案系統掛載點的資訊收集

–collector.filesystem.ignored-fs-types="^(autofs|binfmt_misc|bpf|cgroup2?|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|mqueue|nsfs|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|selinuxfs|squashfs|sysfs|tracefs)$"
#通過正則運算式忽略某些檔案系統型別的資訊收集

–collector.netclass.ignored-devices="^$"
#通過正則運算式忽略某些網路類的資訊收集

–collector.netdev.ignored-devices="^$"
#通過正則運算式忽略某些網路設備的資訊收集

–collector.netstat.fields="^$"
#通過正則運算式配置需要獲取的網路狀態資訊

–collector.vmstat.fields="^(oom_kill|pgpg|pswp|pg.fault)."
#通過正則運算式配置vmstat回傳資訊中需要收集的選項

5.1.2 采集配置

在prometheus.yml中添加Job,targets指向已運行node-expoter的主機

  - job_name: 'linux-node'
    static_configs:
      - targets: 
        - 10.**.**.**:9100
        - 10.**.**.**:9100
  # 采集node exporter監控資料

5.1.3 儀表板配置

1 Node Exporter for Prometheus Dashboard CN v20201010 by StarsL.cnhttps://grafana.com/grafana/dashboards/8919

img
資源明細頁截圖 img

注意事項:


匯入看板后,請根據實際情況在看板右上角點擊Dashboard settingsVariables設定好變數:

默認已經設定并關聯好jobhostnamenode這3個變數,

  • $node取值node_exporter的instanceIP:埠格式,大部分查詢關聯了這個變數,請確保該變數有效!
  • $maxmount用來查詢當前主機的最大磁區,默認只獲取ext.*和xfs型別的磁區,

5.2 windows_exporter 配置

5.2.1 實體部署

windows_exporter,需要在每個Windows實體上部署,可以從https://github.com/prometheus-community/windows_exporter/releases/ 中下載msi檔案進行安裝,亦可以下載exe檔案直接執行,

軟體運行后訪問http://ip:9182/metrics,能夠成功回傳資料即可,

**注意: ** windows_exporter 不能用于Win7及Windows 2008 R2 以前的版本,

wmi_exporter 宣布更名成windows_exporter后就不支持老版本的Windows,舊版本請下載windows_exporter 0.9.0(wmi_exporter)以前的版本(exe),新版本的指標為window開頭,舊版本指標為wmi開頭,相應的Dashboard需要跟著修改,

5.2.2 采集配置

同node_exporter

5.2.3 儀表板配置

1 windows_exporter for Prometheus Dashboard CN v20201012 by StarsL.cn

https://grafana.com/grafana/dashboards/10467

img

win2k系列的 wmi_exporter采用該儀表板

3 wmi_exporter 0.7.0+ for Prometheus 監控展示看板(windows監控)

https://grafana.com/grafana/dashboards/11230

在這里插入圖片描述

5.3 blackbox_exporter 配置

5.3.1 實體部署

blackbox_exporter是代理部署,僅需部署單個實體,通過blackbox.yml告知blackbox_exporter啟用哪些監聽模塊,通過Prometheus配置prometheus.yml實作具體業務探針,Blackbox由于其靈活性,可以探測http、ssh、dns、證書等,是使用率最高的一個模塊,

Docker-compose.yml示例如下

version: '3.7'

services:
  blackbox_exporter:
    image: prom/blackbox_exporter:master
    depends_on:
      - prometheus
    ports:
      - 9115:9115
    command:
      - '--config.file=/config/blackbox.yml'
    volumes:
      - ./exporter/blackbox.yml:/config/blackbox.yml
    networks:
      - back-tier
    restart: always

blackbox.yml配置如下:

modules:
    http_2xx:
      prober: http
      timeout: 10s
      http:
        preferred_ip_protocol: "ip4" ## 如果http監測是使用ipv4 就要寫上,目前國內使用ipv6很少,
        tls: true
        tls_config:
          insecure_skip_verify: true     #因為是自簽名證書,故配
          
    http_post_2xx_query: ## 用于post請求使用的模塊)由于每個介面傳參不同 可以定義多個module 
                         ## 用于不同介面(例如此命名為http_post_2xx_query 用于監測query.action介面 
      prober: http
      timeout: 15s
      http:
        preferred_ip_protocol: "ip4" ##使用ipv4
        method: POST
        headers:
          Content-Type: application/json ##header頭
        body: '{"hmac":"","params":{"publicFundsKeyWords":"xxx"}}' ##傳參
    tcp_connect:         ##  TCP模塊
      prober: tcp
    pop3s_banner:
      prober: tcp
      tcp:
        query_response:
        - expect: "^+OK"
        tls: true
        tls_config:
          insecure_skip_verify: false
    ssh_banner:
      prober: tcp
      tcp:
        query_response:
        - expect: "^SSH-2.0-"
    irc_banner:
      prober: tcp
      tcp:
        query_response:
        - send: "NICK prober"
        - send: "USER prober prober prober :prober"
        - expect: "PING :([^ ]+)"
          send: "PONG ${1}"
        - expect: "^:[^ ]+ 001"
    icmp:          ##  icmp模塊  
      prober: icmp
      timeout: 5s
      icmp:
    dns_gdyd:      ##  dns模塊
      prober: dns
      timeout: 5s
      dns:
        query_name: "phpoa.gdyd.com"  #檢查指定DNS記錄
        query_type: "A"
        valid_rcodes:
        - NOERROR

5.3.2 采集配置

由于blackbox_exporter屬于代理配置,需要在每個Job下面增加標簽重命名,否則所有被探測的實體都只會顯示blackbox_exporter的ip

  - job_name: "blackbox_埠監控"

...
    relabel_configs:                    
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 10.45.**.xx:9115 

ICMP監控(Ping)

由于target很多,這里按照target進行分組,并附上labels標簽env作為區分

  - job_name: 'blackbox_ping'
    scrape_interval: 5s
    metrics_path: /probe
    params:
      module: [icmp]  #ping
    static_configs:
      - targets: 
        - 10.**.**.**
        labels:
          env: '門禁設備'
      - targets: 
        - 10.**.**.**
        labels:
          env: '網路安全設備'
      - targets: 
        - 10.**.**.**
        - 10.**.**.**
        - 10.**.**.**
        - 10.**.**.**
        labels:
          env: '綜合辦公樓交換機'
      - targets: 
        - 10.**.**.**
        - 10.**.**.**
        - 10.**.**.**
        - 10.**.**.**
        - 10.**.**.**
        - 10.**.**.**
        labels:
          env: '中心機房交換機'
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 10.45.**.**:9115  # Blackbox exporter.

blackbox_埠監控

使用blackbox tcp_connect模塊,相關模塊配置在blackbox.yml

  - job_name: "blackbox_埠監控"
    scrape_interval: 5s
    metrics_path: /probe
    params:
      module: [tcp_connect] #呼叫tcp_connect模塊
    static_configs:
      - targets: 
        - '10.**.**.xx:8200'
        labels:
          env: 'SIS時序資料庫'
      - targets: 
        - '10.**.**.xx:1521'
        labels:
          env: 'Oracle資料庫'
      - targets: 
        - 10.**.**.xx:3306
        labels:
          env: 'Mysql資料庫'
    relabel_configs:                    
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 10.**.**.xx:9115 #blackbox_exporter ip

HTTP監控實體

相關模塊配置在blackbox.yml,注意 insecure_skip_verify: true必須加上,否則自簽證書的http監控會報無法連接,

modules:
    http_2xx:
      prober: http
      timeout: 10s
      http:
        preferred_ip_protocol: "ip4" ## 如果http監測是使用ipv4 就要寫上,目前國內使用ipv6很少,
        tls: true
        tls_config:
          insecure_skip_verify: true     #因為是自簽名證書,故配該選項
          

prometheus.yml

  - job_name: 'blackbox_HTTP監控'
    scrape_interval: 45s
    metrics_path: /probe
    params:
      module: [http_2xx]  # Look for a HTTP 200 response.
    static_configs:
      - targets:
        - http://10.45.**.**
        - http://phpoa.gdyd.com/
        - https://www.baidu.com
        - https://mail.dms.yudean.com
        - http://eip.itc.gdyd.com/static/d/realtimeload.html
        - https://mobile.gdphdc.com:***/lead_adapter/portal/login.lead
        
        labels:
          env: 'HTTP業務'
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 10.**.**.**:9115  # The blackbox exporter's real hostname:port.

DNS監控配置

dns監控需要告知blackbox指定的域名決議,若域名決議成功,證明dns正常,blackbox.yaml配置如下

    dns_gdyd:      ##  dns模塊
      prober: dns
      timeout: 5s
      dns:
        query_name: "phpoa.gdyd.com"  #檢查指定DNS A記錄
        query_type: "A"
        valid_rcodes:
        - NOERROR

prometheus.yml

  - job_name: "blackbox_dns"
    scrape_interval: 5s
    static_configs:
    metrics_path: /probe
    params:
      module: [dns_gdyd]
    static_configs:    
      - targets: 
        - 10.45.**.**
        - 10.45.**.**
        labels:
          env: '集團DNS業務'
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 10.**.**.**:9115

5.3.3 儀表板配置

2 Blackbox Exporter 0.14 for Prometheus 監控展示看板by StarsL.cn

https://grafana.com/grafana/dashboards/9965

目前在使用的TCP,ICMP,HTTPS服務狀態監控 Prometheus Blackbox Exporter,在一個看板里面展示,做了展示效果的優化,支持多服務同時展示,需要使用的可以參考下,記得根據自己的實際情況修改下變數,

記得安裝餅圖插件

在這里插入圖片描述

5.4 snmp_exporter 配置

snmp_exporter的配置為snmp.yml,該配置需要用SNMP Exporter Config Generator來生成,

5.4.1 實體部署

  1. 用Docker方式使用SNMP Exporter Config Generator生成snmp.yml,Generator位于snmp_exporter/generator

    #克隆snmp_exporter專案
    git clone https://github.com/prometheus/snmp_exporter.git
    
    #創建mibs檔案夾
    cd snmp_exporter/generator
    mkdir mibs
    
  2. 將交換機的mib檔案放入mib檔案夾內,

    收集 MIBs

    • Cisco: ftp://ftp.cisco.com/pub/mibs/v2/v2.tar.gz
    • APC: https://download.schneider-electric.com/files?p_File_Name=powernet432.mib
    • Servertech: ftp://ftp.servertech.com/Pub/SNMP/sentry3/Sentry3.mib
    • Palo Alto PanOS 7.0 enterprise MIBs: https://www.paloaltonetworks.com/content/dam/pan/en_US/assets/zip/technical-documentation/snmp-mib-modules/PAN-MIB-MODULES-7.0.zip
    • Arista Networks: https://www.arista.com/assets/data/docs/MIBS/ARISTA-ENTITY-SENSOR-MIB.txt https://www.arista.com/assets/data/docs/MIBS/ARISTA-SW-IP-FORWARDING-MIB.txt https://www.arista.com/assets/data/docs/MIBS/ARISTA-SMI-MIB.txt
    • Synology: https://global.download.synology.com/download/Document/Software/DeveloperGuide/Firmware/DSM/All/enu/Synology_MIB_File.zip
    • MikroTik: http://download2.mikrotik.com/Mikrotik.mib
    • UCD-SNMP-MIB (Net-SNMP): http://www.net-snmp.org/docs/mibs/UCD-SNMP-MIB.txt
    • Ubiquiti Networks: http://dl.ubnt-ut.com/snmp/UBNT-MIB http://dl.ubnt-ut.com/snmp/UBNT-UniFi-MIB https://dl.ubnt.com/firmwares/airos-ubnt-mib/ubnt-mib.zip

    這是一個很全的mib庫:https://github.com/librenms/librenms/tree/master/mibs

  3. 使用snmptranslate查看MIB相關oid

    snmptranslate -Tz -m mib檔案
    
  4. 修改generator.yml,提供模塊串列,最簡單的模塊只是一個名稱和一組要遍歷的 OID,

    modules:
      if_mib:
        walk:
         - 1.3.6.1.4.1.41475 #自定義oid
        version: 2
        auth:
          community: ****  #snmp團體名密碼
    
  5. 生成snmp.yml,

    make mibs
    docker build -t snmp-generator .
    docker run -ti \
      -v "${PWD}:/opt/" \
      snmp-generator generate
    

使用docker-compose啟動smnp_exporter

version: '3.7'

services:
  snmp_exporter:
    image: prom/snmp_exporter-linux-amd64
    depends_on:
      - prometheus
    ports:
      - 9116:9116
    volumes:
      - ./exporter/snmp.yml:/etc/snmp_exporter/snmp.yml
    networks:
      - back-tier
    restart: always

至此已完成smnp實體部署,

5.4.2 采集配置

  - job_name: 'BJ-BG-Center-3750-A'  # 交換機型別的名稱表示采用Job做區分,然后多類交換機寫多個Job對應即可
    static_configs:
      - targets: 
        - '192.168.4.1'  # 交換機的IP地址
    metrics_path: /snmp
    params:
      module: [if_mib] # 如果是其他設備,可以采用其他模塊,比如cisco_wlc AP設備, ddwrt 軟路由等等
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 10.**.**.**:9116  

5.4.3 儀表板配置

可根據這個儀表板做一下修改

https://grafana.com/grafana/dashboards/1124

在這里插入圖片描述

5.5 vmware_exporter 配置

5.5.1 實體部署

vmware_exporter屬于實體部署exporter,可以向其傳遞環境變數或組態檔,傳遞環境變數需要大寫,傳遞組態檔需要在命令列中增加 -c config.yml ,以下采用外掛環境變數檔案進行傳參

version: '3.7'
services:
  vmware_exporter:
    image: pryorda/vmware_exporter
    depends_on:
      - prometheus
    ports:
      - 9272:9272
    env_file:
      - ./exporter/vmware_exporter.config
    networks:
      - back-tier
    restart: always

vmware_exporter.config 如下

VSPHERE_USER=administrator@vsphere.local  #vsphere用戶名
VSPHERE_PASSWORD=****                     #vsphere密碼
VSPHERE_HOST=10.**.**.**                  #vsphere 地址
VSPHERE_IGNORE_SSL=True                   # 忽略證書錯誤
VSPHERE_SPECS_SIZE=2000

其他環境變數及配置說明如下:

環境變數配置方式默認描述
VSPHERE_HOSTconfig, env, get_paramn/avsphere server地址
VSPHERE_USERconfig, envn/avsphere User
VSPHERE_PASSWORDconfig, envn/avsphere Password
VSPHERE_SPECS_SIZEconfig, env5000Size of specs list for query stats function
VSPHERE_IGNORE_SSLconfig, envFalse忽略證書錯誤
VSPHERE_FETCH_CUSTOM_ATTRIBUTESconfig, envFalse是否獲取自定義屬性
VSPHERE_FETCH_TAGSconfig, envFalse是否獲取自定義標簽
VSPHERE_FETCH_ALARMSconfig, envFalse是否獲取告警
VSPHERE_COLLECT_HOSTSconfig, envTrue是否獲取主機資訊
VSPHERE_COLLECT_DATASTORESconfig, envTrue是否獲取存盤資訊
VSPHERE_COLLECT_VMSconfig, envTrue是否獲取虛擬機資訊
VSPHERE_COLLECT_VMGUESTSconfig, envTrue是否獲取虛擬機guest資訊
VSPHERE_COLLECT_SNAPSHOTSconfig, envTrue是否獲取快照資訊

詳情參見:https://github.com/pryorda/vmware_exporter

5.5.2 采集配置

- job_name: vmware_export
    metrics_path: /metrics
    static_configs:
    - targets:
      - vcenter01
      - vcenter02
      - vcenter03
    relabel_configs:
    - source_labels: [__address__]
      target_label: __param_target
    - source_labels: [__param_target]
      target_label: instance
    - target_label: __address__
      replacement: exporter_ip:9272

5.6 oracle_exporter 配置

略,實驗證明oracle_exporter對公司內Oracle 10版本來說不太穩定,隔一段時間后會掛,且對Oracle資料庫具有一定的壓力,后放棄對Oracle的監控,可參考https://github.com/iamseth/oracledb_exporter

5.7 ceph-mgr配置

5.7.1 實體部署

在Ceph Luminous之前的版本,可以使用第三方的Prometheus exporterceph_exporter,

Ceph Luminous 12.2.1的mgr中自帶了Prometheus插件,內置了 Prometheus ceph exporter,可以使用Ceph mgr內置的exporter作為Prometheus的target,需要進入mgr節點輸入命令

# 啟用Ceph的Prometheus插件
ceph mgr module enable prometheus

5.7.2 采集配置

  - job_name: 'ceph_exporter'
    static_configs:
    - targets: ['10.**.**.**:9283']
      labels:
        instance: ceph
        cluster: ceph

5.7.3 儀表板配置

https://grafana.com/grafana/dashboards/2842

在這里插入圖片描述

5.8 容器監控配置

? 為了解決docker stats的問題(存盤、展示),谷歌開源了cadvisor不僅可以搜集一臺機器上所有運行的容器資訊,還提供基礎查詢界面和http介面,方便其他組件如Prometheus進行資料抓取,cAdvisor可以對節點機器上的資源及容器進行實時監控和性能資料采集,包括CPU使用情況、記憶體使用情況、網路吞吐量及檔案系統使用情況,Cadvisor使用Go語言開發,利用Linux的cgroups獲取容器的資源使用資訊,在K8S中集成在Kubelet里作為默認啟動項,官方標配,

5.8.1 實體配置

? 在有docker的主機上,執行以下命令

docker run \
  -v=/:/rootfs:ro \
  -v=/var/run:/var/run:rw \
  -v=/sys:/sys:ro \
  -v=/var/lib/docker/:/var/lib/docker:ro \
  -v=/dev/disk/:/dev/disk:ro \
  -p=8765:8080 \
  -d \
  --name=cadvisor \
  google/cadvisor:latest

注意:

在Ret Hat,CentOS, Fedora 等發行版上需要傳遞如下引數,因為 SELinux 加強了安全策略:

–privileged=true

啟動后訪問:http://127.0.0.1:8765查看頁面,/metric查看指標

5.8.2 采集配置

  - job_name: 'cadvisor'
    scrape_interval: 5s
    static_configs:
      - targets:
        - 10.**.**.**:8765

5.8.3 儀表盤配置

Docker monitoring with node selectionby Nazar

https://grafana.com/grafana/dashboards/8321

在這里插入圖片描述

5.9 Java監控配置

5.9.1 實體配置

Java監控需要運行Jmx_exporter,其原理是在Java運行的時候呼叫-javaagent引數,指定jar 運行,

  • jmx_prometheus_javaagent-0.16.1.jar 適用于 Java >= 7.
  • jmx_prometheus_javaagent-0.16.1_java6.jar 適用于 Java 6.
java -javaagent:./jmx_prometheus_javaagent-0.16.1.jar=埠名稱:config.yaml -jar springboot.jar

Tips:一般的Java中間件都會參考系統環境變數JAVA_OPTIONS,可以將-javaagent引數寫入JAVA_OPTIONS中

#Windows 環境變數寫法
JAVA_OPTIONS=%JAVA_OPTIONS%;-javaagent:c:\jmx_prometheus_javaagent-0.16.1.jar=8083:c:\config.yaml
#Linux 環境變數寫法
JAVA_OPTIONS=$JAVA_OPTIONS./jmx_prometheus_javaagent-0.16.1.jar=8083:config.yaml

config.yaml 可根據github上的示例,根據不同中間件來配置,

github上已有常見的weblogic、tomcat的配置,直接參考即可

https://github.com/prometheus/jmx_exporter/tree/master/example_configs

5.9.2 采集配置

采集配置根據引數中暴露的埠定義即可

  - job_name: 'java'
    scrape_interval: 5s
    static_configs:
      - targets:
        - 10.**.**.**:8083

5.9.3 儀表盤配置

JMX Overview by rogerw

在這里插入圖片描述

https://grafana.com/grafana/dashboards/3457

6. 告警配置決議

6.1 alertmanager配置

config.yml

global:
  resolve_timeout: 5m               # 在沒有報警的情況下宣告為已解決的時間
  # 配置郵件發送資訊
templates:    
 - '/etc/alertmanager/wechat.tmpl'  #告警模板
route:

  # 將傳入的報警中有這些標簽的分為一個組.
  # 比如, cluster=A 和 alertname=LatencyHigh 會分成一個組.
  group_by: ['alertname']
  
  # 指分組創建多久后才可以發送壓縮的警報,也就是初次發警報的延時.
  # 這樣會確保第一次通知的時候, 有更多的報警被壓縮在一起.
  group_wait: 10s

  # 當第一個通知發送,等待多久發送壓縮的警報
  group_interval: 10s

  # 默認的接收器
  receiver: 'wechat'
receivers:
 - name: 'wechat'					# 子節點 - 微信
   wechat_configs:					
   - corp_id: 'xxxxx'                 # 企業微信corpid 
     to_party: '13'                  # 組ID
     agent_id: '1000015'            # agentid
     api_secret: 'xxxxxxxxxxxxxxxxxxx'             # 企業微信corp secret
     send_resolved: true			# 告警解除后否發送通知

告警模板

wechat.tmpl,該檔案采用go temple決議模板

{{ define "wechat.default.message" }}{{ range $i, $alert :=.Alerts }}
告警狀態:{{   .Status }}
告警級別:{{ $alert.Labels.severity }}
告警型別:{{ $alert.Labels.alertname }}
告警應用:{{ $alert.Annotations.summary }}
告警主機:{{ $alert.Labels.instance }}
告警環境:{{ $alert.Labels.env }}
告警詳情:{{ $alert.Annotations.description }}
告警時間:{{ (.StartsAt.Add 28800e9).Format "2006-01-02 15:04:05" }}  #UTC時間需要增加基礎時間StartsAt.Add 28800e9
恢復時間: {{ (.EndsAt.Sub .StartsAt) }} 
------------------------------------------------
{{ end }}{{ end }}

6.2 告警規則

告警規則可以參照https://awesome-prometheus-alerts.grep.to/ ,這里根據公司需求收集并修改漢化了一下,

6.2.1 業務連通性告警

groups:
- name: 業務連通性監控
  rules:

  # Alert for any instance that is unreachable for >5 minutes.
  - alert: 業務連通性監控
    expr: probe_success == 0
    for: 2m
    labels:
      severity: 嚴重
    annotations:
      summary: "業務 {{ $labels.instance }} 丟失"
      description: " {{ $labels.job }} 檢測到環境 {{ $labels.env }} 的{{ $labels.instance }}狀態例外超過2分鐘."

  - alert: HTTP業務連通性監控
    expr: probe_http_status_code <= 199 OR probe_http_status_code >= 400
    for: 2m
    labels:
      severity: 嚴重
    annotations:
      summary: "HTTP業務 {{ $labels.instance }} 例外"
      description: "{{ $labels.job }} 檢測到環境 {{ $labels.env }} 的{{ $labels.instance }}狀態例外超過2分鐘."
  

6.2.2 SSL證書告警

- name: SSL證書監控
  rules:

  - alert: 證書30天提醒
    expr: probe_ssl_earliest_cert_expiry-time()< 86400 * 30
    for: 1d
    labels:
      severity: 提醒
    annotations:
      summary: "業務證書SSL {{ $labels.instance }} 即將過期"
      description: " {{ $labels.job }} 檢測到環境 {{ $labels.env }} 的{{ $labels.instance }} SSL證書過期時間小于30天."
  - alert: 證書15天提醒
    expr: probe_ssl_earliest_cert_expiry-time()< 86400 * 15
    for: 1d
    labels:
      severity: 告警
    annotations:
      summary: "業務證書SSL {{ $labels.instance }} 即將過期"
      description: " {{ $labels.job }} 檢測到環境 {{ $labels.env }} 的{{ $labels.instance }} SSL證書過期時間小于15天."


  - alert: 證書過期提醒
    expr: probe_ssl_earliest_cert_expiry-time()<= 0
    for: 1d
    labels:
      severity: 嚴重
    annotations:
      summary: "業務證書SSL {{ $labels.instance }} 過期"
      description: " {{ $labels.job }} 檢測到環境 {{ $labels.env }} 的{{ $labels.instance }} SSL證書過期."

6.2.3 虛擬機告警

- name: 虛擬主機告警
  rules:

  # Alert for any instance that is unreachable for >2 minutes.
  - alert: vSphere主機記憶體使用率超上限
    expr: vmware_host_memory_usage/vmware_host_memory_max*100>85
    for: 20m
    labels:
      severity: 告警
    annotations:
      summary: "vSphere主機 {{ $labels.host_name }} 主機記憶體使用率超高限85%"
      description: " {{ $labels.job }}\n檢測到環境vSphere主機 {{ $labels.host_name }} 主機記憶體使用率超高限85% 超過20分鐘.\n 當前值 = {{ $value }}"
  - alert: vSphere主機記憶體使用率超下限
    expr: vmware_host_memory_usage/vmware_host_memory_max*100<20
    for: 20m
    labels:
      severity: 告警
    annotations:
      summary: "vSphere主機 {{ $labels.host_name }} 主機記憶體使用率超限20%"
      description: " {{ $labels.job }}檢測到\n環境vSphere主機 {{ $labels.host_name }} 主機記憶體使用率超低限10% 超過20分鐘.\n 當前值 = {{ $value }}"

- name: 虛擬機告警
  rules:

  # Alert for any instance that is unreachable for >2 minutes.
  - alert: 虛擬機CPU使用率超上限
    expr: vmware_vm_cpu_usagemhz_average/vmware_vm_max_cpu_usage*100>80
    for: 30m
    labels:
      severity: 告警
    annotations:
      summary: "虛擬機 {{ $labels.vm_name }} 上的CPU使用率超高限80%"
      description: " {{ $labels.job }}檢測到\n {{ $labels.host_name }} 中的虛機 {{ $labels.vm_name }} CPU使用率超高限80%超過30分鐘.\n 當前值 = {{ $value }}"

  - alert: 虛擬機記憶體使用率超上限
    expr: (vmware_vm_mem_active_average/ vmware_vm_mem_consumed_average)*100>90
    for: 30m
    labels:
      severity: 告警
    annotations:
      summary: "vSphere主機 {{ $labels.host_name }} 主機記憶體使用率超90%"
      description: " {{ $labels.job }}檢測到\n {{ $labels.host_name }} 中的虛機 {{ $labels.vm_name }} 記憶體使用率超90% 超過30分鐘.n\ 當前值 = {{ $value }}"


6.2.4 Linux主機告警

- name: Linux主機告警
  rules:
  - alert: 主機記憶體超限>90%
    expr: node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100 < 10
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "{{ $labels.instance }}主機記憶體超限>90%"
      description: "{{ $labels.instance }} 主機記憶體超限(< 10% left)\n  當前值 = {{ $value }}\n "


  - alert: HostMemoryUnderMemoryPressure
    expr: rate(node_vmstat_pgmajfault[1m]) > 1000
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "Host memory under memory pressure (instance {{ $labels.instance }})"
      description: "The node is under heavy memory pressure. High rate of major page faults\n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"


  - alert: 主機磁盤空間不足
    expr: (node_filesystem_avail_bytes{mountpoint="/rootfs"}  * 100) / node_filesystem_size_bytes{mountpoint="/rootfs"} < 10
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "{{ $labels.instance }}主機磁盤空間不足"
      description: "{{ $labels.instance }} 主機磁盤空間不足(< 10% 剩余)\n  當前值 = {{ $value }}\n "


  - alert: 主機磁盤Inodes不足
    expr: node_filesystem_files_free{mountpoint ="/rootfs"} / node_filesystem_files{mountpoint ="/rootfs"} * 100 < 10
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "{{ $labels.instance }}主機磁盤Inodes不足"
      description: "{{ $labels.instance }} 主機磁盤Inodes不足(< 10% 剩余)\n  當前值 = {{ $value }}\n"



  - alert: 主機CPU負載高
    expr: 100 - (avg by(instance) (irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) > 80
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "{{ $labels.instance }}主機CPU負載高"
      description: "{{ $labels.instance }} 主機CPU負載高\n  當前值 = {{ $value }}\n"


  # 1000 context switches is an arbitrary number.
  # Alert threshold depends on nature of application.
  # Please read: https://github.com/samber/awesome-prometheus-alerts/issues/58
  - alert: 主機CPU背景關系切換高
    expr: (rate(node_context_switches_total[5m])) / (count without(cpu, mode) (node_cpu_seconds_total{mode="idle"})) > 10000
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "{{ $labels.instance }}主機CPU背景關系切換高"
      description: "{{ $labels.instance }}主機CPU背景關系切換高 (> 2000 / s)\n 當前值 =  {{ $value }}\n  "


  - alert: 主機Swap空間滿
    expr: (1 - (node_memory_SwapFree_bytes / node_memory_SwapTotal_bytes)) * 100 > 80
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "{{ $labels.instance }}主機Swap空間滿"
      description: "{{ $labels.instance }}主機Swap空間滿 (>80%)\n  當前值  = {{ $value }}\n "

  
  - alert: 主機過熱
    expr: node_hwmon_temp_alarm == 1
    for: 5m
    labels:
      severity: 嚴重
    annotations:
      summary: "{{ $labels.instance }} 主機過熱"
      description: "{{ $labels }}主機過熱\n  當前值  = {{ $value }} \n "


  - alert: HostRaidDiskFailure
    expr: node_md_disks{state="fail"} > 0
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "Host RAID disk failure (instance {{ $labels.instance }})"
      description: "At least one device in RAID array on {{ $labels.instance }} failed. Array {{ $labels.md_device }} needs attention and possibly a disk swap\n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"



  - alert: 主機OomKill檢測
    expr: increase(node_vmstat_oom_kill[5m]) > 0
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "檢測到主機{{ $labels.instance }}發生OoM kill"
      description: "OOM kill detected\n  當前值 = {{ $value }}\n "

6.2.5 Windows主機告警

- name: Windows主機告警
  rules:
  - alert: Windows 服務告警
    expr: windows_service_status{status="ok"} != 1
    for: 5m
    labels:
      severity: 嚴重
    annotations:
      summary: "Windows服務告警狀態告警 (instance {{ $labels.instance }})"
      description: "Windows Service state is not OK\n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"

  - alert: Windows CPU使用率告警
    expr: 100 - (avg by (instance) (rate(windows_cpu_time_total{mode="idle"}[2m])) * 100) > 80
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "Windows使用率告警 (instance {{ $labels.instance }})"
      description: "CPU使用率超過 80%\n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"

  - alert: Windows 記憶體使用率告警
    expr: 100 * (windows_os_physical_memory_free_bytes) / windows_cs_physical_memory_bytes > 90
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "Windows Server memory Usage (instance {{ $labels.instance }})"
      description: "記憶體使用率超過 90%\n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"

  - alert: Windows 磁盤使用率告警
    expr: 100.0 - 100 * ((windows_logical_disk_free_bytes{} / 1024 / 1024 ) / (windows_logical_disk_size_bytes{} / 1024 / 1024)) > 80
    for: 5m
    labels:
      severity: 嚴重
    annotations:
      summary: "Windows 磁盤使用率告警 (instance {{ $labels.instance }})"
      description: "磁盤使用率告警超過 80%\n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"


- name: Windows 2k 主機告警
  rules:
  - alert: Windows 2k 服務告警
    expr: wmi_service_status{status="ok"} != 1
    for: 5m
    labels:
      severity: 嚴重
    annotations:
      summary: "Windows 2k 服務告警狀態告警 (instance {{ $labels.instance }})"
      description: "Windows Service state is not OK\n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"

  - alert: Windows 2k CPU使用率告警
    expr: 100 - (avg by (instance) (rate(wmi_cpu_time_total{mode="idle"}[2m])) * 100) > 80
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "Windows 2k 使用率告警 (instance {{ $labels.instance }})"
      description: "CPU使用率超過 80%\n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"

  - alert: Windows 2k 記憶體使用率告警
    expr: 100 * (wmi_os_physical_memory_free_bytes) / wmi_cs_physical_memory_bytes > 90
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "Windows  2k Server memory Usage (instance {{ $labels.instance }})"
      description: "記憶體使用率超過 90%\n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"

  - alert: Windows 磁盤使用率告警
    expr: 100.0 - 100 * ((wmi_logical_disk_free_bytes{} / 1024 / 1024 ) / (wmi_logical_disk_size_bytes{} / 1024 / 1024)) > 90
    for: 5m
    labels:
      severity: 嚴重
    annotations:
      summary: "Windows 2k 磁盤使用率告警 (instance {{ $labels.instance }})"
      description: "磁盤使用率告警超過 90%\n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"

6.2.6 Ceph告警


- name: Ceph告警
  rules:
  - alert: Ceph狀態
    expr: ceph_health_status != 0
    for: 5m
    labels:
      severity: 嚴重
    annotations:
      summary: "Ceph 狀態不健康 (instance {{ $labels.instance }})"
      description: "Ceph 狀態不健康 \n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"

  - alert: Ceph管理節點時間不同步
    expr: abs(ceph_monitor_clock_skew_seconds) > 0.2
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "Ceph管理節點時間不同步 (instance {{ $labels.instance }})"
      description: "監測到Ceph管理節點時間不同步. 請檢查時間設定\n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"

  - alert: Ceph管理節點空間不足
    expr: ceph_monitor_avail_percent < 10
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "Ceph管理節點 low space (instance {{ $labels.instance }})"
      description: "Ceph管理節點空間不足.\n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"

  - alert: CephOsd宕機
    expr: ceph_osd_up == 0
    for: 5m
    labels:
      severity: 嚴重
    annotations:
      summary: "Ceph OSD Down (instance {{ $labels.instance }})"
      description: "Ceph Object Storage Daemon Down\n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"

  - alert: CephOsd高延時
    expr: ceph_osd_perf_apply_latency_seconds > 10
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "Ceph OSD 高延時 (instance {{ $labels.instance }})"
      description: "Ceph Object Storage Daemon 高延時.\n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"

  - alert: CephOsd容量不足
    expr: ceph_osd_utilization > 90
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "Ceph OSD 容量不足 (instance {{ $labels.instance }})"
      description: "Ceph Object Storage Daemon 容量不足. 請增加磁盤.\n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"

  - alert: CephOsd權重調整時間過長
    expr: ceph_osd_weight < 1
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "Ceph OSD 權重調整超時 (instance {{ $labels.instance }})"
      description: "Ceph Object Storage Daemon 權重調整時間過長.\n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"

  - alert: CephPg宕機
    expr: ceph_pg_down > 0
    for: 5m
    labels:
      severity: 嚴重
    annotations:
      summary: "Ceph PG down (instance {{ $labels.instance }})"
      description: "Ceph placement groups 狀態為 down. 請確認資料完整性.\n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"

  - alert: CephPgIncomplete
    expr: ceph_pg_incomplete > 0
    for: 5m
    labels:
      severity: 嚴重
    annotations:
      summary: "Ceph PG 不完整 (instance {{ $labels.instance }})"
      description: "Ceph placement groups 狀態為 incomplete. 請確認資料完整性.\n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"

  - alert: CephPg回填滿
    expr: ceph_pg_backfill_toofull > 0
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "Ceph PG 回填滿 (instance {{ $labels.instance }})"
      description: "Ceph placement groups 位于已經滿了的 Object Storage Daemon .PGs不可用. 請檢查 OSDs, 更改權重或重新配置CRUSH規則.\n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"

6.2.7 容器告警

- name: 資料庫告警
  rules:
  - alert: Oracle資料庫Down
    expr: oracledb_up !=1
    for: 2m
    labels:
      severity: 嚴重
    annotations:
      summary: "主資料庫 (instance {{ $labels.instance }})宕機"
      description: "主資料庫 (instance {{ $labels.instance }})宕機"

- name: 容器告警

  rules:
  - alert: 容器Killed
    expr: time() - container_last_seen > 60
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "容器 killed (instance {{ $labels.instance }})"
      description: "容器被 killed \n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"



  - alert: 容器Volume使用率高
    expr: (1 - (sum(container_fs_inodes_free) BY (instance) / sum(container_fs_inodes_total) BY (instance)) * 100) > 80
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "容器Volume使用率高 (instance {{ $labels.instance }})"
      description: "容器Volume使用率高于 80%\n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"
    
  - alert: 容器Volume IO 高
    expr: (sum(container_fs_io_current) BY (instance, name) * 100) > 80
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "容器Volume IO 高 (instance {{ $labels.instance }})"
      description: "容器Volume IO高于 80%\n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"

  - alert: 容器CPU頻率限制高
    expr: rate(container_cpu_cfs_throttled_seconds_total[3m]) > 1
    for: 5m
    labels:
      severity: 告警
    annotations:
      summary: "容器CPU頻率限制高 (instance {{ $labels.instance }})"
      description: "容器CPU頻率被限制\n  當前值 = {{ $value }}\n  LABELS: {{ $labels }}"


轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/295044.html

標籤:其他

上一篇:深度學習——計算機視覺

下一篇:k8s 二進制部署之添加 masterN 實作高可用

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 網閘典型架構簡述

    網閘架構一般分為兩種:三主機的三系統架構網閘和雙主機的2+1架構網閘。 三主機架構分別為內端機、外端機和仲裁機。三機無論從軟體和硬體上均各自獨立。首先從硬體上來看,三機都用各自獨立的主板、記憶體及存盤設備。從軟體上來看,三機有各自獨立的作業系統。這樣能達到完全的三機獨立。對于“2+1”系統,“2”分為 ......

    uj5u.com 2020-09-10 02:00:44 more
  • 如何從xshell上傳檔案到centos linux虛擬機里

    如何從xshell上傳檔案到centos linux虛擬機里及:虛擬機CentOs下執行 yum -y install lrzsz命令,出現錯誤:鏡像無法找到軟體包 前言 一、安裝lrzsz步驟 二、上傳檔案 三、遇到的問題及解決方案 總結 前言 提示:其實很簡單,往虛擬機上安裝一個上傳檔案的工具 ......

    uj5u.com 2020-09-10 02:00:47 more
  • 一、SQLMAP入門

    一、SQLMAP入門 1、判斷是否存在注入 sqlmap.py -u 網址/id=1 id=1不可缺少。當注入點后面的引數大于兩個時。需要加雙引號, sqlmap.py -u "網址/id=1&uid=1" 2、判斷文本中的請求是否存在注入 從文本中加載http請求,SQLMAP可以從一個文本檔案中 ......

    uj5u.com 2020-09-10 02:00:50 more
  • Metasploit 簡單使用教程

    metasploit 簡單使用教程 浩先生, 2020-08-28 16:18:25 分類專欄: kail 網路安全 linux 文章標簽: linux資訊安全 編輯 著作權 metasploit 使用教程 前言 一、Metasploit是什么? 二、準備作業 三、具體步驟 前言 Msfconsole ......

    uj5u.com 2020-09-10 02:00:53 more
  • 游戲逆向之驅動層與用戶層通訊

    驅動層代碼: #pragma once #include <ntifs.h> #define add_code CTL_CODE(FILE_DEVICE_UNKNOWN,0x800,METHOD_BUFFERED,FILE_ANY_ACCESS) /* 更多游戲逆向視頻www.yxfzedu.com ......

    uj5u.com 2020-09-10 02:00:56 more
  • 北斗電力時鐘(北斗授時服務器)讓網路資料更精準

    北斗電力時鐘(北斗授時服務器)讓網路資料更精準 北斗電力時鐘(北斗授時服務器)讓網路資料更精準 京準電子科技官微——ahjzsz 近幾年,資訊技術的得了快速發展,互聯網在逐漸普及,其在人們生活和生產中都得到了廣泛應用,并且取得了不錯的應用效果。計算機網路資訊在電力系統中的應用,一方面使電力系統的運行 ......

    uj5u.com 2020-09-10 02:01:03 more
  • 【CTF】CTFHub 技能樹 彩蛋 writeup

    ?碎碎念 CTFHub:https://www.ctfhub.com/ 筆者入門CTF時時剛開始刷的是bugku的舊平臺,后來才有了CTFHub。 感覺不論是網頁UI設計,還是題目質量,賽事跟蹤,工具軟體都做得很不錯。 而且因為獨到的金幣制度的確讓人有一種想去刷題賺金幣的感覺。 個人還是非常喜歡這個 ......

    uj5u.com 2020-09-10 02:04:05 more
  • 02windows基礎操作

    我學到了一下幾點 Windows系統目錄結構與滲透的作用 常見Windows的服務詳解 Windows埠詳解 常用的Windows注冊表詳解 hacker DOS命令詳解(net user / type /md /rd/ dir /cd /net use copy、批處理 等) 利用dos命令制作 ......

    uj5u.com 2020-09-10 02:04:18 more
  • 03.Linux基礎操作

    我學到了以下幾點 01Linux系統介紹02系統安裝,密碼啊破解03Linux常用命令04LAMP 01LINUX windows: win03 8 12 16 19 配置不繁瑣 Linux:redhat,centos(紅帽社區版),Ubuntu server,suse unix:金融機構,證券,銀 ......

    uj5u.com 2020-09-10 02:04:30 more
  • 05HTML

    01HTML介紹 02頭部標簽講解03基礎標簽講解04表單標簽講解 HTML前段語言 js1.了解代碼2.根據代碼 懂得挖掘漏洞 (POST注入/XSS漏洞上傳)3.黑帽seo 白帽seo 客戶網站被黑帽植入劫持代碼如何處理4.熟悉html表單 <html><head><title>TDK標題,描述 ......

    uj5u.com 2020-09-10 02:04:36 more
最新发布
  • 2023年最新微信小程式抓包教程

    01 開門見山 隔一個月發一篇文章,不過分。 首先回顧一下《微信系結手機號資料庫被脫庫事件》,我也是第一時間得知了這個訊息,然后跟蹤了整件事情的經過。下面是這起事件的相關截圖以及近日流出的一萬條資料樣本: 個人認為這件事也沒什么,還不如關注一下之前45億快遞資料查詢渠道疑似在近日復活的訊息。 訊息是 ......

    uj5u.com 2023-04-20 08:48:24 more
  • web3 產品介紹:metamask 錢包 使用最多的瀏覽器插件錢包

    Metamask錢包是一種基于區塊鏈技術的數字貨幣錢包,它允許用戶在安全、便捷的環境下管理自己的加密資產。Metamask錢包是以太坊生態系統中最流行的錢包之一,它具有易于使用、安全性高和功能強大等優點。 本文將詳細介紹Metamask錢包的功能和使用方法。 一、 Metamask錢包的功能 數字資 ......

    uj5u.com 2023-04-20 08:47:46 more
  • vulnhub_Earth

    前言 靶機地址->>>vulnhub_Earth 攻擊機ip:192.168.20.121 靶機ip:192.168.20.122 參考文章 https://www.cnblogs.com/Jing-X/archive/2022/04/03/16097695.html https://www.cnb ......

    uj5u.com 2023-04-20 07:46:20 more
  • 從4k到42k,軟體測驗工程師的漲薪史,給我看哭了

    清明節一過,盲猜大家已經無心上班,在數著日子準備過五一,但一想到銀行卡里的余額……瞬間心情就不美麗了。最近,2023年高校畢業生就業調查顯示,本科畢業月平均起薪為5825元。調查一出,便有很多同學表示自己又被平均了。看著這一資料,不免讓人想到前不久中國青年報的一項調查:近六成大學生認為畢業10年內會 ......

    uj5u.com 2023-04-20 07:44:00 more
  • 最新版本 Stable Diffusion 開源 AI 繪畫工具之中文自動提詞篇

    🎈 標簽生成器 由于輸入正向提示詞 prompt 和反向提示詞 negative prompt 都是使用英文,所以對學習母語的我們非常不友好 使用網址:https://tinygeeker.github.io/p/ai-prompt-generator 這個網址是為了讓大家在使用 AI 繪畫的時候 ......

    uj5u.com 2023-04-20 07:43:36 more
  • 漫談前端自動化測驗演進之路及測驗工具分析

    隨著前端技術的不斷發展和應用程式的日益復雜,前端自動化測驗也在不斷演進。隨著 Web 應用程式變得越來越復雜,自動化測驗的需求也越來越高。如今,自動化測驗已經成為 Web 應用程式開發程序中不可或缺的一部分,它們可以幫助開發人員更快地發現和修復錯誤,提高應用程式的性能和可靠性。 ......

    uj5u.com 2023-04-20 07:43:16 more
  • CANN開發實踐:4個DVPP記憶體問題的典型案例解讀

    摘要:由于DVPP媒體資料處理功能對存放輸入、輸出資料的記憶體有更高的要求(例如,記憶體首地址128位元組對齊),因此需呼叫專用的記憶體申請介面,那么本期就分享幾個關于DVPP記憶體問題的典型案例,并給出原因分析及解決方法。 本文分享自華為云社區《FAQ_DVPP記憶體問題案例》,作者:昇騰CANN。 DVPP ......

    uj5u.com 2023-04-20 07:43:03 more
  • msf學習

    msf學習 以kali自帶的msf為例 一、msf核心模塊與功能 msf模塊都放在/usr/share/metasploit-framework/modules目錄下 1、auxiliary 輔助模塊,輔助滲透(埠掃描、登錄密碼爆破、漏洞驗證等) 2、encoders 編碼器模塊,主要包含各種編碼 ......

    uj5u.com 2023-04-20 07:42:59 more
  • Halcon軟體安裝與界面簡介

    1. 下載Halcon17版本到到本地 2. 雙擊安裝包后 3. 步驟如下 1.2 Halcon軟體安裝 界面分為四大塊 1. Halcon的五個助手 1) 影像采集助手:與相機連接,設定相機引數,采集影像 2) 標定助手:九點標定或是其它的標定,生成標定檔案及內參外參,可以將像素單位轉換為長度單位 ......

    uj5u.com 2023-04-20 07:42:17 more
  • 在MacOS下使用Unity3D開發游戲

    第一次發博客,先發一下我的游戲開發環境吧。 去年2月份買了一臺MacBookPro2021 M1pro(以下簡稱mbp),這一年來一直在用mbp開發游戲。我大致分享一下我的開發工具以及使用體驗。 1、Unity 官網鏈接: https://unity.cn/releases 我一般使用的Apple ......

    uj5u.com 2023-04-20 07:40:19 more