diff --git a/internal/collector/postgres_locks.go b/internal/collector/postgres_locks.go index a740af1..1b47ae9 100644 --- a/internal/collector/postgres_locks.go +++ b/internal/collector/postgres_locks.go @@ -58,7 +58,16 @@ func (c *postgresLocksCollector) Update(config Config, ch chan<- prometheus.Metr func parsePostgresLocksStats(r *model.PGResult) map[string]float64 { log.Debug("parse postgres locks stats") - stats := make(map[string]float64) + stats := map[string]float64{ + "AccessShareLock": 0, + "RowShareLock": 0, + "RowExclusiveLock": 0, + "ShareUpdateExclusiveLock": 0, + "ShareLock": 0, + "ShareRowExclusiveLock": 0, + "ExclusiveLock": 0, + "AccessExclusiveLock": 0, + } for _, row := range r.Rows { if len(row) != 2 { diff --git a/internal/collector/postgres_locks_test.go b/internal/collector/postgres_locks_test.go index f12944b..0224b64 100644 --- a/internal/collector/postgres_locks_test.go +++ b/internal/collector/postgres_locks_test.go @@ -40,10 +40,14 @@ func Test_parsePostgresLocksStats(t *testing.T) { }, }, want: map[string]float64{ - "RowExclusiveLock": 150, - "RowShareLock": 100, - "ExclusiveLock": 50, - "AccessShareLock": 2000, + "AccessShareLock": 2000, + "RowShareLock": 100, + "RowExclusiveLock": 150, + "ShareUpdateExclusiveLock": 0, + "ShareLock": 0, + "ShareRowExclusiveLock": 0, + "ExclusiveLock": 50, + "AccessExclusiveLock": 0, }, }, }