From a4a281b3cf12f91b63a9bfe5e4464faee4d52fe1 Mon Sep 17 00:00:00 2001 From: Colin Barry Date: Thu, 19 Nov 2026 10:05:38 +0000 Subject: [PATCH 1/3] docs(monitoring): Add replica state, replication lag, and role gauges --- pages/database-management/monitoring.mdx | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/pages/database-management/monitoring.mdx b/pages/database-management/monitoring.mdx index 24e93396b..b17a01091 100644 --- a/pages/database-management/monitoring.mdx +++ b/pages/database-management/monitoring.mdx @@ -381,6 +381,41 @@ used. | memgraph\_write\_queries\_total | Counter | Number of write-only queries executed. | | memgraph\_read\_write\_queries\_total | Counter | Number of read-write queries executed. | +#### Replication metrics + +Every data instance reports replication metrics, with or without [high +availability](/database-management/clustering/high-availability); coordinators +don't. `SHOW METRICS INFO` doesn't include them; `SHOW REPLICATION ROLE`, `SHOW +REPLICAS`, and `SHOW REPLICATION LAG` show the same information. + + | Name | Type | Description | + | ---- | ---- | ----------- | + | memgraph\_replication\_role | Gauge | `1` for the instance's current replication role, `0` for the other role. | + | memgraph\_main\_writeable | Gauge | `1` if the instance is a MAIN that accepts writes, `0` otherwise. | + | memgraph\_registered\_replicas | Gauge | Number of REPLICAs registered on the MAIN. | + | memgraph\_replica\_state | Gauge | `1` for the REPLICA's current state, `0` for the other states. | + | memgraph\_replica\_txns\_behind | Gauge | Number of committed transactions the REPLICA is behind the MAIN. | + +The `role` label of `memgraph_replication_role` is `main` or `replica`, as +[`SHOW REPLICATION ROLE`](/database-management/clustering/replication/replication-commands-reference#show-replication-role) +shows it. + +The MAIN reports `memgraph_replica_state` and `memgraph_replica_txns_behind` +once for each REPLICA and database, with the labels `mg_instance` (the +REPLICA's name), `database`, and `mode` (`sync`, +`async`, or `strict_sync`). The `state` label uses the [REPLICA +states](/database-management/clustering/replication/how-replication-works#replica-states) +as `SHOW REPLICAS` shows them: `ready`, `replicating`, `recovery`, `invalid`, or +`diverged`. + +A healthy ASYNC REPLICA is often `invalid` under constant writes, so use the +`mode` label to tell it apart from a SYNC REPLICA that fell behind. + +`memgraph_replica_txns_behind` counts transactions, as [`SHOW REPLICATION +LAG`](/database-management/clustering/high-availability/ha-commands-reference#show-replication-lag) +does on coordinators. The `behind` field of `SHOW REPLICAS` compares timestamps +instead. + #### Schema and storage info metrics | Name | Type | Description | From ced8c3f0d5dd14815009ae2dfa8c7896b9b51501 Mon Sep 17 00:00:00 2001 From: Colin Barry Date: Thu, 19 Nov 2026 13:35:49 +0000 Subject: [PATCH 2/3] docs(replication): Rename the writeable gauge and add the writeable column to SHOW REPLICATION ROLE --- .../replication-commands-reference.mdx | 20 ++++++++++++------- pages/database-management/monitoring.mdx | 7 +++++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/pages/database-management/clustering/replication/replication-commands-reference.mdx b/pages/database-management/clustering/replication/replication-commands-reference.mdx index 9459568d2..9498ed848 100644 --- a/pages/database-management/clustering/replication/replication-commands-reference.mdx +++ b/pages/database-management/clustering/replication/replication-commands-reference.mdx @@ -77,15 +77,21 @@ SHOW REPLICATION ROLE; ``` **Returns:** -- Current replication role: "main" or "replica" +- `replication role`: "main" or "replica" +- `writeable`: whether the instance accepts writes. It's `false` on a REPLICA. + On a MAIN, it's `true` unless the MAIN is part of a [high availability + cluster](/database-management/clustering/high-availability) and the + coordinators haven't enabled writes on it. + +Before Memgraph 3.15, `SHOW REPLICATION ROLE` returned only the role. **Example output:** -```nocopy -+------------------+ -| replication role | -+------------------+ -| "replica" | -+------------------+ +```plaintext copy=false ++------------------+-----------+ +| replication role | writeable | ++------------------+-----------+ +| "replica" | false | ++------------------+-----------+ ``` **When to use:** diff --git a/pages/database-management/monitoring.mdx b/pages/database-management/monitoring.mdx index b17a01091..6b04406c5 100644 --- a/pages/database-management/monitoring.mdx +++ b/pages/database-management/monitoring.mdx @@ -391,14 +391,17 @@ REPLICAS`, and `SHOW REPLICATION LAG` show the same information. | Name | Type | Description | | ---- | ---- | ----------- | | memgraph\_replication\_role | Gauge | `1` for the instance's current replication role, `0` for the other role. | - | memgraph\_main\_writeable | Gauge | `1` if the instance is a MAIN that accepts writes, `0` otherwise. | + | memgraph\_accepts\_writes | Gauge | `1` if replication lets the instance accept writes, `0` otherwise. | | memgraph\_registered\_replicas | Gauge | Number of REPLICAs registered on the MAIN. | | memgraph\_replica\_state | Gauge | `1` for the REPLICA's current state, `0` for the other states. | | memgraph\_replica\_txns\_behind | Gauge | Number of committed transactions the REPLICA is behind the MAIN. | The `role` label of `memgraph_replication_role` is `main` or `replica`, as [`SHOW REPLICATION ROLE`](/database-management/clustering/replication/replication-commands-reference#show-replication-role) -shows it. +shows it, and `memgraph_accepts_writes` matches its `writeable` column. An +instance accepts writes if it's a MAIN and, in a high availability cluster, the +coordinators have enabled writes on it. The gauge doesn't reflect license or +storage limits. The MAIN reports `memgraph_replica_state` and `memgraph_replica_txns_behind` once for each REPLICA and database, with the labels `mg_instance` (the From e5538f251b326fe447a318690177af01be88848b Mon Sep 17 00:00:00 2001 From: Colin Barry Date: Sun, 22 Nov 2026 09:46:04 +0000 Subject: [PATCH 3/3] Spell out transactions in the replica lag metric name --- pages/database-management/monitoring.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pages/database-management/monitoring.mdx b/pages/database-management/monitoring.mdx index 6b04406c5..5862e7d38 100644 --- a/pages/database-management/monitoring.mdx +++ b/pages/database-management/monitoring.mdx @@ -403,9 +403,9 @@ instance accepts writes if it's a MAIN and, in a high availability cluster, the coordinators have enabled writes on it. The gauge doesn't reflect license or storage limits. -The MAIN reports `memgraph_replica_state` and `memgraph_replica_txns_behind` -once for each REPLICA and database, with the labels `mg_instance` (the -REPLICA's name), `database`, and `mode` (`sync`, +The MAIN reports `memgraph_replica_state` and +`memgraph_replica_transactions_behind` once for each REPLICA and database, with +the labels `mg_instance` (the REPLICA's name), `database`, and `mode` (`sync`, `async`, or `strict_sync`). The `state` label uses the [REPLICA states](/database-management/clustering/replication/how-replication-works#replica-states) as `SHOW REPLICAS` shows them: `ready`, `replicating`, `recovery`, `invalid`, or @@ -414,7 +414,7 @@ as `SHOW REPLICAS` shows them: `ready`, `replicating`, `recovery`, `invalid`, or A healthy ASYNC REPLICA is often `invalid` under constant writes, so use the `mode` label to tell it apart from a SYNC REPLICA that fell behind. -`memgraph_replica_txns_behind` counts transactions, as [`SHOW REPLICATION +`memgraph_replica_transactions_behind` counts transactions, as [`SHOW REPLICATION LAG`](/database-management/clustering/high-availability/ha-commands-reference#show-replication-lag) does on coordinators. The `behind` field of `SHOW REPLICAS` compares timestamps instead.