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

Added ability to query for silences that will expire soon #1120

Merged
merged 1 commit into from
Dec 12, 2017

Conversation

sinkingpoint
Copy link
Contributor

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:

amtool silence query --within 8h

which will give all the silences that expire within the next 8h.

@stuartnelson3
Copy link
Contributor

sorry for the delay, I've been on vacation and will be getting back to work soon. I'll review this soon!

@stuartnelson3 stuartnelson3 self-assigned this Nov 26, 2017
@@ -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
Copy link
Contributor

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 ...

@@ -89,6 +90,11 @@ func query(cmd *cobra.Command, args []string) error {
return err
}

within, err := queryFlags.GetDuration("within")
Copy link
Contributor

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?

ea9a584e

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.

@sinkingpoint sinkingpoint force-pushed the master branch 3 times, most recently from 5555b88 to b483830 Compare December 4, 2017 10:44
@sinkingpoint
Copy link
Contributor Author

@stuartnelson3 @josedonizetti I've addressed both of your comments

@stuartnelson3
Copy link
Contributor

sorry for the delay, I'll review this tomorrow. Thanks for your patience!

@stuartnelson3
Copy link
Contributor

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.

@sinkingpoint sinkingpoint force-pushed the master branch 2 times, most recently from a2614da to 5904bb3 Compare December 12, 2017 10:08
@sinkingpoint
Copy link
Contributor Author

Done @stuartnelson3 , just waiting on CI. I've also rebased for cleanliness.

@stuartnelson3 stuartnelson3 merged commit 873623e into prometheus:master Dec 12, 2017
hh pushed a commit to ii/alertmanager that referenced this pull request Nov 4, 2018
* Collect additional common Infiniband counters

Signed-off-by: Patrick Freeman <[email protected]>
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.

3 participants