From fedf3587d389750f2dd1e721ea5e16a63de98868 Mon Sep 17 00:00:00 2001 From: Alexey Lesovsky Date: Mon, 24 May 2021 12:14:23 +0500 Subject: [PATCH] Fix counter metrics names, add _total suffix. --- internal/collector/postgres_bgwriter.go | 2 +- internal/collector/postgres_bgwriter_test.go | 2 +- internal/collector/postgres_database.go | 8 ++++---- internal/collector/postgres_database_test.go | 4 ++-- internal/collector/postgres_functions.go | 4 ++-- internal/collector/postgres_functions_test.go | 4 ++-- internal/collector/postgres_replication.go | 4 ++-- internal/collector/postgres_replication_slots.go | 2 +- internal/collector/postgres_replication_test.go | 4 ++-- internal/collector/postgres_tables.go | 4 ++-- internal/collector/postgres_tables_test.go | 4 ++-- 11 files changed, 21 insertions(+), 21 deletions(-) diff --git a/internal/collector/postgres_bgwriter.go b/internal/collector/postgres_bgwriter.go index 90e093e..032840d 100644 --- a/internal/collector/postgres_bgwriter.go +++ b/internal/collector/postgres_bgwriter.go @@ -84,7 +84,7 @@ func NewPostgresBgwriterCollector(constLabels prometheus.Labels, _ model.Collect }, "stats_age_seconds": { desc: prometheus.NewDesc( - prometheus.BuildFQName("postgres", "bgwriter", "stats_age_seconds"), + prometheus.BuildFQName("postgres", "bgwriter", "stats_age_seconds_total"), "The age of the background writer activity statistics, in seconds.", nil, constLabels, ), valueType: prometheus.CounterValue, diff --git a/internal/collector/postgres_bgwriter_test.go b/internal/collector/postgres_bgwriter_test.go index 4a21cc4..635ac13 100644 --- a/internal/collector/postgres_bgwriter_test.go +++ b/internal/collector/postgres_bgwriter_test.go @@ -19,7 +19,7 @@ func TestPostgresBgwriterCollector_Update(t *testing.T) { "postgres_bgwriter_maxwritten_clean_total", "postgres_backends_fsync_total", "postgres_backends_allocated_bytes_total", - "postgres_bgwriter_stats_age_seconds", + "postgres_bgwriter_stats_age_seconds_total", }, collector: NewPostgresBgwriterCollector, service: model.ServiceTypePostgresql, diff --git a/internal/collector/postgres_database.go b/internal/collector/postgres_database.go index 7493275..43c5532 100644 --- a/internal/collector/postgres_database.go +++ b/internal/collector/postgres_database.go @@ -103,8 +103,8 @@ func NewPostgresDatabasesCollector(constLabels prometheus.Labels, _ model.Collec }, blockstime: typedDesc{ desc: prometheus.NewDesc( - prometheus.BuildFQName("postgres", "database", "blk_time_seconds"), - "Time spent accessing data file blocks by backends in this database in each access type, in seconds.", + prometheus.BuildFQName("postgres", "database", "blk_time_seconds_total"), + "Total time spent accessing data blocks by backends in this database in each access type, in seconds.", []string{"database", "type"}, constLabels, ), valueType: prometheus.CounterValue, factor: .001, }, @@ -117,8 +117,8 @@ func NewPostgresDatabasesCollector(constLabels prometheus.Labels, _ model.Collec }, statsage: typedDesc{ desc: prometheus.NewDesc( - prometheus.BuildFQName("postgres", "database", "stats_age_seconds"), - "The age of the activity statistics, in seconds.", + prometheus.BuildFQName("postgres", "database", "stats_age_seconds_total"), + "The age of the databases activity statistics, in seconds.", labels, constLabels, ), valueType: prometheus.CounterValue, }, diff --git a/internal/collector/postgres_database_test.go b/internal/collector/postgres_database_test.go index 3bf7aac..546e7bd 100644 --- a/internal/collector/postgres_database_test.go +++ b/internal/collector/postgres_database_test.go @@ -19,9 +19,9 @@ func TestPostgresDatabasesCollector_Update(t *testing.T) { "postgres_database_tuples_total", "postgres_database_temp_bytes_total", "postgres_database_temp_files_total", - "postgres_database_blk_time_seconds", + "postgres_database_blk_time_seconds_total", "postgres_database_size_bytes", - "postgres_database_stats_age_seconds", + "postgres_database_stats_age_seconds_total", "postgres_xacts_left_before_wraparound", }, collector: NewPostgresDatabasesCollector, diff --git a/internal/collector/postgres_functions.go b/internal/collector/postgres_functions.go index 2f36e70..a104535 100644 --- a/internal/collector/postgres_functions.go +++ b/internal/collector/postgres_functions.go @@ -35,14 +35,14 @@ func NewPostgresFunctionsCollector(constLabels prometheus.Labels, _ model.Collec }, totaltime: typedDesc{ desc: prometheus.NewDesc( - prometheus.BuildFQName("postgres", "function", "total_time_seconds"), + prometheus.BuildFQName("postgres", "function", "total_time_seconds_total"), "Total time spent in function and all other functions called by it, in seconds.", labelNames, constLabels, ), valueType: prometheus.CounterValue, factor: .001, }, selftime: typedDesc{ desc: prometheus.NewDesc( - prometheus.BuildFQName("postgres", "function", "self_time_seconds"), + prometheus.BuildFQName("postgres", "function", "self_time_seconds_total"), "Total time spent in function itself, not including other functions called by it, in seconds.", labelNames, constLabels, ), valueType: prometheus.CounterValue, factor: .001, diff --git a/internal/collector/postgres_functions_test.go b/internal/collector/postgres_functions_test.go index ee90632..390eed1 100644 --- a/internal/collector/postgres_functions_test.go +++ b/internal/collector/postgres_functions_test.go @@ -14,8 +14,8 @@ func TestPostgresFunctionsCollector_Update(t *testing.T) { var input = pipelineInput{ required: []string{ "postgres_function_calls_total", - "postgres_function_total_time_seconds", - "postgres_function_self_time_seconds", + "postgres_function_total_time_seconds_total", + "postgres_function_self_time_seconds_total", }, collector: NewPostgresFunctionsCollector, service: model.ServiceTypePostgresql, diff --git a/internal/collector/postgres_replication.go b/internal/collector/postgres_replication.go index c62049e..72d0825 100644 --- a/internal/collector/postgres_replication.go +++ b/internal/collector/postgres_replication.go @@ -87,14 +87,14 @@ func NewPostgresReplicationCollector(constLabels prometheus.Labels, _ model.Coll }, lagtotalbytes: typedDesc{ desc: prometheus.NewDesc( - prometheus.BuildFQName("postgres", "replication", "lag_total_bytes"), + prometheus.BuildFQName("postgres", "replication", "lag_all_bytes"), "Number of bytes standby is behind than primary including all phases.", []string{"client_addr", "user", "application_name", "state"}, constLabels, ), valueType: prometheus.GaugeValue, }, lagtotalseconds: typedDesc{ desc: prometheus.NewDesc( - prometheus.BuildFQName("postgres", "replication", "lag_total_seconds"), + prometheus.BuildFQName("postgres", "replication", "lag_all_seconds"), "Number of seconds standby is behind than primary including all phases.", []string{"client_addr", "user", "application_name", "state"}, constLabels, ), valueType: prometheus.GaugeValue, diff --git a/internal/collector/postgres_replication_slots.go b/internal/collector/postgres_replication_slots.go index 0a4fbaa..0428faf 100644 --- a/internal/collector/postgres_replication_slots.go +++ b/internal/collector/postgres_replication_slots.go @@ -23,7 +23,7 @@ type postgresReplicationSlotCollector struct { labelNames []string } -// NewPostgresReplicationSlotCollector returns a new Collector exposing postgres replication slots stats. +// NewPostgresReplicationSlotsCollector returns a new Collector exposing postgres replication slots stats. // For details see https://www.postgresql.org/docs/current/view-pg-replication-slots.html func NewPostgresReplicationSlotsCollector(constLabels prometheus.Labels, _ model.CollectorSettings) (Collector, error) { var labelNames = []string{"database", "slot_name", "slot_type", "active"} diff --git a/internal/collector/postgres_replication_test.go b/internal/collector/postgres_replication_test.go index b7a4ca5..d0659af 100644 --- a/internal/collector/postgres_replication_test.go +++ b/internal/collector/postgres_replication_test.go @@ -14,9 +14,9 @@ func TestPostgresReplicationCollector_Update(t *testing.T) { "postgres_recovery_info", "postgres_wal_written_bytes_total", "postgres_replication_lag_bytes", + "postgres_replication_lag_all_bytes", "postgres_replication_lag_seconds", - "postgres_replication_lag_total_bytes", - "postgres_replication_lag_total_seconds", + "postgres_replication_lag_all_seconds", }, optional: []string{}, collector: NewPostgresReplicationCollector, diff --git a/internal/collector/postgres_tables.go b/internal/collector/postgres_tables.go index 16c7582..c02e7e4 100644 --- a/internal/collector/postgres_tables.go +++ b/internal/collector/postgres_tables.go @@ -141,7 +141,7 @@ func NewPostgresTablesCollector(constLabels prometheus.Labels, _ model.Collector }, maintLastVacuum: typedDesc{ desc: prometheus.NewDesc( - prometheus.BuildFQName("postgres", "table", "last_vacuum_seconds"), + prometheus.BuildFQName("postgres", "table", "since_last_vacuum_seconds_total"), "Total time since table was vacuumed manually or automatically (not counting VACUUM FULL), in seconds.", labels, constLabels, ), @@ -149,7 +149,7 @@ func NewPostgresTablesCollector(constLabels prometheus.Labels, _ model.Collector }, maintLastAnalyze: typedDesc{ desc: prometheus.NewDesc( - prometheus.BuildFQName("postgres", "table", "last_analyze_seconds"), + prometheus.BuildFQName("postgres", "table", "since_last_analyze_seconds_total"), "Total time since table was analyzed manually or automatically, in seconds.", labels, constLabels, ), diff --git a/internal/collector/postgres_tables_test.go b/internal/collector/postgres_tables_test.go index 079fd0c..8bb63ae 100644 --- a/internal/collector/postgres_tables_test.go +++ b/internal/collector/postgres_tables_test.go @@ -22,8 +22,8 @@ func TestPostgresTablesCollector_Update(t *testing.T) { "postgres_table_tuples_live_total", "postgres_table_tuples_dead_total", "postgres_table_tuples_modified_total", - "postgres_table_last_vacuum_seconds", - "postgres_table_last_analyze_seconds", + "postgres_table_since_last_vacuum_seconds_total", + "postgres_table_since_last_analyze_seconds_total", "postgres_table_maintenance_total", "postgres_table_size_bytes", },