From d8bc300da48dcaef439d5792553fe175606ba05b Mon Sep 17 00:00:00 2001 From: Vincent Mercier Date: Fri, 13 Oct 2023 16:52:11 +0200 Subject: [PATCH] feat(metrics): Add performance_insights_enabled label in rds_instance_info metric --- README.md | 2 +- internal/app/exporter/exporter.go | 4 ++-- internal/app/rds/rds.go | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9469052..b5e51a1 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ It collect key metrics about: | rds_exporter_errors_total | | Total number of errors encountered by the exporter | | rds_free_storage_bytes | `aws_account_id`, `aws_region`, `dbidentifier` | Free storage on the instance | | rds_freeable_memory_bytes | `aws_account_id`, `aws_region`, `dbidentifier` | Amount of available random access memory. For MariaDB, MySQL, Oracle, and PostgreSQL DB instances, this metric reports the value of the MemAvailable field of /proc/meminfo | -| rds_instance_info | `aws_account_id`, `aws_region`, `dbi_resource_id`, `dbidentifier`, `deletion_protection`, `engine`, `engine_version`, `instance_class`, `multi_az`, `pending_maintenance`, `pending_modified_values`, `role`, `source_dbidentifier`, `storage_type` | RDS instance information | +| rds_instance_info | `aws_account_id`, `aws_region`, `dbi_resource_id`, `dbidentifier`, `deletion_protection`, `engine`, `engine_version`, `instance_class`, `multi_az`, `performance_insights_enabled`, `pending_maintenance`, `pending_modified_values`, `role`, `source_dbidentifier`, `storage_type` | RDS instance information | | rds_instance_log_files_size_bytes | `aws_account_id`, `aws_region`, `dbidentifier` | Total of log files on the instance | | rds_instance_max_iops_average | `aws_account_id`, `aws_region`, `dbidentifier` | Maximum IOPS of underlying EC2 instance | | rds_instance_max_throughput_bytes | `aws_account_id`, `aws_region`, `dbidentifier` | Maximum throughput of underlying EC2 instance | diff --git a/internal/app/exporter/exporter.go b/internal/app/exporter/exporter.go index 9436664..ed7d06a 100644 --- a/internal/app/exporter/exporter.go +++ b/internal/app/exporter/exporter.go @@ -113,7 +113,7 @@ func NewCollector(logger slog.Logger, awsAccountID string, awsRegion string, rds ), information: prometheus.NewDesc("rds_instance_info", "RDS instance information", - []string{"aws_account_id", "aws_region", "dbidentifier", "dbi_resource_id", "instance_class", "engine", "engine_version", "storage_type", "multi_az", "deletion_protection", "role", "source_dbidentifier", "pending_modified_values", "pending_maintenance"}, nil, + []string{"aws_account_id", "aws_region", "dbidentifier", "dbi_resource_id", "instance_class", "engine", "engine_version", "storage_type", "multi_az", "deletion_protection", "role", "source_dbidentifier", "pending_modified_values", "pending_maintenance", "performance_insights_enabled"}, nil, ), maxAllocatedStorage: prometheus.NewDesc("rds_max_allocated_storage_bytes", "Upper limit in gibibytes to which Amazon RDS can automatically scale the storage of the DB instance", @@ -390,7 +390,7 @@ func (c *rdsCollector) Collect(ch chan<- prometheus.Metric) { ch <- prometheus.MustNewConstMetric(c.apiCall, prometheus.CounterValue, c.counters.rdsAPIcalls, c.awsAccountID, c.awsRegion, "rds") for dbidentifier, instance := range c.metrics.rds.Instances { ch <- prometheus.MustNewConstMetric(c.allocatedStorage, prometheus.GaugeValue, float64(instance.AllocatedStorage), c.awsAccountID, c.awsRegion, dbidentifier) - ch <- prometheus.MustNewConstMetric(c.information, prometheus.GaugeValue, 1, c.awsAccountID, c.awsRegion, dbidentifier, instance.DbiResourceID, instance.DBInstanceClass, instance.Engine, instance.EngineVersion, instance.StorageType, strconv.FormatBool(instance.MultiAZ), strconv.FormatBool(instance.DeletionProtection), instance.Role, instance.SourceDBInstanceIdentifier, strconv.FormatBool(instance.PendingModifiedValues), instance.PendingMaintenanceAction) + ch <- prometheus.MustNewConstMetric(c.information, prometheus.GaugeValue, 1, c.awsAccountID, c.awsRegion, dbidentifier, instance.DbiResourceID, instance.DBInstanceClass, instance.Engine, instance.EngineVersion, instance.StorageType, strconv.FormatBool(instance.MultiAZ), strconv.FormatBool(instance.DeletionProtection), instance.Role, instance.SourceDBInstanceIdentifier, strconv.FormatBool(instance.PendingModifiedValues), instance.PendingMaintenanceAction, strconv.FormatBool(instance.PerformanceInsightsEnabled)) ch <- prometheus.MustNewConstMetric(c.logFilesSize, prometheus.GaugeValue, float64(instance.LogFilesSize), c.awsAccountID, c.awsRegion, dbidentifier) ch <- prometheus.MustNewConstMetric(c.maxAllocatedStorage, prometheus.GaugeValue, float64(instance.MaxAllocatedStorage), c.awsAccountID, c.awsRegion, dbidentifier) ch <- prometheus.MustNewConstMetric(c.maxIops, prometheus.GaugeValue, float64(instance.MaxIops), c.awsAccountID, c.awsRegion, dbidentifier) diff --git a/internal/app/rds/rds.go b/internal/app/rds/rds.go index d089c4c..375e821 100644 --- a/internal/app/rds/rds.go +++ b/internal/app/rds/rds.go @@ -6,6 +6,7 @@ import ( "fmt" "reflect" + "github.com/aws/aws-sdk-go-v2/aws" aws_rds "github.com/aws/aws-sdk-go-v2/service/rds" aws_rds_types "github.com/aws/aws-sdk-go-v2/service/rds/types" converter "github.com/qonto/prometheus-rds-exporter/internal/app/unit" @@ -224,7 +225,7 @@ func (r *RDSFetcher) computeInstanceMetrics(dbInstance aws_rds_types.DBInstance, MultiAZ: dbInstance.MultiAZ, PendingMaintenanceAction: pendingMaintenanceAction, PendingModifiedValues: pendingModifiedValues, - PerformanceInsightsEnabled: *dbInstance.PerformanceInsightsEnabled, + PerformanceInsightsEnabled: aws.ToBool(dbInstance.PerformanceInsightsEnabled), PubliclyAccessible: dbInstance.PubliclyAccessible, Role: role, SourceDBInstanceIdentifier: sourceDBInstanceIdentifier,