Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Alerting: Convenience translations for For field in alert rules #104

Merged
merged 3 commits into from
Aug 12, 2022

Conversation

alexweav
Copy link
Contributor

The for field in rules was broken for a while and was recently fixed in 9.1. This client also provided the value in the wrong format, using a raw serialized time.Duration rather than the string-based format that Prometheus expects.

This PR adds a new string field called For to the alert rule model, which takes the prom-style format.

We also add some convenience translations: whether the user wishes to provide a time.Duration or the prom-style duration, we now accept both and send the right thing regardless. The result is that this change is completely backwards-compatible, and improves the usability of the client by supporting whatever type the caller prefers.

Copy link
Member

@JohnnyQQQQ JohnnyQQQQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, perhaps we should add a comment on the functions coming from upstream, referencing their source.

@alexweav alexweav merged commit 1cb3f2e into master Aug 12, 2022
@alexweav alexweav deleted the alexweav/alerting-serialization branch August 12, 2022 21:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Archived in project
2 participants