diff --git a/.dictionary b/.dictionary index af8064a..eebc640 100644 --- a/.dictionary +++ b/.dictionary @@ -11,3 +11,7 @@ CLI JSON toc Codecov +IPv4 +IPv6 +Alertmanager +VM \ No newline at end of file diff --git a/docs/content/usage/_index.md b/docs/content/usage/_index.md index 1c21d59..3cf46d4 100644 --- a/docs/content/usage/_index.md +++ b/docs/content/usage/_index.md @@ -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 +``` diff --git a/prometheuspvesd/discovery.py b/prometheuspvesd/discovery.py index 5a2b471..f0253bf 100644 --- a/prometheuspvesd/discovery.py +++ b/prometheuspvesd/discovery.py @@ -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: