-
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
api: support more query filters #1366
api: support more query filters #1366
Conversation
This change adds 2 new query filters to the /api/v1/alerts endpoint. - active, filter out active alerts when set to 'false' (default: 'true'). - unprocessed, filter out unprocessed alerts when set to 'false' (default: 'true'). The default values ensure that the API behavior remains the same as before when the query filters aren't provided. Signed-off-by: Simon Pasquier <spasquie@redhat.com>
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.
looks great! couple small requests
@@ -20,26 +21,72 @@ import ( | |||
"github.com/stretchr/testify/require" | |||
) | |||
|
|||
// fakeAlerts is a struct implementing the provider.Alerts interface for tests. |
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.
💯
api/api_test.go
Outdated
false, | ||
map[string]string{"filter": "{alertname"}, | ||
400, | ||
[]string{"alert1", "alert2", "alert3", "alert4"}, |
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.
this []string{}
should probably be empty, since it's not being executed anyway because of the 400
.
@@ -88,6 +136,167 @@ func TestAddAlerts(t *testing.T) { | |||
} | |||
} | |||
|
|||
func TestListAlerts(t *testing.T) { |
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.
😍
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
@stuartnelson3 thanks for spotting the inconsistency! |
Support the new filter options in the alerts api endpoint introduced by #1366 Signed-off-by: stuart nelson <stuartnelson3@gmail.com>
Support the new filter options in the alerts api endpoint introduced by #1366 Signed-off-by: stuart nelson <stuartnelson3@gmail.com>
* cli alert query: Expose --active and --unprocessed Support the new filter options in the alerts api endpoint introduced by #1366 Signed-off-by: stuart nelson <stuartnelson3@gmail.com> * Update comment and client_test Signed-off-by: stuart nelson <stuartnelson3@gmail.com>
Cherry-pick two bug fixes into 0.18.1. Signed-off-by: Ben Kochie <superq@gmail.com>
Cherry-pick two bug fixes into 0.18.1. Signed-off-by: Ben Kochie <superq@gmail.com>
Cherry-pick two bug fixes into 0.18.1. Signed-off-by: Ben Kochie <superq@gmail.com>
Fixes #1359.
This change adds 2 new query filters to the /api/v1/alerts endpoint.
(default: 'true').
The default values ensure that the API behavior remains the same as
before when the query filters aren't provided.
cc @stuartnelson3