diff --git a/internal/collector/linux_memory_test.go b/internal/collector/linux_memory_test.go index fe89241..db85cb1 100644 --- a/internal/collector/linux_memory_test.go +++ b/internal/collector/linux_memory_test.go @@ -1,6 +1,7 @@ package collector import ( + "fmt" "github.com/stretchr/testify/assert" "os" "path/filepath" @@ -8,6 +9,14 @@ import ( ) func TestMeminfoCollector_Update(t *testing.T) { + meminfo, err := os.ReadFile("/proc/meminfo") + assert.NoError(t, err) + fmt.Println(string(meminfo)) + + vmstat, err := os.ReadFile("/proc/vmstat") + assert.NoError(t, err) + fmt.Println(string(vmstat)) + var input = pipelineInput{ required: []string{ "node_memory_MemTotal", "node_memory_MemFree", "node_memory_MemAvailable", "node_memory_MemUsed", @@ -32,6 +41,7 @@ func TestMeminfoCollector_Update(t *testing.T) { "node_memory_WritebackTmp", "node_memory_NFS_Unstable", "node_memory_DirectMap2M", "node_memory_Hugetlb", "node_memory_CmaTotal", "node_memory_Mlocked", "node_memory_ShmemPmdMapped", "node_memory_SUnreclaim", "node_memory_KernelStack", "node_memory_VmallocChunk", "node_memory_Percpu", "node_memory_HardwareCorrupted", + "node_memory_CmaFree", "node_memory_CmaTotal", // vmstat "node_vmstat_nr_free_pages", "node_vmstat_nr_zone_inactive_anon", "node_vmstat_nr_zone_active_anon", "node_vmstat_nr_zone_inactive_file", "node_vmstat_nr_zone_active_file", "node_vmstat_nr_zone_unevictable", @@ -83,7 +93,8 @@ func TestMeminfoCollector_Update(t *testing.T) { "node_vmstat_pgsteal_anon", "node_vmstat_pgsteal_file", "node_vmstat_pgscan_file", "node_vmstat_pgscan_anon", "node_vmstat_thp_file_fallback_charge", "node_vmstat_nr_foll_pin_released", "node_vmstat_thp_file_fallback", "node_vmstat_thp_fault_fallback_charge", "node_vmstat_nr_swapcached", "node_vmstat_direct_map_level2_splits", - "node_vmstat_direct_map_level3_splits", + "node_vmstat_direct_map_level3_splits", "node_vmstat_workingset_refault", "node_vmstat_workingset_activate", + "node_vmstat_workingset_restore", "node_vmstat_pgdemote_kswapd", "node_vmstat_pgdemote_direct", }, collector: NewMeminfoCollector, } diff --git a/internal/collector/postgres_database.go b/internal/collector/postgres_database.go index 76794e4..21a4270 100644 --- a/internal/collector/postgres_database.go +++ b/internal/collector/postgres_database.go @@ -46,7 +46,11 @@ type postgresDatabasesCollector struct { commits typedDesc rollbacks typedDesc blocks typedDesc - tuples typedDesc + tuplesReturned typedDesc + tuplesFetched typedDesc + tuplesInserted typedDesc + tuplesUpdated typedDesc + tuplesDeleted typedDesc tempbytes typedDesc tempfiles typedDesc conflicts typedDesc @@ -89,10 +93,34 @@ func NewPostgresDatabasesCollector(constLabels labels, settings model.CollectorS []string{"database", "access"}, constLabels, settings.Filters, ), - tuples: newBuiltinTypedDesc( - descOpts{"postgres", "database", "tuples_total", "Total number of rows processed by each type of operation.", 0}, + tuplesReturned: newBuiltinTypedDesc( + descOpts{"postgres", "database", "tuples_returned_total", "Total number of rows returned per each database.", 0}, prometheus.CounterValue, - []string{"database", "tuples"}, constLabels, + []string{"database"}, constLabels, + settings.Filters, + ), + tuplesFetched: newBuiltinTypedDesc( + descOpts{"postgres", "database", "tuples_fetched_total", "Total number of rows fetched per each database.", 0}, + prometheus.CounterValue, + []string{"database"}, constLabels, + settings.Filters, + ), + tuplesInserted: newBuiltinTypedDesc( + descOpts{"postgres", "database", "tuples_inserted_total", "Total number of rows inserted per each database.", 0}, + prometheus.CounterValue, + []string{"database"}, constLabels, + settings.Filters, + ), + tuplesUpdated: newBuiltinTypedDesc( + descOpts{"postgres", "database", "tuples_updated_total", "Total number of rows updated per each database.", 0}, + prometheus.CounterValue, + []string{"database"}, constLabels, + settings.Filters, + ), + tuplesDeleted: newBuiltinTypedDesc( + descOpts{"postgres", "database", "tuples_deleted_total", "Total number of rows deleted per each database.", 0}, + prometheus.CounterValue, + []string{"database"}, constLabels, settings.Filters, ), tempbytes: newBuiltinTypedDesc( @@ -209,11 +237,11 @@ func (c *postgresDatabasesCollector) Update(config Config, ch chan<- prometheus. ch <- c.rollbacks.newConstMetric(stat.xactrollback, stat.database) ch <- c.blocks.newConstMetric(stat.blksread, stat.database, "read") ch <- c.blocks.newConstMetric(stat.blkshit, stat.database, "hit") - ch <- c.tuples.newConstMetric(stat.tupreturned, stat.database, "returned") - ch <- c.tuples.newConstMetric(stat.tupfetched, stat.database, "fetched") - ch <- c.tuples.newConstMetric(stat.tupinserted, stat.database, "inserted") - ch <- c.tuples.newConstMetric(stat.tupupdated, stat.database, "updated") - ch <- c.tuples.newConstMetric(stat.tupdeleted, stat.database, "deleted") + ch <- c.tuplesReturned.newConstMetric(stat.tupreturned, stat.database) + ch <- c.tuplesFetched.newConstMetric(stat.tupfetched, stat.database) + ch <- c.tuplesInserted.newConstMetric(stat.tupinserted, stat.database) + ch <- c.tuplesUpdated.newConstMetric(stat.tupupdated, stat.database) + ch <- c.tuplesDeleted.newConstMetric(stat.tupdeleted, stat.database) ch <- c.tempbytes.newConstMetric(stat.tempbytes, stat.database) ch <- c.tempfiles.newConstMetric(stat.tempfiles, stat.database) diff --git a/internal/collector/postgres_database_test.go b/internal/collector/postgres_database_test.go index e08973f..0927fb2 100644 --- a/internal/collector/postgres_database_test.go +++ b/internal/collector/postgres_database_test.go @@ -14,7 +14,11 @@ func TestPostgresDatabasesCollector_Update(t *testing.T) { "postgres_database_xact_commits_total", "postgres_database_xact_rollbacks_total", "postgres_database_blocks_total", - "postgres_database_tuples_total", + "postgres_database_tuples_returned_total", + "postgres_database_tuples_fetched_total", + "postgres_database_tuples_inserted_total", + "postgres_database_tuples_updated_total", + "postgres_database_tuples_deleted_total", "postgres_database_temp_bytes_total", "postgres_database_temp_files_total", "postgres_database_conflicts_total", @@ -25,10 +29,6 @@ func TestPostgresDatabasesCollector_Update(t *testing.T) { "postgres_database_size_bytes", "postgres_database_stats_age_seconds_total", "postgres_xacts_left_before_wraparound", - }, - // TODO: wait until Postgres 14 has been released, update Postgres version on pgscv-testing docker image - // and move these metrics to 'required' slice. - optional: []string{ "postgres_database_session_time_seconds_all_total", "postgres_database_session_time_seconds_total", "postgres_database_sessions_all_total",