fix: pagination error on cloudwatch plugin (#9693)
This commit is contained in:
parent
357959f087
commit
646273abe0
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue