Prometheus系統下vmware_exporter配置
爲了方便管理設備,搞起了Prometheus。今天從vmware_exporter開始,監控起來我的vmware vsphere集羣。
vmware_exporter由於編譯問題不成功,選擇使用docker方式執行。vmware_exporter
-
編輯配置文件config.yml,爲了配置prometheus的文件發現服務,特將esx中的vsphere_hosthost刪除。
mkdir -p /data/vmware/config.yml vim /data/vmware/config.yml
default: vsphere_host: "vcenter" vsphere_user: "user" vsphere_password: "password" ignore_ssl: False collect_only: vms: True vmguests: True datastores: True hosts: True snapshots: True esx: vsphere_user: 'root' vsphere_password: 'password' ignore_ssl: True collect_only: vms: True vmguests: True datastores: True hosts: True snapshots: True
-
執行vmware-exporter docker程序。
docker run -d -v /data/vmware:/data/ -it --rm -p 9272:9272 --name vmware_exporter pryorda/vmware_exporter -c /data/config.yml
-
編譯prometheus配置文件
-
編輯esx.yml文件,以便prometheus中sd_file配置文件使用。
vim /etc/prometheus/esx.yml
--- - targets: - 192.168.21.91 - 192.168.21.92 - 192.168.21.93 - 192.168.21.95 - 192.168.21.96 labels: job: vmware_esx
- 編輯prometheus文件,其中section:[esx] 對應config.yml文件中的ESX片段。
vim /etc/prometheus/prometheus.yml
- job_name: 'vmware_vcenter' metrics_path: '/metrics' static_configs: - targets: - 'vcenter.company.com' relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: localhost:9272 - job_name: 'vmware_esx' metrics_path: '/metrics' file_sd_configs: - files: - /etc/prometheus/esx.yml params: section: [esx] relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: localhost:9272
-
-
添加Grafana監控,導入granafa的配置文件,配置文件默認在dashboard目錄下。
參考鏈接:
終於完成了一小步,但是總歸是完成了,還有很多問題需要進一步解決,比如告警,比如更精細的監控,等等。
我的prometheus系列逐步完善中,未完待續,加油!