-
Notifications
You must be signed in to change notification settings - Fork 12k
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
CloudWatch: Calculate period based on time range #21471
Conversation
234d21c
to
5e517c7
Compare
@mtanda could you review this, please? |
|
||
Convey("closest works as expected", func() { | ||
periods := []int{60, 300, 900, 3600, 21600} | ||
Convey("and input is lower than 60", func() { |
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.
@sunker Would you add test which confirm the period isn't shorter than CloudWatch retension?
Sample test case.
So(closest(periods, (60 * 60 * 24 * 15) + 1), ShouldEqual, 300)
So(closest(periods, (60 * 60 * 24 * 63) + 1), ShouldEqual, 3600)
0cb267b
to
ee668d8
Compare
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.
LGTM
I guess it can be reproduced, by creating new panel which use CloudWatch datasource. |
Oh, must have been a merge problem. Fix coming right up @mtanda.. |
* Calculate min period based on time range and no of queries * Use hardcoded array of periods if period is not defined actively by the user * Fix broken tests * Use a smaller max period for auto interval * Fix broken tests * Test period calculation * Test min retention period * Fix broken test
I think this commit introduced a behavior where when you zoom in (to say start-end < 15 days) on an event that occurred more than 15 or 63 days prior and To fix we will need to have a concept of |
This PR will add logic that will set a period interval based on the time range in case the period field in the query editor is left blank or has the value
auto
. If the period is actively defined by the user in the query editor, that value will be passed to the GMD api unconditionally. Previously the auto period calculations were made in the frontend, and therefore it didn't work for alerting. This PR moves the period calculation to the backend.If the period field is not defined by the user, the period will be calculated the following way:
periods = [60, 300, 900, 3600, 21600]
x = timeRangeDeltaInSeconds / 2000
x will then snap to the closest number in the periods array
This is an example with a time range of 30 days
2,592,000 / 2000 = 1296
-->900 is the closest number
fixes #20652
fixes #18493