Skip to content

Commit cf61deb

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 cf61deb

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

src/v/storage/probe.cc

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -255,21 +255,18 @@ 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(
268259
"compaction_ratio",
269260
[this] { return _compaction_ratio; },
270-
sm::description("Average segment compaction ratio"),
261+
sm::description(
262+
"Sum of compaction ratios across segments in this partition. "
263+
"When aggregate_metrics is enabled, this is summed across all "
264+
"partitions in a topic; divide by the partition count to get "
265+
"the average compaction ratio."),
271266
labels),
272-
});
267+
},
268+
{},
269+
{sm::shard_label, metrics::partition_label});
273270
}
274271

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

0 commit comments

Comments
 (0)