diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index ad3545b3736..a1688cf7653 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -427,7 +427,7 @@ for a few releases. Please use other tools provided by Elastic to fetch data fro - Change vsphere.datastore.capacity.used.pct value to betweeen 0 and 1. {pull}23148[23148] - `beat` module respects `basepath` config option. {pull}28162[28162] - Fix list_docker.go {pull}28374[28374] - +- Divide RDS metric cpu.total.pct by 100. {pull}28456[28456] *Packetbeat* - Handle truncated DNS records more gracefully. {issue}21495[21495] {pull}28297[28297] 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 29d9fee6701..c74234af7ce 100644 --- a/x-pack/metricbeat/module/aws/cloudwatch/metadata/rds/rds.go +++ b/x-pack/metricbeat/module/aws/cloudwatch/metadata/rds/rds.go @@ -16,21 +16,10 @@ import ( "github.com/elastic/beats/v7/libbeat/logp" "github.com/elastic/beats/v7/metricbeat/mb" awscommon "github.com/elastic/beats/v7/x-pack/libbeat/common/aws" - "github.com/elastic/beats/v7/x-pack/metricbeat/module/aws" ) const metadataPrefix = "aws.rds.db_instance." -// DBDetails holds detailed information from DescribeDBInstances for each rds. -type DBDetails struct { - dbArn string - dbClass string - dbAvailabilityZone string - dbIdentifier string - dbStatus string - tags []aws.Tag -} - // AddMetadata adds metadata for RDS instances from a specific region func AddMetadata(endpoint string, regionName string, awsConfig awssdk.Config, events map[string]mb.Event) map[string]mb.Event { svc := rds.New(awscommon.EnrichAWSConfigWithEndpoint( @@ -43,17 +32,47 @@ func AddMetadata(endpoint string, regionName string, awsConfig awssdk.Config, ev return events } + for _, event := range events { + cpuValue, err := event.RootFields.GetValue("aws.rds.metrics.CPUUtilization.avg") + if err == nil { + if value, ok := cpuValue.(float64); ok { + event.RootFields.Put("aws.rds.metrics.CPUUtilization.avg", value/100) + } + } + } + for identifier, output := range dbDetailsMap { if _, ok := events[identifier]; !ok { continue } - events[identifier].RootFields.Put(metadataPrefix+"arn", &output.DBInstanceArn) - events[identifier].RootFields.Put(metadataPrefix+"status", &output.DBInstanceStatus) - events[identifier].RootFields.Put(metadataPrefix+"identifier", &output.DBInstanceIdentifier) - events[identifier].RootFields.Put(metadataPrefix+"db_cluster_identifier", &output.DBClusterIdentifier) - events[identifier].RootFields.Put(metadataPrefix+"class", &output.DBInstanceClass) - events[identifier].RootFields.Put(metadataPrefix+"engine_name", &output.Engine) - events[identifier].RootFields.Put("cloud.availability_zone", &output.AvailabilityZone) + + if output.DBInstanceArn != nil { + events[identifier].RootFields.Put(metadataPrefix+"arn", *output.DBInstanceArn) + } + + if output.DBInstanceStatus != nil { + events[identifier].RootFields.Put(metadataPrefix+"status", *output.DBInstanceStatus) + } + + if output.DBInstanceIdentifier != nil { + events[identifier].RootFields.Put(metadataPrefix+"identifier", *output.DBInstanceIdentifier) + } + + if output.DBClusterIdentifier != nil { + events[identifier].RootFields.Put(metadataPrefix+"db_cluster_identifier", *output.DBClusterIdentifier) + } + + if output.DBInstanceClass != nil { + events[identifier].RootFields.Put(metadataPrefix+"class", *output.DBInstanceClass) + } + + if output.Engine != nil { + events[identifier].RootFields.Put(metadataPrefix+"engine_name", *output.Engine) + } + + if output.AvailabilityZone != nil { + events[identifier].RootFields.Put("cloud.availability_zone", *output.AvailabilityZone) + } } return events } diff --git a/x-pack/metricbeat/module/aws/rds/_meta/data.json b/x-pack/metricbeat/module/aws/rds/_meta/data.json index 76cfd2aa3e7..84f9c93b728 100644 --- a/x-pack/metricbeat/module/aws/rds/_meta/data.json +++ b/x-pack/metricbeat/module/aws/rds/_meta/data.json @@ -5,17 +5,19 @@ "namespace": "AWS/RDS" }, "dimensions": { - "DBClusterIdentifier": "database-1", - "Role": "WRITER" + "DatabaseClass": "db.r5.large" }, "rds": { "aurora_bin_log_replica_lag": 0, "aurora_replica": { + "lag": { + "ms": 19.9485 + }, "lag_max": { - "ms": 13.449000358581543 + "ms": 21.318500518798828 }, "lag_min": { - "ms": 13.449000358581543 + "ms": 21.318500518798828 } }, "aurora_volume_left_total": { @@ -27,54 +29,49 @@ }, "cpu": { "total": { - "pct": 6.975116251937533 + "pct": 0.06552109062928828 } }, "database_connections": 0, "deadlocks": 0, "engine_uptime": { - "sec": 20413803 + "sec": 33121208 }, "free_local_storage": { - "bytes": 25608523776 + "bytes": 27275925504 }, "freeable_memory": { - "bytes": 4695093248 + "bytes": 4604928000 }, "latency": { - "commit": 5.198533333333333, + "commit": 3.2349916666666667, "ddl": 0, "delete": 0, - "dml": 0.19726666666666667, - "insert": 0.19726666666666667, + "dml": 0.09888333333333334, + "insert": 0.09888333333333334, "read": 0, - "select": 0.21317204301075268, + "select": 0.2432811228126595, "update": 0, - "write": 0.0013534145331858408 + "write": 0.0005787267919438727 }, "login_failures": 0, - "queries": 8.830095631601747, + "queries": 7.862475898034027, "throughput": { - "commit": 0.49980840677740196, + "commit": 0.24950762724254, "ddl": 0, "delete": 0, - "dml": 0.49980840677740196, - "insert": 0.49980840677740196, - "network": 1.3998600139986002, - "network_receive": 0.6999300069993001, - "network_transmit": 0.6999300069993001, - "select": 3.098812122019892, + "dml": 0.24950762724254, + "insert": 0.24950762724254, + "network": 1.3985171580449323, + "network_receive": 0.6992585790224661, + "network_transmit": 0.6992585790224661, + "select": 2.9299395125804084, "update": 0 }, "transactions": { "active": 0, "blocked": 0 } - }, - "tags": { - "cluster": "database-1", - "created-by": "ks", - "dept": "eng" } }, "cloud": { @@ -83,7 +80,7 @@ "name": "elastic-beats" }, "provider": "aws", - "region": "us-east-1" + "region": "eu-west-1" }, "event": { "dataset": "aws.rds",