6565 Name : "immudb_replication_allow_commit_up_to_tx_id" ,
6666 Help : "most recently received confirmation up to which commit id the replica is allowed to durably commit" ,
6767 }, []string {"db" })
68+
69+ _metricsReplicationLag = promauto .NewGaugeVec (prometheus.GaugeOpts {
70+ Name : "immudb_replication_lag" ,
71+ Help : "The difference between the last transaction committed by the primary and replicated by the replica" ,
72+ }, []string {"db" })
6873)
6974
7075type metrics struct {
@@ -76,6 +81,7 @@ type metrics struct {
7681 replicatorsInRetryDelay prometheus.Gauge
7782 primaryCommittedTxID prometheus.Gauge
7883 allowCommitUpToTxID prometheus.Gauge
84+ replicationLag prometheus.Gauge
7985}
8086
8187// metricsForDb returns metrics object for particular database name
@@ -89,6 +95,7 @@ func metricsForDb(dbName string) metrics {
8995 replicatorsInRetryDelay : _metricsReplicatorsInRetryDelay .WithLabelValues (dbName ),
9096 primaryCommittedTxID : _metricsReplicationPrimaryCommittedTxID .WithLabelValues (dbName ),
9197 allowCommitUpToTxID : _metricsAllowCommitUpToTxID .WithLabelValues (dbName ),
98+ replicationLag : _metricsReplicationLag .WithLabelValues (dbName ),
9299 }
93100}
94101
@@ -99,6 +106,7 @@ func (m *metrics) reset() {
99106 m .replicatorsInRetryDelay .Set (0 )
100107 m .primaryCommittedTxID .Set (0 )
101108 m .allowCommitUpToTxID .Set (0 )
109+ m .replicationLag .Set (0 )
102110}
103111
104112// replicationTimeHistogramTimer returns prometheus timer for replicationTimeHistogram
0 commit comments