Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tags label to pve_guest_info metric #246

Merged
merged 3 commits into from
Apr 30, 2024
Merged

Conversation

ajgon
Copy link
Contributor

@ajgon ajgon commented Apr 28, 2024

Recent proxmox versions introduced tags for VMs. These provide useful for metrics as well, especially for configuring alerts i.e. something like pve_up{tags=~".*important.*"} == 0.

This PR adds tags to all metrics related to the VMs. Since .resource.get is used everywhere, this change should be backwards compatible.

@znerol
Copy link
Member

znerol commented Apr 28, 2024

Thanks for your contribution. This is a good start.

The tags label should only be added to the pve_guest_info metric though. The rest of the metrics should remain untouched.

@ajgon
Copy link
Contributor Author

ajgon commented Apr 28, 2024

I think it makes sense for other as well - pve_up makes sense with example I provided before. For other metrics - there may be a use case, when we want to monitor CPU spikes only on few machines, but ignore on others (as they're duoing heavy duty tasks). So I think it won't hurt to add them there as well? pve_guest_info from what I understand, doesn't have much added value?

Edit: After hitting "comment" I think I noticed your point - basically using pve_guest_info as a reference for other tags? Something like:

(pve_guest_info{tags=~".*important.*"} * on(id) group_left(name) pve_up{}) == 0

@znerol
Copy link
Member

znerol commented Apr 29, 2024

Edit: After hitting "comment" I think I noticed your point - basically using pve_guest_info as a reference for other tags?

Exactly. See also this blog post for more info on joins.

Would you mind updating the example metrics in the README.md as well? How does it look like with multiple tags?

@ajgon
Copy link
Contributor Author

ajgon commented Apr 29, 2024

Would you mind updating the example metrics in the README.md as well?

Done

How does it look like with multiple tags?

Proxmox returns them as string separated with semicolon (i.e. tags="tag1;tag2"). This comes directly as a string from API, and underlying library doesn't alter it in any way - so it translates nicely to label value.

@znerol znerol changed the title Add tags label to supporting metrics Add tags label to pve_guest_info metric Apr 30, 2024
@znerol znerol merged commit b3da91a into prometheus-pve:main Apr 30, 2024
1 check passed
@znerol
Copy link
Member

znerol commented Apr 30, 2024

Thank you @ajgon, released v3.4.0 which includes your valuable contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants