Skip to content

Commit aaf82d2

Browse files
authored
Merge pull request #262 from vmercierfr/hotfix-x2g
Fix for x2g RDS instance family
2 parents 1bfd810 + f1450b7 commit aaf82d2

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

internal/app/ec2/ec2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (e *EC2Fetcher) GetDBInstanceTypeInformation(instanceTypes []string) (Metri
7575
// Remove "db." prefix from instance types
7676
instanceTypesToFetch := make([]aws_ec2_types.InstanceType, len(instances))
7777
for i, instance := range instances {
78-
instanceTypesToFetch[i] = (aws_ec2_types.InstanceType)(removeDBPrefix(instance))
78+
instanceTypesToFetch[i] = (aws_ec2_types.InstanceType)(overrideInvalidInstanceTypes(removeDBPrefix(instance)))
7979
}
8080

8181
input := &aws_ec2.DescribeInstanceTypesInput{InstanceTypes: instanceTypesToFetch}

internal/app/ec2/helper.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,15 @@ func addDBPrefix(instance string) string {
1919
func removeDBPrefix(instance string) string {
2020
return strings.Trim(instance, "db.")
2121
}
22+
23+
// overrideInvalidInstanceTypes normalizes EC2 instance type names to handle
24+
// inconsistencies between RDS and EC2 services.
25+
// x2g RDS instances which are memory-optimized instance classes with AWS Graviton2 processors
26+
// are referenced as x2gd in EC2 API
27+
// See: https://github.com/qonto/prometheus-rds-exporter/issues/258
28+
func overrideInvalidInstanceTypes(instanceType string) string {
29+
if strings.HasPrefix(instanceType, "x2g.") {
30+
return strings.Replace(instanceType, "x2g.", "x2gd.", 1)
31+
}
32+
return instanceType
33+
}

0 commit comments

Comments
 (0)