Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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:**
Expand Down
38 changes: 38 additions & 0 deletions pages/database-management/monitoring.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,44 @@ 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\_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, 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_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
`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_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.

#### Schema and storage info metrics

| Name | Type | Description |
Expand Down