From 2d687ac9d22854900d1ca76a4e22a2b1515a7886 Mon Sep 17 00:00:00 2001 From: Gabriel Pop <94497545+gpop63@users.noreply.github.com> Date: Fri, 24 May 2024 19:36:15 +0300 Subject: [PATCH] Normalize AWS RDS CPU Utilization values before metadata API call (#39664) * handle cpu normalization before the API call * add changelog entry * fix changelog pr id --- CHANGELOG.next.asciidoc | 1 + .../module/aws/cloudwatch/metadata/rds/rds.go | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 1db083bad9a..d39c31feaad 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -170,6 +170,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff] - Fix timeout caused by the retrival of which indices are hidden {pull}39165[39165] - Fix Azure Monitor support for multiple aggregation types {issue}39192[39192] {pull}39204[39204] - Fix for MySQL/Performance - Query failure for MySQL versions below v8.0.1, for performance metric `quantile_95`. {pull}38710[38710] +- Normalize AWS RDS CPU Utilization values before making the metadata API call. {pull}39664[39664] *Osquerybeat* diff --git a/x-pack/metricbeat/module/aws/cloudwatch/metadata/rds/rds.go b/x-pack/metricbeat/module/aws/cloudwatch/metadata/rds/rds.go index 01102ad190a..78dde6aa2ae 100644 --- a/x-pack/metricbeat/module/aws/cloudwatch/metadata/rds/rds.go +++ b/x-pack/metricbeat/module/aws/cloudwatch/metadata/rds/rds.go @@ -27,12 +27,9 @@ func AddMetadata(regionName string, awsConfig awssdk.Config, fips_enabled bool, } }) - // Get DBInstance IDs per region - dbDetailsMap, err := getDBInstancesPerRegion(svc) - if err != nil { - return events, fmt.Errorf("aws.rds.db_instance fields are not available, skipping region %s: %w", regionName, err) - } - + // Normalize CPU Utilization values before making the API call, + // because the API call can fail, and we need to ensure the + // CPU values are correctly scaled regardless of the API call outcome. for _, event := range events { cpuValue, err := event.RootFields.GetValue("aws.rds.metrics.CPUUtilization.avg") if err == nil { @@ -42,6 +39,12 @@ func AddMetadata(regionName string, awsConfig awssdk.Config, fips_enabled bool, } } + // Get DBInstance IDs per region + dbDetailsMap, err := getDBInstancesPerRegion(svc) + if err != nil { + return events, fmt.Errorf("aws.rds.db_instance fields are not available, skipping region %s: %w", regionName, err) + } + for dbInstanceIdentifier, output := range dbDetailsMap { for eventIdentifier := range events { eventIdentifierComponents := strings.Split(eventIdentifier, "-")