Proposed change
Summary
Enhancement: Show percentage difference from leader in nats server stream-check --unsynced
When nats server stream-check --stdin --unsynced is invoked, modify the output to include percentage differences from the stream leader on numeric columns for non-leader replica rows. This gives operators immediate visibility into how far off replicas are, not just that they differ.
Proposed behavior
Modify --unsynced output so that for each stream group, the following columns on non-leader rows include a percentage difference relative to the leader (*):
Columns: Messages, Bytes, Subjects, Deleted, Consumers, First, Last
Rules
- Leader row (denoted by
* on the node name): show raw values only, no percentage.
- Non-leader rows: append
(+X.XX%) or (-X.XX%) to the numeric value.
- When the replica value equals the leader value: show the raw value only, no percentage.
- When the percentage rounds to less than 0.01%: show
(+<0.01%) or (-<0.01%) to indicate a non-zero but negligible difference.
- When the leader value is 0 and the replica value is non-zero: show
(+inf%) since division by zero makes a true percentage undefined.
- Precision: 2 decimal places.
Example output
Given three streams with unsynced replicas, the enhanced output would look like:
events_gen_3 (leader: node-v1-0)
| Node |
Messages |
Bytes |
Subjects |
Deleted |
Consumers |
First |
Last |
| node-v1-0* |
214183 |
39409672 |
1 |
2 |
1 |
352385805 |
352599989 |
| node-v1-3 |
214167 (-0.01%) |
39406728 (-0.01%) |
1 |
1 (-50.00%) |
1 |
352385822 (+<0.01%) |
352599989 |
| node-v1-4 |
214172 (-0.01%) |
39407648 (-0.01%) |
1 |
0 (-100.00%) |
1 |
352385818 (+<0.01%) |
352599989 |
payloads (leader: node-v1-0)
| Node |
Messages |
Bytes |
Subjects |
Deleted |
Consumers |
First |
Last |
| node-v1-0* |
9382 |
298024237 |
20 |
49918 |
20 |
1025740131 |
1025799430 |
| node-v1-1 |
9373 (-0.10%) |
297935168 (-0.03%) |
20 |
50327 (+0.82%) |
20 |
1025740131 |
1025799830 (+<0.01%) |
| node-v1-2 |
9302 (-0.85%) |
295487415 (-0.85%) |
20 |
49918 |
20 |
1025740131 |
1025799350 (-<0.01%) |
events_gen_1 (leader: node-v1-4)
| Node |
Messages |
Bytes |
Subjects |
Deleted |
Consumers |
First |
Last |
| node-v1-4* |
2 |
322 |
2 |
0 |
1 |
978060 |
978061 |
| node-v1-1 |
2 |
322 |
2 |
0 |
1 |
966144 (-1.22%) |
966145 (-1.22%) |
| node-v1-3 |
2 |
322 |
2 |
0 |
1 |
902183 (-7.76%) |
902184 (-7.76%) |
Use case
Why this is useful
Currently --unsynced tells you streams are out of sync, but you have to mentally diff the numbers across rows to gauge severity. The percentage makes triage immediate:
- A -0.01% message difference is likely a transient lag.
- A -7.76% sequence number difference suggests a replica is significantly behind.
- A -100.00% deleted difference means tombstones haven't propagated at all.
- A +0.82% deleted difference (replica has more deletes than leader) signals divergence in the opposite direction.
Implementation notes
- No new flag required. The percentage diff should always be shown when
--unsynced is used, since investigating divergence is the entire purpose of that flag.
- The
* on the node name already identifies the leader; the percentage computation uses that row as the baseline.
Contribution
No response
Proposed change
Summary
Enhancement: Show percentage difference from leader in
nats server stream-check --unsyncedWhen
nats server stream-check --stdin --unsyncedis invoked, modify the output to include percentage differences from the stream leader on numeric columns for non-leader replica rows. This gives operators immediate visibility into how far off replicas are, not just that they differ.Proposed behavior
Modify
--unsyncedoutput so that for each stream group, the following columns on non-leader rows include a percentage difference relative to the leader (*):Columns: Messages, Bytes, Subjects, Deleted, Consumers, First, Last
Rules
*on the node name): show raw values only, no percentage.(+X.XX%)or(-X.XX%)to the numeric value.(+<0.01%)or(-<0.01%)to indicate a non-zero but negligible difference.(+inf%)since division by zero makes a true percentage undefined.Example output
Given three streams with unsynced replicas, the enhanced output would look like:
events_gen_3 (leader: node-v1-0)
payloads (leader: node-v1-0)
events_gen_1 (leader: node-v1-4)
Use case
Why this is useful
Currently
--unsyncedtells you streams are out of sync, but you have to mentally diff the numbers across rows to gauge severity. The percentage makes triage immediate:Implementation notes
--unsyncedis used, since investigating divergence is the entire purpose of that flag.*on the node name already identifies the leader; the percentage computation uses that row as the baseline.Contribution
No response