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:
|
default:
|
||||||
recentlyActive = nil
|
recentlyActive = nil
|
||||||
}
|
}
|
||||||
params = &cwClient.ListMetricsInput{
|
|
||||||
Dimensions: []*cwClient.DimensionFilter{},
|
|
||||||
NextToken: token,
|
|
||||||
MetricName: nil,
|
|
||||||
RecentlyActive: recentlyActive,
|
|
||||||
}
|
|
||||||
for _, namespace := range c.Namespaces {
|
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 {
|
for {
|
||||||
resp, err := c.client.ListMetrics(params)
|
resp, err := c.client.ListMetrics(params)
|
||||||
if err != nil {
|
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...)
|
metrics = append(metrics, resp.Metrics...)
|
||||||
|
|
@ -432,7 +435,6 @@ func (c *CloudWatch) fetchNamespaceMetrics() ([]*cwClient.Metric, error) {
|
||||||
params.NextToken = resp.NextToken
|
params.NextToken = resp.NextToken
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return metrics, nil
|
return metrics, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue