Skip to content

Commit 0d04d47

Browse files
committed
storage: aggregate compaction_ratio metric across partitions
Although it is a bit more natural to leave this unaggregated to determine the compaction ratio of a log/partition rather than a topic, the cardinality of this metric is much too high, and its usefulness does not justify the cost. Because this is aggregated, it is now a sum, meaning to recover the average compaction ratio for a topic, we must divide by the number of partitions in Grafana, e.g. ``` sum(compaction_ratio) by (topic) / count(compaction_ratio) by (topic) ```
1 parent 0d4187b commit 0d04d47

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

src/v/storage/probe.cc

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -255,21 +255,17 @@ void probe::setup_metrics(const model::ntp& ntp) {
255255
"Number of segments that have been compacted away "
256256
"during adjacent merge compaction."),
257257
labels),
258-
},
259-
{},
260-
{sm::shard_label, metrics::partition_label});
261-
262-
_metrics.add_group(
263-
group_name,
264-
{
265-
// compaction_ratio cannot easily be aggregated since aggregation always
266-
// sums values and sum is nonsensical for a compaction ratio
267258
sm::make_total_bytes(
268-
"compaction_ratio",
259+
"compaction_ratio_total",
269260
[this] { return _compaction_ratio; },
270-
sm::description("Average segment compaction ratio"),
261+
sm::description(
262+
"Sum of segment compaction ratios across all partitions in a "
263+
"topic. Divide by the number of partitions for a topic to get the "
264+
"average compaction ratio per partition."),
271265
labels),
272-
});
266+
},
267+
{},
268+
{sm::shard_label, metrics::partition_label});
273269
}
274270

275271
void probe::add_initial_segment(const segment& s) {

0 commit comments

Comments
 (0)