Cloudwatch: Revert aws sdk go v2 (#103644)

* Revert "CloudWatch: Import new grafana-aws-sdk with PDC fix (#103249)"

This reverts commit f2b5b4e0c0.

* Revert "CloudWatch: Migrate to aws-sdk-go-v2 (#103106)"

This reverts commit a65cc0df93.

* make update-workspace
This commit is contained in:
Isabella Siu
2025-04-08 15:40:15 -04:00
committed by GitHub
parent 27e9422f24
commit 13534a7d98
60 changed files with 1599 additions and 1483 deletions
+17 -19
View File
@@ -7,10 +7,8 @@ import (
"strconv"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/cloudwatch"
cloudwatchtypes "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/cloudwatch"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/data"
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/kinds/dataquery"
@@ -31,14 +29,14 @@ func (e *cloudWatchExecutor) executeAnnotationQuery(ctx context.Context, pluginC
statistic = *model.Statistic
}
var period int32
var period int64
if model.Period != nil && *model.Period != "" {
p, err := strconv.ParseInt(*model.Period, 10, 32)
p, err := strconv.ParseInt(*model.Period, 10, 64)
if err != nil {
return nil, backend.DownstreamError(fmt.Errorf("query period must be an int"))
}
period = int32(p)
period = p
}
prefixMatching := false
@@ -71,11 +69,11 @@ func (e *cloudWatchExecutor) executeAnnotationQuery(ctx context.Context, pluginC
if prefixMatching {
params := &cloudwatch.DescribeAlarmsInput{
MaxRecords: aws.Int32(100),
MaxRecords: aws.Int64(100),
ActionPrefix: actionPrefix,
AlarmNamePrefix: alarmNamePrefix,
}
resp, err := cli.DescribeAlarms(ctx, params)
resp, err := cli.DescribeAlarms(params)
if err != nil {
result.Responses[query.RefID] = backend.ErrorResponseWithErrorSource(backend.DownstreamError(fmt.Errorf("%v: %w", "failed to call cloudwatch:DescribeAlarms", err)))
return result, nil
@@ -86,10 +84,10 @@ func (e *cloudWatchExecutor) executeAnnotationQuery(ctx context.Context, pluginC
return result, backend.DownstreamError(errors.New("invalid annotations query"))
}
var qd []cloudwatchtypes.Dimension
var qd []*cloudwatch.Dimension
for k, v := range dimensions {
for _, vvv := range v.ArrayOfString {
qd = append(qd, cloudwatchtypes.Dimension{
qd = append(qd, &cloudwatch.Dimension{
Name: aws.String(k),
Value: aws.String(vvv),
})
@@ -99,10 +97,10 @@ func (e *cloudWatchExecutor) executeAnnotationQuery(ctx context.Context, pluginC
Namespace: aws.String(model.Namespace),
MetricName: aws.String(metricName),
Dimensions: qd,
Statistic: cloudwatchtypes.Statistic(statistic),
Period: aws.Int32(period),
Statistic: aws.String(statistic),
Period: aws.Int64(period),
}
resp, err := cli.DescribeAlarmsForMetric(ctx, params)
resp, err := cli.DescribeAlarmsForMetric(params)
if err != nil {
result.Responses[query.RefID] = backend.ErrorResponseWithErrorSource(backend.DownstreamError(fmt.Errorf("%v: %w", "failed to call cloudwatch:DescribeAlarmsForMetric", err)))
return result, nil
@@ -118,9 +116,9 @@ func (e *cloudWatchExecutor) executeAnnotationQuery(ctx context.Context, pluginC
AlarmName: alarmName,
StartDate: aws.Time(query.TimeRange.From),
EndDate: aws.Time(query.TimeRange.To),
MaxRecords: aws.Int32(100),
MaxRecords: aws.Int64(100),
}
resp, err := cli.DescribeAlarmHistory(ctx, params)
resp, err := cli.DescribeAlarmHistory(params)
if err != nil {
result.Responses[query.RefID] = backend.ErrorResponseWithErrorSource(backend.DownstreamError(fmt.Errorf("%v: %w", "failed to call cloudwatch:DescribeAlarmHistory", err)))
return result, nil
@@ -129,7 +127,7 @@ func (e *cloudWatchExecutor) executeAnnotationQuery(ctx context.Context, pluginC
annotations = append(annotations, &annotationEvent{
Time: *history.Timestamp,
Title: *history.AlarmName,
Tags: string(history.HistoryItemType),
Tags: *history.HistoryItemType,
Text: *history.HistorySummary,
})
}
@@ -164,7 +162,7 @@ func transformAnnotationToTable(annotations []*annotationEvent, query backend.Da
}
func filterAlarms(alarms *cloudwatch.DescribeAlarmsOutput, namespace string, metricName string,
dimensions dataquery.Dimensions, statistic string, period int32) []*string {
dimensions dataquery.Dimensions, statistic string, period int64) []*string {
alarmNames := make([]*string, 0)
for _, alarm := range alarms.MetricAlarms {
@@ -191,7 +189,7 @@ func filterAlarms(alarms *cloudwatch.DescribeAlarmsOutput, namespace string, met
continue
}
if string(alarm.Statistic) != statistic {
if *alarm.Statistic != statistic {
continue
}