diff --git a/internal/pkg/daemon/daemon.go b/internal/pkg/daemon/daemon.go index 2826b62..dc67912 100644 --- a/internal/pkg/daemon/daemon.go +++ b/internal/pkg/daemon/daemon.go @@ -349,6 +349,7 @@ func (d *Daemon) waitForUpgrade(ctx context.Context, cfg *config.Config) (int64, logger.Err(err).Error("Error received from HeightWatcher") continue } + d.metrics.LastObservedHeight.Set(float64(newHeight.Height)) currBlockHeight := newHeight.Height lastBlockHeight := d.currHeight diff --git a/internal/pkg/metrics/metrics.go b/internal/pkg/metrics/metrics.go index fe46ba1..3d2e0da 100644 --- a/internal/pkg/metrics/metrics.go +++ b/internal/pkg/metrics/metrics.go @@ -14,12 +14,13 @@ const ( ) type Metrics struct { - Up prometheus.Gauge - BlocksToUpgrade *prometheus.GaugeVec - UpwErrs prometheus.Counter - UiwErrs prometheus.Counter - HwErrs prometheus.Counter - NotifErrs prometheus.Counter + Up prometheus.Gauge + BlocksToUpgrade *prometheus.GaugeVec + LastObservedHeight prometheus.Gauge + UpwErrs prometheus.Counter + UiwErrs prometheus.Counter + HwErrs prometheus.Counter + NotifErrs prometheus.Counter } func NewMetrics(composeFile, hostname, version string) *Metrics { @@ -43,6 +44,14 @@ func NewMetrics(composeFile, hostname, version string) *Metrics { }, []string{"upgrade_height", "upgrade_name", "upgrade_status", "upgrade_step", "chain_id", "validator_address"}, ), + LastObservedHeight: promauto.NewGauge( + prometheus.GaugeOpts{ + Namespace: namespace, + Name: "last_observed_height", + Help: "Last block height observed by the height watcher", + ConstLabels: labels, + }, + ), UpwErrs: promauto.NewCounter( prometheus.CounterOpts{ Namespace: namespace,