|
20 | 20 |
|
21 | 21 | namespace cluster {
|
22 | 22 |
|
| 23 | +static const ss::sstring cluster_metrics_name |
| 24 | + = prometheus_sanitize::metrics_name("cluster:partition"); |
| 25 | + |
23 | 26 | replicated_partition_probe::replicated_partition_probe(
|
24 | 27 | const partition& p) noexcept
|
25 | 28 | : _partition(p) {
|
@@ -59,8 +62,31 @@ void replicated_partition_probe::setup_internal_metrics(const model::ntp& ntp) {
|
59 | 62 | partition_label(ntp.tp.partition()),
|
60 | 63 | };
|
61 | 64 |
|
| 65 | + // The following few metrics uses a separate add_group call which doesn't |
| 66 | + // aggregate any labels since aggregation does not make sense for "leader |
| 67 | + // ID" values. |
| 68 | + _metrics.add_group( |
| 69 | + cluster_metrics_name, |
| 70 | + {sm::make_gauge( |
| 71 | + "leader_id", |
| 72 | + [this] { |
| 73 | + return _partition.raft()->get_leader_id().value_or( |
| 74 | + model::node_id(-1)); |
| 75 | + }, |
| 76 | + sm::description("Id of current partition leader"), |
| 77 | + labels), |
| 78 | + sm::make_gauge( |
| 79 | + "under_replicated_replicas", |
| 80 | + [this] { |
| 81 | + return _partition.raft()->get_under_replicated().value_or(0); |
| 82 | + }, |
| 83 | + sm::description("Number of under replicated replicas"), |
| 84 | + labels)}, |
| 85 | + {}, |
| 86 | + {sm::shard_label}); |
| 87 | + |
62 | 88 | _metrics.add_group(
|
63 |
| - prometheus_sanitize::metrics_name("cluster:partition"), |
| 89 | + cluster_metrics_name, |
64 | 90 | {
|
65 | 91 | sm::make_gauge(
|
66 | 92 | "leader",
|
@@ -96,21 +122,6 @@ void replicated_partition_probe::setup_internal_metrics(const model::ntp& ntp) {
|
96 | 122 | sm::description(
|
97 | 123 | "Partion high watermark i.e. highest consumable offset"),
|
98 | 124 | labels),
|
99 |
| - sm::make_gauge( |
100 |
| - "leader_id", |
101 |
| - [this] { |
102 |
| - return _partition.raft()->get_leader_id().value_or( |
103 |
| - model::node_id(-1)); |
104 |
| - }, |
105 |
| - sm::description("Id of current partition leader"), |
106 |
| - labels), |
107 |
| - sm::make_gauge( |
108 |
| - "under_replicated_replicas", |
109 |
| - [this] { |
110 |
| - return _partition.raft()->get_under_replicated().value_or(0); |
111 |
| - }, |
112 |
| - sm::description("Number of under replicated replicas"), |
113 |
| - labels), |
114 | 125 | sm::make_counter(
|
115 | 126 | "records_produced",
|
116 | 127 | [this] { return _records_produced; },
|
@@ -153,13 +164,13 @@ void replicated_partition_probe::setup_internal_metrics(const model::ntp& ntp) {
|
153 | 164 | labels),
|
154 | 165 | },
|
155 | 166 | {},
|
156 |
| - {sm::shard_label}); |
| 167 | + {sm::shard_label, partition_label}); |
157 | 168 |
|
158 | 169 | if (
|
159 | 170 | config::shard_local_cfg().enable_schema_id_validation()
|
160 | 171 | != pandaproxy::schema_registry::schema_id_validation_mode::none) {
|
161 | 172 | _metrics.add_group(
|
162 |
| - prometheus_sanitize::metrics_name("cluster:partition"), |
| 173 | + cluster_metrics_name, |
163 | 174 | {
|
164 | 175 | sm::make_counter(
|
165 | 176 | "schema_id_validation_records_failed",
|
@@ -276,7 +287,7 @@ void replicated_partition_probe::setup_public_metrics(const model::ntp& ntp) {
|
276 | 287 | config::shard_local_cfg().enable_schema_id_validation()
|
277 | 288 | != pandaproxy::schema_registry::schema_id_validation_mode::none) {
|
278 | 289 | _public_metrics.add_group(
|
279 |
| - prometheus_sanitize::metrics_name("cluster:partition"), |
| 290 | + cluster_metrics_name, |
280 | 291 | {
|
281 | 292 | sm::make_counter(
|
282 | 293 | "schema_id_validation_records_failed",
|
|
0 commit comments