feat: add new label __meta_pve_tags to expose proxmox tags (#168)

This commit is contained in:
Mathias Petermann 2022-03-11 10:41:22 +01:00 committed by GitHub
parent b820f4646a
commit a2f7422591
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 1 deletions

View File

@ -11,3 +11,7 @@ CLI
JSON
toc
Codecov
IPv4
IPv6
Alertmanager
VM

View File

@ -34,6 +34,9 @@ The following list of meta labels can be used to relabel your scrape results:
`__meta_pve_status`
`__meta_pve_tags`
: A comma-separated list of tags, as set on Proxmox. Tags are supported by Proxmox 6+, and the field is missing if no tags are present on a VM.
`__meta_pve_groups`
: Groups will be discovered from the `Notes` field of a host and need to be set as JSON e.g. `{"groups":["group1","group2"]}`
@ -58,3 +61,45 @@ This example configuration snippet for the Prometheus `scrape_config` Prometheus
- __meta_pve_name
target_label: instance
```
### IPv4 or c usage
Set the address from the IPv4 or IPv4 meta label, and not the name
```YAML
relabel_configs:
- replacement: ${1}:9273
source_labels:
- __meta_pve_ipv4
target_label: __address__
```
## Convert tags to custom labels
E.g. Extract `group` and `alert` from a list of tags like this: `__meta_pve_tags="alert:team-1,group:cluster-1,node:node-1"`
```YAML
relabel_configs:
- source_labels:
- __meta_pve_tags
regex: ".*group:([\w\-_]*)"
target_label: "group"
replacement: "${1}"
- source_labels:
- __meta_pve_tags
regex: ".*alert:([\w\-_]*)"
target_label: "alert"
replacement: "${1}"
```
Using the `alert` label, you can then for example set an Alertmanager route, for this alert
```YAML
routes:
- receiver: "empty"
matchers:
- alert = muted
- receiver: "team-1"
matchers:
- alert = team-1
```

View File

@ -229,7 +229,7 @@ class Discovery():
prom_host = Host(vmid, host, ipv4_address, ipv6_address, pve_type)
config_flags = [("cpu", "sockets"), ("cores", "cores"), ("memory", "memory")]
meta_flags = [("status", "proxmox_status")]
meta_flags = [("status", "proxmox_status"), ("tags", "proxmox_tags")]
for key, flag in config_flags:
if flag in config: