Skip to content

Commit 9e5a704

Browse files
committed
Stats_reset as null seems to actually be legitimate for new databases,
so don't fail for it Signed-off-by: Felix Yuan <[email protected]>
1 parent 716ac23 commit 9e5a704

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

collector/pg_stat_database.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,11 @@ func (c *PGStatDatabaseCollector) Update(ctx context.Context, instance *instance
344344
level.Debug(c.log).Log("msg", "Skipping collecting metric because it has no blk_write_time")
345345
continue
346346
}
347+
348+
statsResetMetric := 0.0
347349
if !statsReset.Valid {
348350
level.Debug(c.log).Log("msg", "Skipping collecting metric because it has no stats_reset")
349-
continue
351+
statsResetMetric = float64(statsReset.Time.Unix()),
350352
}
351353

352354
labels := []string{datid.String, datname.String}
@@ -466,7 +468,7 @@ func (c *PGStatDatabaseCollector) Update(ctx context.Context, instance *instance
466468
ch <- prometheus.MustNewConstMetric(
467469
statDatabaseStatsReset,
468470
prometheus.CounterValue,
469-
float64(statsReset.Time.Unix()),
471+
statsResetMetric,
470472
labels...,
471473
)
472474
}

0 commit comments

Comments
 (0)