2021-09-08 16:06:43 +02:00
|
|
|
package cloudwatch
|
|
|
|
|
|
|
|
|
|
import "github.com/aws/aws-sdk-go/service/cloudwatch"
|
|
|
|
|
|
|
|
|
|
// queryRowResponse represents the GetMetricData response for a query row in the query editor.
|
|
|
|
|
type queryRowResponse struct {
|
2022-05-18 00:16:38 -07:00
|
|
|
partialDataSet map[string]*cloudwatch.MetricDataResult
|
2022-04-04 14:44:19 +01:00
|
|
|
ErrorCodes map[string]bool
|
|
|
|
|
HasArithmeticError bool
|
|
|
|
|
ArithmeticErrorMessage string
|
2022-05-18 00:16:38 -07:00
|
|
|
Metrics []*cloudwatch.MetricDataResult
|
2022-04-04 14:44:19 +01:00
|
|
|
StatusCode string
|
2021-09-08 16:06:43 +02:00
|
|
|
}
|
|
|
|
|
|
2022-05-08 09:27:03 +02:00
|
|
|
func newQueryRowResponse() queryRowResponse {
|
2021-09-08 16:06:43 +02:00
|
|
|
return queryRowResponse{
|
2022-05-18 00:16:38 -07:00
|
|
|
partialDataSet: make(map[string]*cloudwatch.MetricDataResult),
|
2022-04-04 14:44:19 +01:00
|
|
|
ErrorCodes: map[string]bool{
|
|
|
|
|
maxMetricsExceeded: false,
|
|
|
|
|
maxQueryTimeRangeExceeded: false,
|
|
|
|
|
maxQueryResultsExceeded: false,
|
|
|
|
|
maxMatchingResultsExceeded: false},
|
|
|
|
|
HasArithmeticError: false,
|
|
|
|
|
ArithmeticErrorMessage: "",
|
2022-05-18 00:16:38 -07:00
|
|
|
Metrics: []*cloudwatch.MetricDataResult{},
|
2021-09-08 16:06:43 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (q *queryRowResponse) addMetricDataResult(mdr *cloudwatch.MetricDataResult) {
|
2022-05-18 00:16:38 -07:00
|
|
|
if partialData, ok := q.partialDataSet[*mdr.Label]; ok {
|
|
|
|
|
partialData.Timestamps = append(partialData.Timestamps, mdr.Timestamps...)
|
|
|
|
|
partialData.Values = append(partialData.Values, mdr.Values...)
|
|
|
|
|
q.StatusCode = *mdr.StatusCode
|
|
|
|
|
if *mdr.StatusCode != "PartialData" {
|
|
|
|
|
delete(q.partialDataSet, *mdr.Label)
|
|
|
|
|
}
|
|
|
|
|
return
|
2021-09-08 16:06:43 +02:00
|
|
|
}
|
2022-05-18 00:16:38 -07:00
|
|
|
|
|
|
|
|
q.Metrics = append(q.Metrics, mdr)
|
2021-09-08 16:06:43 +02:00
|
|
|
q.StatusCode = *mdr.StatusCode
|
2022-05-18 00:16:38 -07:00
|
|
|
if *mdr.StatusCode == "PartialData" {
|
|
|
|
|
q.partialDataSet[*mdr.Label] = mdr
|
|
|
|
|
}
|
2021-09-08 16:06:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (q *queryRowResponse) addArithmeticError(message *string) {
|
|
|
|
|
q.HasArithmeticError = true
|
|
|
|
|
q.ArithmeticErrorMessage = *message
|
|
|
|
|
}
|