Make walreceiver collector useful w/o repmgr (#1086)
In a streaming replication setup that was created without replication manager (`repmgr`), the `stat_wal_receiver` collector does not return any metrics, because one value it wants to export is not present. This is rather overly opinionated. The missing metric is comparatively uninteresting and does not justify discarding all the others. And replication setups created without `repmgr` are not exactly rare. This commit makes the one relevant metric optional and simply skips it if the respective value cannot be determined. Signed-off-by: Conrad Hoffmann <ch@bitfehler.net>
This commit is contained in:
parent
f9c74570ed
commit
552ff92f8b
|
@ -203,10 +203,6 @@ func (c *PGStatWalReceiverCollector) Update(ctx context.Context, instance *insta
|
||||||
c.log.Debug("Skipping wal receiver stats because latest_end_time is null")
|
c.log.Debug("Skipping wal receiver stats because latest_end_time is null")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !upstreamNode.Valid {
|
|
||||||
c.log.Debug("Skipping wal receiver stats because upstream_node is null")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
statWalReceiverReceiveStartLsn,
|
statWalReceiverReceiveStartLsn,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
|
@ -257,11 +253,15 @@ func (c *PGStatWalReceiverCollector) Update(ctx context.Context, instance *insta
|
||||||
latestEndTime.Float64,
|
latestEndTime.Float64,
|
||||||
labels...)
|
labels...)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
if !upstreamNode.Valid {
|
||||||
statWalReceiverUpstreamNode,
|
c.log.Debug("Skipping wal receiver stats upstream_node because it is null")
|
||||||
prometheus.GaugeValue,
|
} else {
|
||||||
float64(upstreamNode.Int64),
|
ch <- prometheus.MustNewConstMetric(
|
||||||
labels...)
|
statWalReceiverUpstreamNode,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
float64(upstreamNode.Int64),
|
||||||
|
labels...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err := rows.Err(); err != nil {
|
if err := rows.Err(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue