Skip to content

Commit 6b6944d

Browse files
Add latency log and change RDS metric label (#663)
1 parent f815948 commit 6b6944d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

pkg/aws/rds/rds.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ var (
2424
cloudcost_exporter.MetricPrefix,
2525
subsystem,
2626
"hourly_rate_usd_per_hour",
27-
"Hourly cost of NAT Gateway by region. Cost represented in USD/hour",
28-
[]string{"region", "tier", "name"},
27+
"Hourly cost of AWS RDS instances by region, tier and id. Cost represented in USD/hour",
28+
[]string{"region", "tier", "id"},
2929
)
3030
)
3131

@@ -120,7 +120,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
120120
hourlyPrice,
121121
region,
122122
*instance.DBInstanceClass,
123-
*instance.DBInstanceIdentifier,
123+
*instance.DbiResourceId,
124124
)
125125
}
126126
return nil

pkg/aws/rds/rds_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ func TestCollector_Collect(t *testing.T) {
129129
Engine: aws.String("postgres"),
130130
DBInstanceIdentifier: aws.String("test-db"),
131131
MultiAZ: aws.Bool(false),
132+
DbiResourceId: aws.String("test-db"),
132133
}},
133134
pricingKey: createPricingKey("us-east-1", "db.t3.medium", "postgres", "Single-AZ", "AWS Region"),
134135
},
@@ -149,6 +150,7 @@ func TestCollector_Collect(t *testing.T) {
149150
Engine: aws.String("mysql"),
150151
DBInstanceIdentifier: aws.String("test-db-2"),
151152
MultiAZ: aws.Bool(false),
153+
DbiResourceId: aws.String("test-db-2"),
152154
}},
153155
pricingKey: cacheKey,
154156
},
@@ -203,7 +205,7 @@ func TestCollector_Collect(t *testing.T) {
203205
labels := metricResult.Labels
204206
hourlyPrice, _ := c.pricingMap.Get(tt.pricingKey)
205207
assert.Equal(t, *tt.ListRDSInstances[0].DBInstanceClass, labels["tier"])
206-
assert.Equal(t, *tt.ListRDSInstances[0].DBInstanceIdentifier, labels["name"])
208+
assert.Equal(t, *tt.ListRDSInstances[0].DBInstanceIdentifier, labels["id"])
207209
assert.Equal(t, hourlyPrice, metricResult.Value)
208210
default:
209211
t.Fatal("expected a metric to be collected")

0 commit comments

Comments
 (0)