prometheus監控VShereClient7.0_EXSi7.0主機狀態這篇文章就夠了,網上一些菜雞那文章簡直辣眼睛,就是瞎幾把炒文章。
我用的docker的方式監控的,方便不需要編譯。我監控的是:
VShereClient7.0_EXSi7.0主機狀態
VShereClient7.0_EXSi7.0主機狀態
VShereClient7.0_EXSi7.0主機狀態
重要的事情說三遍。下面貼一張監控展示圖,下面開始部署。
前提是把單台的EXSi7.0通過VShereClient7.0組成集群,vmware_exporter采集的數據是VShereClient7.0的數據,如下圖。注意!!!!
第一步、編寫docker-compose
[root@monitor vmware_exporter]# ls
docker-compose.yaml
[root@monitor vmware_exporter]# cat docker-compose.yaml
services:
vmware-exporter:
image: pryorda/vmware_exporter:v0.11.1
container_name: vmware-exporter
restart: unless-stopped
ports:
- '9272:9272'
expose:
- 9272
environment:
VSPHERE_HOST: "10.0.10.210"
VSPHERE_IGNORE_SSL: "True"
VSPHERE_USER: "administrator@vsphere.local"
VSPHERE_PASSWORD: "1qazXSW@"
labels:
org.label-schema.group: "monitoring"
第二、使用docker-compose將容器運行起來。
使用docker-compose將該容器運維起來。docker ps 查詢該容器是否運行起來。如果沒有請自行排查原因。
docker-compose up -d
第三、瀏覽該問監控所在服務器的ip+端口。
訪問ip+端口發現vmware_exporter可以正常采集到數據,說明這就成功了80%了,剩下的就是配置監控項報警規則。
第四、配置監控項報警規則
添加監控項,並瀏覽器查看,滿足監控規則就會報警。報警途徑有許多請自行設置。
[root@monitor rules]# cat VsphereAlert.yml
groups:
- name: EXSi主機狀態監控告警
rules:
- alert: EXSi主機狀態
expr: vmware_host_power_state ==0
for: 5m
labels:
type: lost
severity: fatal
annotations:
summary: "EXSi主機 {{$labels.host_name}} 失聯"
description: "EXSi任務 {{$labels.job}} 下的主機 {{$labels.host_name}} 已經超過五分鍾沒有數據了."
monitor_url: "http://10.0.10.120:3000/d/q1yCDNbWz/vmware-stats?orgId=1"
- alert: EXSi主機CPU使用情況
expr: (vmware_host_cpu_usage / vmware_host_cpu_max) * 100 >80
for: 5m
labels:
type: cpu
severity: warning
annotations:
summary: "EXSi主機 {{ $labels.host_name }} 的 CPU 使用率告警"
description: "EXSi主機 {{ $labels.host_name }} CPU 使用率超過 80%, 當前值為: {{ $value }}"
monitor_url: "http://10.0.10.120:3000/d/q1yCDNbWz/vmware-stats?orgId=1"
- alert: EXSi主機內存使用
expr: (vmware_host_memory_usage/ vmware_host_memory_max) * 100 >85
for: 5m
labels:
type: mem
severity: warning
annotations:
summary: "EXSi主機 {{ $labels.host_name }} 的內存使用率告警"
description: "EXSi主機 {{ $labels.host_name }} 的內存使用率超過 85%, 當前值為: {{ $value }}"
monitor_url: "http://10.0.10.120:3000/d/q1yCDNbWz/vmware-stats?orgId=1"
- alert: EXSi主機磁盤容量
expr: ((vmware_datastore_capacity_size- vmware_datastore_freespace_size) / vmware_datastore_capacity_size) * 100 >70
for: 5m
labels:
type: cpu
severity: warning
annotations:
summary: "EXSi主機 {{ $labels.host_name }} 的磁盤使用率告警"
description: "EXSi主機 {{ $labels.host_name }} 的磁盤使用率超過 70%, 掛載點: {{ $labels.mountpoint }} 當前值為:{{ $value }}%"
monitor_url: "http://10.0.10.120:3000/d/q1yCDNbWz/vmware-stats?orgId=1"
第五、添加Grafana展示模板。
請自行添加模板(連接地址https://grafana.com/grafana/dashboards/11243)模板ID:11243,添加時模板數據源選擇promethus。最終展示如下圖。
這是報警截圖。
感謝大家不足之處請指出,謝謝。
————————————————
版權聲明:本文為CSDN博主「遙襟」的原創文章,遵循CC 4.0 BY-SA版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/weixin_46396833/article/details/118021606