mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
CloudWatch: Update Period auto to take retention into account (#37424)
* now to get it to build * modified names, added the 455 day case, and added a comment * removed wireguard override i used for my local * updated the docs
This commit is contained in:
@@ -69,7 +69,7 @@ func parseRequestQuery(model *simplejson.Json, refId string, startTime time.Time
|
||||
var period int
|
||||
if strings.ToLower(p) == "auto" || p == "" {
|
||||
deltaInSeconds := endTime.Sub(startTime).Seconds()
|
||||
periods := []int{60, 300, 900, 3600, 21600, 86400}
|
||||
periods := getRetainedPeriods(time.Since(startTime))
|
||||
datapoints := int(math.Ceil(deltaInSeconds / 2000))
|
||||
period = periods[len(periods)-1]
|
||||
for _, value := range periods {
|
||||
@@ -123,6 +123,19 @@ func parseRequestQuery(model *simplejson.Json, refId string, startTime time.Time
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getRetainedPeriods(timeSince time.Duration) []int {
|
||||
// See https://aws.amazon.com/about-aws/whats-new/2016/11/cloudwatch-extends-metrics-retention-and-new-user-interface/
|
||||
if timeSince > time.Duration(455)*24*time.Hour {
|
||||
return []int{21600, 86400}
|
||||
} else if timeSince > time.Duration(63)*24*time.Hour {
|
||||
return []int{3600, 21600, 86400}
|
||||
} else if timeSince > time.Duration(15)*24*time.Hour {
|
||||
return []int{300, 900, 3600, 21600, 86400}
|
||||
} else {
|
||||
return []int{60, 300, 900, 3600, 21600, 86400}
|
||||
}
|
||||
}
|
||||
|
||||
func parseStatistics(model *simplejson.Json) []string {
|
||||
var statistics []string
|
||||
for _, s := range model.Get("statistics").MustArray() {
|
||||
|
||||
Reference in New Issue
Block a user