-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Added ability to query for silences that will expire soon #1120
Conversation
sorry for the delay, I've been on vacation and will be getting back to work soon. I'll review this soon! |
cli/silence_query.go
Outdated
@@ -117,6 +123,11 @@ func query(cmd *cobra.Command, args []string) error { | |||
if !expired && silence.EndsAt.Before(time.Now()) { | |||
continue | |||
} | |||
|
|||
if int64(within) > 0 && silence.EndsAt.After(time.Now().Add(within)) { | |||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EndsAt is UTC on the AM, and calling time.Now() on amtool will use the user time zone, better to use UTC as well time.Now().UTC().Add ...
cli/silence_query.go
Outdated
@@ -89,6 +90,11 @@ func query(cmd *cobra.Command, args []string) error { | |||
return err | |||
} | |||
|
|||
within, err := queryFlags.GetDuration("within") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the sake of consistency, would it be possible to get the flag value as a string, and then parse it with the prometheus duration parser?
It seems unlikely folks are interested in filtering down to silences that are expiring in weeks or even years, but we should offer the same duration parsing functionality.
5555b88
to
b483830
Compare
@stuartnelson3 @josedonizetti I've addressed both of your comments |
sorry for the delay, I'll review this tomorrow. Thanks for your patience! |
Looks good! Can you add a note in the command's long description for the new flag? Once that's in, it's all good. |
a2614da
to
5904bb3
Compare
Done @stuartnelson3 , just waiting on CI. I've also rebased for cleanliness. |
* Collect additional common Infiniband counters Signed-off-by: Patrick Freeman <[email protected]>
As part of our workflow we find it quite useful to be able to query alerts that will expire soon, so that we can investigate whether they should stay silenced or be extended before we get a flood of alerts.
This PR adds such functionality to amtool so that a user can do something like:
which will give all the silences that expire within the next 8h.