Skip to content

Commit f8d7345

Browse files
dashboard: add leader election panels
Add panels to "Cluster overview" section to dashboard templates. Update consists of panels with following metrics: - tnt_election_state - tnt_election_vote - tnt_election_leader - tnt_election_term Closes #178
1 parent eb341ae commit f8d7345

22 files changed

+19268
-10176
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Panels with net statistics per thread
1313
- Panel with failover trigger count
1414
- Panels with syncro replication queue statistics
15+
- Panels with leader election statistics
1516

1617
### Changed
1718
- Replace LuaJit deprecated metrics with new ones

dashboard/panels/cluster.libsonnet

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,4 +473,143 @@ local prometheus = grafana.prometheus;
473473
'last'
474474
)
475475
),
476+
477+
local election_warning(description) = std.join(
478+
'\n',
479+
[description, |||
480+
Panel works with metrics 0.15.0 or newer, Tarantool 2.6.1 or newer.
481+
|||]
482+
),
483+
484+
election_state(
485+
title='Instance election state',
486+
description=election_warning(|||
487+
Election state (mode) of the node.
488+
When election is enabled, the node is writable only in the leader state.
489+
490+
All the non-leader nodes are called `follower`s.
491+
`candidate`s are nodes that start a new election round.
492+
`leader` is a node that collected a quorum of votes.
493+
494+
Panel works with Grafana 8.x.
495+
|||),
496+
datasource_type=null,
497+
datasource=null,
498+
policy=null,
499+
measurement=null,
500+
job=null,
501+
alias=null,
502+
):: timeseries.new(
503+
title=title,
504+
description=description,
505+
datasource=datasource,
506+
panel_width=6,
507+
max=2,
508+
min=0,
509+
).addValueMapping(
510+
0, 'green', 'follower'
511+
).addValueMapping(
512+
1, 'yellow', 'candidate'
513+
).addValueMapping(
514+
2, 'green', 'leader'
515+
).addRangeMapping(
516+
0.001, 0.999, '-'
517+
).addRangeMapping(
518+
1.001, 1.999, '-'
519+
).addTarget(
520+
common.default_metric_target(
521+
datasource_type,
522+
'tnt_election_state',
523+
job,
524+
policy,
525+
measurement,
526+
alias,
527+
'last'
528+
)
529+
),
530+
531+
election_vote(
532+
title='Instance election vote',
533+
description=election_warning(|||
534+
ID of a node the current node votes for.
535+
If the value is 0, it means the node hasn’t
536+
voted in the current term yet.
537+
|||),
538+
datasource_type=null,
539+
datasource=null,
540+
policy=null,
541+
measurement=null,
542+
job=null,
543+
alias=null,
544+
):: common.default_graph(
545+
title=title,
546+
description=description,
547+
datasource=datasource,
548+
labelY1='id',
549+
decimals=0,
550+
panel_width=6,
551+
).addTarget(common.default_metric_target(
552+
datasource_type,
553+
'tnt_election_vote',
554+
job,
555+
policy,
556+
measurement,
557+
alias,
558+
)),
559+
560+
election_leader(
561+
title='Instance election leader',
562+
description=election_warning(|||
563+
Leader node ID in the current term.
564+
If the value is 0, it means the node doesn’t know which
565+
node is the leader in the current term.
566+
|||),
567+
datasource_type=null,
568+
datasource=null,
569+
policy=null,
570+
measurement=null,
571+
job=null,
572+
alias=null,
573+
):: common.default_graph(
574+
title=title,
575+
description=description,
576+
datasource=datasource,
577+
labelY1='id',
578+
decimals=0,
579+
panel_width=6,
580+
).addTarget(common.default_metric_target(
581+
datasource_type,
582+
'tnt_election_leader',
583+
job,
584+
policy,
585+
measurement,
586+
alias,
587+
)),
588+
589+
election_term(
590+
title='Election term',
591+
description=election_warning(|||
592+
Current election term.
593+
|||),
594+
datasource_type=null,
595+
datasource=null,
596+
policy=null,
597+
measurement=null,
598+
job=null,
599+
alias=null,
600+
):: common.default_graph(
601+
title=title,
602+
description=description,
603+
datasource=datasource,
604+
labelY1='term',
605+
decimals=0,
606+
panel_width=6,
607+
).addTarget(common.default_metric_target(
608+
datasource_type,
609+
'tnt_election_term',
610+
job,
611+
policy,
612+
measurement,
613+
alias,
614+
)),
476615
}

dashboard/section.libsonnet

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,38 @@ local tdg_tuples = import 'dashboard/panels/tdg/tuples.libsonnet';
5959
measurement=measurement,
6060
alias=alias,
6161
),
62+
63+
cluster.election_state(
64+
datasource_type=datasource_type,
65+
datasource=datasource,
66+
policy=policy,
67+
measurement=measurement,
68+
alias=alias,
69+
),
70+
71+
cluster.election_vote(
72+
datasource_type=datasource_type,
73+
datasource=datasource,
74+
policy=policy,
75+
measurement=measurement,
76+
alias=alias,
77+
),
78+
79+
cluster.election_leader(
80+
datasource_type=datasource_type,
81+
datasource=datasource,
82+
policy=policy,
83+
measurement=measurement,
84+
alias=alias,
85+
),
86+
87+
cluster.election_term(
88+
datasource_type=datasource_type,
89+
datasource=datasource,
90+
policy=policy,
91+
measurement=measurement,
92+
alias=alias,
93+
),
6294
],
6395

6496
// Must be used only in the top of a dashboard, overall stat panels use complicated layout
@@ -134,6 +166,34 @@ local tdg_tuples = import 'dashboard/panels/tdg/tuples.libsonnet';
134166
job=job,
135167
alias=alias,
136168
),
169+
170+
cluster.election_state(
171+
datasource_type=datasource_type,
172+
datasource=datasource,
173+
job=job,
174+
alias=alias,
175+
),
176+
177+
cluster.election_vote(
178+
datasource_type=datasource_type,
179+
datasource=datasource,
180+
job=job,
181+
alias=alias,
182+
),
183+
184+
cluster.election_leader(
185+
datasource_type=datasource_type,
186+
datasource=datasource,
187+
job=job,
188+
alias=alias,
189+
),
190+
191+
cluster.election_term(
192+
datasource_type=datasource_type,
193+
datasource=datasource,
194+
job=job,
195+
alias=alias,
196+
),
137197
],
138198

139199
replication(datasource_type, datasource, policy=null, measurement=null, job=null, alias=null):: [

supported_metrics.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ Based on [tarantool/metrics 0.16.0](https://github.com/tarantool/metrics/release
125125
- [x] **tnt_synchro_queue_term**: see *Replication overview/Synchronous queue term* panel ([#178](https://github.com/tarantool/grafana-dashboard/issues/178))
126126
- [x] **tnt_synchro_queue_len**: see *Replication overview/Synchronous queue transactions* panel ([#178](https://github.com/tarantool/grafana-dashboard/issues/178))
127127
- [x] **tnt_synchro_queue_busy**: see *Replication overview/Synchronous queue busy* panel ([#178](https://github.com/tarantool/grafana-dashboard/issues/178))
128-
- [ ] **tnt_election_state**: ([#178](https://github.com/tarantool/grafana-dashboard/issues/178))
129-
- [ ] **tnt_election_vote**: ([#178](https://github.com/tarantool/grafana-dashboard/issues/178))
130-
- [ ] **tnt_election_leader**: ([#178](https://github.com/tarantool/grafana-dashboard/issues/178))
131-
- [ ] **tnt_election_term**: ([#178](https://github.com/tarantool/grafana-dashboard/issues/178))
128+
- [x] **tnt_election_state**: see *Cluster overview/Instance election state* panel ([#178](https://github.com/tarantool/grafana-dashboard/issues/178))
129+
- [x] **tnt_election_vote**: see *Cluster overview/Instance election vote* panel ([#178](https://github.com/tarantool/grafana-dashboard/issues/178))
130+
- [x] **tnt_election_leader**: see *Cluster overview/Instance election leader* panel ([#178](https://github.com/tarantool/grafana-dashboard/issues/178))
131+
- [x] **tnt_election_term**: see *Cluster overview/Election term* panel ([#178](https://github.com/tarantool/grafana-dashboard/issues/178))
132132
- [x] **tnt_net_per_thread_sent_total**: see *Tarantool network activity/Data sent (per thread)* panel ([#178](https://github.com/tarantool/grafana-dashboard/issues/178))
133133
- [x] **tnt_net_per_thread_received_total**: see *Tarantool network activity/Data received (per thread)* panel ([#178](https://github.com/tarantool/grafana-dashboard/issues/178))
134134
- [x] **tnt_net_per_thread_connections_total**: see *Tarantool network activity/New binary connections (per thread)* panel ([#178](https://github.com/tarantool/grafana-dashboard/issues/178))

0 commit comments

Comments
 (0)