Proxmox VEExporter用于Prometheus监控系统。
项目描述
Prometheus Proxmox VE Exporter
这是一个用于从Proxmox VE节点收集信息以供Prometheus监控系统使用的Exporter。
安装
需要Python 3.9或更高版本。
使用pip
python3 -m pip install prometheus-pve-exporter
pve_exporter --help
使用docker
docker pull prompve/prometheus-pve-exporter
示例:显示使用消息
docker run -it --rm prompve/prometheus-pve-exporter --help
示例:运行带有挂载配置文件和发布的端口的镜像
docker run --init --name prometheus-pve-exporter -d -p 127.0.0.1:9221:9221 -v /path/to/pve.yml:/etc/prometheus/pve.yml prompve/prometheus-pve-exporter
Prometheus PVE Exporter现在可通过http://localhost:9221/访问。
使用方法
usage: pve_exporter [-h] [--collector.status | --no-collector.status] [--collector.version | --no-collector.version] [--collector.node | --no-collector.node] [--collector.cluster | --no-collector.cluster] [--collector.resources | --no-collector.resources] [--collector.config | --no-collector.config] [--collector.replication | --no-collector.replication] [--config.file CONFIG_FILE] [--web.listen-address WEB_LISTEN_ADDRESS] [--server.keyfile SERVER_KEYFILE] [--server.certfile SERVER_CERTFILE] options: -h, --help show this help message and exit --config.file CONFIG_FILE Path to config file (/etc/prometheus/pve.yml) --web.listen-address WEB_LISTEN_ADDRESS Address on which to expose metrics and web server. ([::]:9221) --server.keyfile SERVER_KEYFILE SSL key for server --server.certfile SERVER_CERTFILE SSL certificate for server cluster collectors: cluster collectors are run if the url parameter cluster=1 is set and skipped if the url parameter cluster=0 is set on a scrape url. --collector.status, --no-collector.status Exposes Node/VM/CT-Status --collector.version, --no-collector.version Exposes PVE version info --collector.node, --no-collector.node Exposes PVE node info --collector.cluster, --no-collector.cluster Exposes PVE cluster info --collector.resources, --no-collector.resources Exposes PVE resources info node collectors: node collectors are run if the url parameter node=1 is set and skipped if the url parameter node=0 is set on a scrape url. --collector.config, --no-collector.config Exposes PVE onboot status --collector.replication, --no-collector.replication Exposes PVE replication info
在双栈机器的 –web.listen-address 标志中使用 [::] 以绑定 IPv6 和 IPv4 套接字。
访问 http://localhost:9221/pve?target=1.2.3.4&cluster=1&node=1(1.2.3.4 是用于获取指标的目标 Proxmox VE 节点的 IP)。指定 module 请求参数,以从配置文件中选择要使用的模块。
请求参数 target 默认为 localhost。因此,如果 pve_exporter 直接部署在 Proxmox 主机上,则可以省略 target。
使用 –collector.X / –no-collector.X 标志来启用或禁用所选收集器。
请注意,配置收集器会导致每个虚拟机/CT 进行一次 API 调用。因此,在大型部署中建议使用 –no-collector.config 标志禁用此收集器。
有关更多示例和文档,请参阅 wiki。
导出的指标
以下是一个导出指标的示例。
# HELP pve_up Node/VM/CT-Status is online/running # TYPE pve_up gauge pve_up{id="node/proxmox"} 1.0 pve_up{id="qemu/100"} 1.0 # HELP pve_disk_size_bytes Size of storage device # TYPE pve_disk_size_bytes gauge pve_disk_size_bytes{id="qemu/100"} 6.8719476736e+010 pve_disk_size_bytes{id="node/proxmox"} 3.1044079616e+010 pve_disk_size_bytes{id="storage/proxmox/local"} 3.1044079616e+010 pve_disk_size_bytes{id="storage/proxmox/local-lvm"} 6.9243764736e+010 pve_disk_size_bytes{id="storage/proxmox/vms"} 1.934882766848e+012 # HELP pve_disk_usage_bytes Disk usage in bytes # TYPE pve_disk_usage_bytes gauge pve_disk_usage_bytes{id="qemu/100"} 0.0 pve_disk_usage_bytes{id="node/proxmox"} 1.7571426304e+010 pve_disk_usage_bytes{id="storage/proxmox/local"} 1.7571426304e+010 pve_disk_usage_bytes{id="storage/proxmox/local-lvm"} 6.619703908e+09 pve_disk_usage_bytes{id="storage/proxmox/vms"} 8.32870981632e+011 # HELP pve_memory_size_bytes Size of memory # TYPE pve_memory_size_bytes gauge pve_memory_size_bytes{id="qemu/100"} 1.7179869184e+010 pve_memory_size_bytes{id="node/proxmox"} 6.739961856e+010 # HELP pve_memory_usage_bytes Memory usage in bytes # TYPE pve_memory_usage_bytes gauge pve_memory_usage_bytes{id="qemu/100"} 1.6573280275e+010 pve_memory_usage_bytes{id="node/proxmox"} 5.3907812352e+010 # HELP pve_network_transmit_bytes Number of bytes transmitted over the network # TYPE pve_network_transmit_bytes gauge pve_network_transmit_bytes{id="qemu/100"} 7.75070828e+09 # HELP pve_network_receive_bytes Number of bytes received over the network # TYPE pve_network_receive_bytes gauge pve_network_receive_bytes{id="qemu/100"} 1.529756162e+09 # HELP pve_disk_write_bytes Number of bytes written to storage # TYPE pve_disk_write_bytes gauge pve_disk_write_bytes{id="qemu/100"} 1.50048127488e+011 # HELP pve_disk_read_bytes Number of bytes read from storage # TYPE pve_disk_read_bytes gauge pve_disk_read_bytes{id="qemu/100"} 7.473739264e+09 # HELP pve_cpu_usage_ratio CPU usage (value between 0.0 and pve_cpu_usage_limit) # TYPE pve_cpu_usage_ratio gauge pve_cpu_usage_ratio{id="qemu/100"} 0.105009724408557 pve_cpu_usage_ratio{id="node/proxmox"} 0.984243806697115 # HELP pve_cpu_usage_limit Maximum allowed CPU usage # TYPE pve_cpu_usage_limit gauge pve_cpu_usage_limit{id="qemu/100"} 1.0 pve_cpu_usage_limit{id="node/proxmox"} 4.0 # HELP pve_uptime_seconds Number of seconds since the last boot # TYPE pve_uptime_seconds gauge pve_uptime_seconds{id="qemu/100"} 315039.0 pve_uptime_seconds{id="node/proxmox"} 315069.0 # HELP pve_storage_shared Whether or not the storage is shared among cluster nodes # TYPE pve_storage_shared gauge pve_storage_shared{id="storage/proxmox/local"} 0.0 pve_storage_shared{id="storage/proxmox/local-lvm"} 0.0 pve_storage_shared{id="storage/proxmox/vms"} 0.0 # HELP pve_guest_info VM/CT info # TYPE pve_guest_info gauge pve_guest_info{id="qemu/100",name="samplevm1",node="proxmox",type="qemu",tags="tag1;tag2"} 1.0 # HELP pve_storage_info Storage info # TYPE pve_storage_info gauge pve_storage_info{id="storage/proxmox/local",node="proxmox",storage="local"} 1.0 pve_storage_info{id="storage/proxmox/local-lvm",node="proxmox",storage="local-lvm"} 1.0 pve_storage_info{id="storage/proxmox/vms",node="proxmox",storage="vms"} 1.0 # HELP pve_node_info Node info # TYPE pve_node_info gauge pve_node_info{id="node/proxmox",level="",name="proxmox",nodeid="0"} 1.0 # HELP pve_onboot_status Proxmox vm config onboot value # TYPE pve_onboot_status gauge pve_onboot_status{id="qemu/201",node="proxmox",type="qemu"} 1.0 # HELP pve_version_info Proxmox VE version info # TYPE pve_version_info gauge pve_version_info{release="7.1",repoid="6fe299a0",version="7.1-5"} 1.0 # HELP pve_replication_duration_seconds Proxmox vm replication duration # TYPE pve_replication_duration_seconds gauge pve_replication_duration_seconds{id="1-0"} 7.73584 # HELP pve_replication_last_sync_timestamp_seconds Proxmox vm replication last_sync # TYPE pve_replication_last_sync_timestamp_seconds gauge pve_replication_last_sync_timestamp_seconds{id="1-0"} 1.713382503e+09 # HELP pve_replication_last_try_timestamp_seconds Proxmox vm replication last_try # TYPE pve_replication_last_try_timestamp_seconds gauge pve_replication_last_try_timestamp_seconds{id="1-0"} 1.713382503e+09 # HELP pve_replication_next_sync_timestamp_seconds Proxmox vm replication next_sync # TYPE pve_replication_next_sync_timestamp_seconds gauge pve_replication_next_sync_timestamp_seconds{id="1-0"} 1.7134689e+09 # HELP pve_replication_failed_syncs Proxmox vm replication fail_count # TYPE pve_replication_failed_syncs gauge pve_replication_failed_syncs{id="1-0"} 0.0 # HELP pve_replication_info Proxmox vm replication info # TYPE pve_replication_info gauge pve_replication_info{guest="qemu/1",id="1-0",source="node/proxmox1",target="node/proxmox2",type="local"} 1.0
身份验证
使用 pve.yml 配置文件
密码身份验证的示例 pve.yml
default:
user: prometheus@pve
password: sEcr3T!
# Optional: set to false to skip SSL/TLS verification
verify_ssl: true
令牌身份验证的示例 pve.yml
default:
user: prometheus@pve
token_name: "your-token-id"
token_value: "..."
使用环境变量
如果存在 PVE_USER 环境变量,则配置将从环境而非 pve.yml 配置文件中获取。以下环境变量被尊重
PVE_USER: 用户名
密码身份验证需要
PVE_PASSWORD: 用户密码
令牌身份验证需要
PVE_TOKEN_NAME: 令牌名称
PVE_TOKEN_VALUE: 令牌值
可选
PVE_VERIFY_SSL: 要验证 PVE tls 证书的布尔值。默认为 true。
PVE_MODULE: 配置模块的名称。默认为 default。
配置直接传递到 proxmoxer.ProxmoxAPI()。
关于 verify_ssl 和证书信任存储的说明
当使用自签名证书操作 PVE 时,则有必要将证书导入到本地信任存储(参见 Debian/Ubuntu 的此 SE 答案)或将 verify_ssl: false 添加到配置字典中作为凭证的兄弟节点。请注意,PVE 支持默认的 Let’s Encrypt。在许多情况下,设置受信任的证书比使用自签名证书操作更好。
Proxmox VE 配置
出于安全原因,对于指标收集的目的,必须添加一个具有只读访问权限的用户(PVEAuditor 角色)。
有关创建用户的不同方法的说明,请参阅 Proxmox 文档。创建后,将用户分配到 / 路径权限。
Prometheus 配置
PVE 导出器可以部署在 Proxmox VE 节点上或单独的机器上。
在 PVE 节点上运行 PVE 导出器的示例配置
scrape_configs:
- job_name: 'pve'
static_configs:
- targets:
- 192.168.1.2:9221 # Proxmox VE node with PVE exporter.
- 192.168.1.3:9221 # Proxmox VE node with PVE exporter.
metrics_path: /pve
params:
module: [default]
cluster: ['1']
node: ['1']
在 Prometheus 主机上运行 PVE 导出器的示例配置
scrape_configs:
- job_name: 'pve'
static_configs:
- targets:
- 192.168.1.2 # Proxmox VE node.
- 192.168.1.3 # Proxmox VE node.
metrics_path: /pve
params:
module: [default]
cluster: ['1']
node: ['1']
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 127.0.0.1:9221 # PVE exporter.
有关警报的说明
您可以通过在 pve_guest_info 指标上使用连接来实现基于 VM 标签的警报,例如,仅当具有 critical 标签的虚拟机关闭时进行警报。
(pve_guest_info{tags=~".*critical.*"} * on(id) group_left(name) pve_up{}) == 0
有关抓取大型集群的说明
在大型部署中,建议为收集集群指标和节点指标设置独立的任务。将集群中任意节点抓取,并将url参数设置为cluster=1&node=0,将得到相同的指标集。因此,可以从单个节点或集群节点的一个子集(例如,通过轮询DNS在每个抓取中选择不同的节点)高效地抓取集群指标。
节点指标只能从指定的节点抓取。为了编译完整的节点指标集,有必要将集群中的每个节点抓取,并将url参数设置为cluster=0&node=1。
Gravatar仪表板
项目详情
下载文件
下载适合您平台的应用程序。如果您不确定选择哪个,请了解有关安装包的更多信息。
源代码分发
构建分发
哈希值 for prometheus_pve_exporter-3.4.5-py3-none-any.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | c558e55891221c27c7b077f8b5b7f89bb430796d2d5d1f436d680daf3a656229 |
|
MD5 | 271d55a306f3479a4eb6ca230362ac86 |
|
BLAKE2b-256 | c1df17a8fbbea536ce9a742f1425628cbb7f3301b41c90988eeb6a0c563dd34d |