Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
55 changes: 37 additions & 18 deletions x-pack/metricbeat/module/aws/cloudwatch/metadata/rds/rds.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understood correctly, this key gets mapped to aws.rds.cpu.total.pct in the final event. Where does this happen?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
}
Expand Down
51 changes: 24 additions & 27 deletions x-pack/metricbeat/module/aws/rds/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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": {
Expand All @@ -83,7 +80,7 @@
"name": "elastic-beats"
},
"provider": "aws",
"region": "us-east-1"
"region": "eu-west-1"
},
"event": {
"dataset": "aws.rds",
Expand Down