Skip to content

Commit

Permalink
chore(metrics): Rename rds_replication_slot_disk_usage_average to rds…
Browse files Browse the repository at this point in the history
…_replication_slot_disk_usage_bytes
  • Loading branch information
vmercierfr committed Nov 14, 2023
1 parent 382a2cf commit a5b0aaf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ It collect key metrics about:
| rds_read_throughput_bytes | `aws_account_id`, `aws_region`, `dbidentifier` | Average number of bytes read from disk per second |
| rds_transaction_logs_disk_usage_bytes | `aws_account_id`, `aws_region`, `dbidentifier` | Disk space used by transaction logs (only on PostgreSQL) |
| rds_replica_lag_seconds | `aws_account_id`, `aws_region`, `dbidentifier` | For read replica configurations, the amount of time a read replica DB instance lags behind the source DB instance. Applies to MariaDB, Microsoft SQL Server, MySQL, Oracle, and PostgreSQL read replicas |
| rds_replication_slot_disk_usage_average | `aws_account_id`, `aws_region`, `dbidentifier` | Disk space used by replication slot files. Applies to PostgreSQL |
| rds_replication_slot_disk_usage_bytes | `aws_account_id`, `aws_region`, `dbidentifier` | Disk space used by replication slot files. Applies to PostgreSQL |
| rds_swap_usage_bytes | `aws_account_id`, `aws_region`, `dbidentifier` | Amount of swap space used on the DB instance. This metric is not available for SQL Server |
| rds_usage_allocated_storage_bytes | `aws_account_id`, `aws_region` | Total storage used by AWS RDS instances |
| rds_usage_db_instances_average | `aws_account_id`, `aws_region` | AWS RDS instance count |
Expand Down
2 changes: 1 addition & 1 deletion internal/app/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func NewCollector(logger slog.Logger, collectorConfiguration Configuration, awsA
"For read replica configurations, the amount of time a read replica DB instance lags behind the source DB instance. Applies to MariaDB, Microsoft SQL Server, MySQL, Oracle, and PostgreSQL read replicas",
[]string{"aws_account_id", "aws_region", "dbidentifier"}, nil,
),
replicationSlotDiskUsage: prometheus.NewDesc("rds_replication_slot_disk_usage_average",
replicationSlotDiskUsage: prometheus.NewDesc("rds_replication_slot_disk_usage_bytes",
"Disk space used by replication slot files. Applies to PostgreSQL",
[]string{"aws_account_id", "aws_region", "dbidentifier"}, nil,
),
Expand Down
6 changes: 3 additions & 3 deletions internal/app/rds/rds.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ func (r *RDSFetcher) computeInstanceMetrics(dbInstance aws_rds_types.DBInstance,

iops, storageThroughput := getStorageMetrics(*dbInstance.StorageType, int64(dbInstance.AllocatedStorage), iops, throughput)

var maxAllocatedStorage int32 = 0
var maxAllocatedStorage int64 = 0
if dbInstance.MaxAllocatedStorage != nil {
maxAllocatedStorage = *dbInstance.MaxAllocatedStorage
maxAllocatedStorage = int64(*dbInstance.MaxAllocatedStorage)
}

pendingModifiedValues := false
Expand Down Expand Up @@ -260,7 +260,7 @@ func (r *RDSFetcher) computeInstanceMetrics(dbInstance aws_rds_types.DBInstance,
Engine: *dbInstance.Engine,
EngineVersion: *dbInstance.EngineVersion,
LogFilesSize: logFilesSize,
MaxAllocatedStorage: converter.GigaBytesToBytes(int64(maxAllocatedStorage)),
MaxAllocatedStorage: converter.GigaBytesToBytes(maxAllocatedStorage),
MaxIops: iops,
MultiAZ: dbInstance.MultiAZ,
PendingMaintenanceAction: pendingMaintenanceAction,
Expand Down
7 changes: 5 additions & 2 deletions internal/app/rds/rds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@ func TestGetMetrics(t *testing.T) {
assert.Equal(t, "primary", m.Role, "Should be primary node")
assert.Equal(t, emptyInt64, m.LogFilesSize, "Log file size mismatch")

assert.Equal(t, converter.GigaBytesToBytes(rdsInstance.AllocatedStorage), m.AllocatedStorage, "Allocated storage mismatch")
assert.Equal(t, converter.GigaBytesToBytes(*rdsInstance.MaxAllocatedStorage), m.MaxAllocatedStorage, "Max allocated storage (aka autoscaling) mismatch")
fmt.Println("MaxAllocatedStorage", *rdsInstance.MaxAllocatedStorage)
fmt.Println("MaxAllocatedStorage", converter.GigaBytesToBytes(int64(10)))

assert.Equal(t, converter.GigaBytesToBytes(int64(rdsInstance.AllocatedStorage)), m.AllocatedStorage, "Allocated storage mismatch")
assert.Equal(t, converter.GigaBytesToBytes(int64(*rdsInstance.MaxAllocatedStorage)), m.MaxAllocatedStorage, "Max allocated storage (aka autoscaling) mismatch")
assert.Equal(t, int64(*rdsInstance.Iops), m.MaxIops, "Max IOPS mismatch")
assert.Equal(t, converter.DaystoSeconds(rdsInstance.BackupRetentionPeriod), m.BackupRetentionPeriod, "Backup retention mismatch")
assert.Equal(t, rdsInstance.DeletionProtection, m.DeletionProtection, "Deletion protection mismatch")
Expand Down

0 comments on commit a5b0aaf

Please sign in to comment.