diff --git a/internal/metrics/aws_cloudwatch_embedded_metrics.go b/internal/metrics/aws_cloudwatch_embedded_metrics.go index 03beadd5..f1c63b86 100644 --- a/internal/metrics/aws_cloudwatch_embedded_metrics.go +++ b/internal/metrics/aws_cloudwatch_embedded_metrics.go @@ -45,11 +45,9 @@ func (m *awsCloudWatchEmbeddedMetrics) Generate(ctx context.Context, data Data) return fmt.Errorf("metrics log_embedded_metrics: %v", err) } + var dimensions []string for key, val := range data.Attributes { - emf, err = sjson.SetBytes(emf, "_aws.CloudWatchMetrics.0.Dimensions.-1.-1", key) - if err != nil { - return fmt.Errorf("metrics log_embedded_metrics: %v", err) - } + dimensions = append(dimensions, key) emf, err = sjson.SetBytes(emf, key, val) if err != nil { @@ -57,6 +55,11 @@ func (m *awsCloudWatchEmbeddedMetrics) Generate(ctx context.Context, data Data) } } + emf, err = sjson.SetBytes(emf, "_aws.CloudWatchMetrics.0.Dimensions.-1", dimensions) + if err != nil { + return fmt.Errorf("metrics log_embedded_metrics: %v", err) + } + emf, err = sjson.SetBytes(emf, "_aws.CloudWatchMetrics.0.Metrics.0.Name", data.Name) if err != nil { return fmt.Errorf("metrics log_embedded_metrics: %v", err)