From 8bda03e1c0b176eab5c0070c7ab8e87c35b2febd Mon Sep 17 00:00:00 2001 From: Josh Powers Date: Thu, 30 May 2024 08:45:38 -0600 Subject: [PATCH] fix(inputs.cloudwatch): Ensure account list is larger than index If not account IDs are returned we need to avoid a panic. fixes: #15422 --- plugins/inputs/cloudwatch/cloudwatch.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/inputs/cloudwatch/cloudwatch.go b/plugins/inputs/cloudwatch/cloudwatch.go index 110bc02a92495..86bdbd9849383 100644 --- a/plugins/inputs/cloudwatch/cloudwatch.go +++ b/plugins/inputs/cloudwatch/cloudwatch.go @@ -378,7 +378,7 @@ func (c *CloudWatch) getDataQueries(filteredMetrics []filteredMetric) map[string id := strconv.Itoa(j) + "_" + strconv.Itoa(i) dimension := ctod(metric.Dimensions) var accountID *string - if c.IncludeLinkedAccounts { + if c.IncludeLinkedAccounts && len(filtered.accounts) > j { accountID = aws.String(filtered.accounts[j]) (*dimension)["account"] = filtered.accounts[j] }