fix: pagination error on cloudwatch plugin (#9693)

This commit is contained in:
Doron-Bargo 2021-09-15 00:06:11 +03:00 committed by GitHub
parent 357959f087
commit 646273abe0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 9 deletions

View File

@ -410,18 +410,21 @@ func (c *CloudWatch) fetchNamespaceMetrics() ([]*cwClient.Metric, error) {
default:
recentlyActive = nil
}
params = &cwClient.ListMetricsInput{
Dimensions: []*cwClient.DimensionFilter{},
NextToken: token,
MetricName: nil,
RecentlyActive: recentlyActive,
}
for _, namespace := range c.Namespaces {
params.Namespace = aws.String(namespace)
params = &cwClient.ListMetricsInput{
Dimensions: []*cwClient.DimensionFilter{},
NextToken: token,
MetricName: nil,
RecentlyActive: recentlyActive,
Namespace: aws.String(namespace),
}
for {
resp, err := c.client.ListMetrics(params)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to list metrics with params per namespace: %v", err)
}
metrics = append(metrics, resp.Metrics...)
@ -432,7 +435,6 @@ func (c *CloudWatch) fetchNamespaceMetrics() ([]*cwClient.Metric, error) {
params.NextToken = resp.NextToken
}
}
return metrics, nil
}