diff --git a/README.md b/README.md index 7099267..4ba2cdc 100644 --- a/README.md +++ b/README.md @@ -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 | diff --git a/internal/app/exporter/exporter.go b/internal/app/exporter/exporter.go index 1b0270a..602ae91 100644 --- a/internal/app/exporter/exporter.go +++ b/internal/app/exporter/exporter.go @@ -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, ), diff --git a/internal/app/rds/rds.go b/internal/app/rds/rds.go index f9b1d5e..88a638b 100644 --- a/internal/app/rds/rds.go +++ b/internal/app/rds/rds.go @@ -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 @@ -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, diff --git a/internal/app/rds/rds_test.go b/internal/app/rds/rds_test.go index 90188eb..cc17695 100644 --- a/internal/app/rds/rds_test.go +++ b/internal/app/rds/rds_test.go @@ -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")