Skip to content

Commit

Permalink
metrics: storage: default aggregations
Browse files Browse the repository at this point in the history
Aggregate over shard, partition by default

Signed-off-by: Ben Pope <ben@redpanda.com>
  • Loading branch information
BenPope authored and Vlad Lazar committed Jun 21, 2022
1 parent 0a96c0e commit 8e5765c
Showing 1 changed file with 51 additions and 19 deletions.
70 changes: 51 additions & 19 deletions src/v/storage/probe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ void probe::setup_metrics(const model::ntp& ntp) {
topic_label(ntp.tp.topic()),
partition_label(ntp.tp.partition()),
};
auto aggregate_labels
= config::shard_local_cfg().aggregate_metrics()
? std::vector<sm::label>{sm::shard_label, partition_label}
: std::vector<sm::label>{};

_metrics.add_group(
prometheus_sanitize::metrics_name("storage:log"),
Expand All @@ -78,78 +82,97 @@ void probe::setup_metrics(const model::ntp& ntp) {
"written_bytes",
[this] { return _bytes_written; },
sm::description("Total number of bytes written"),
labels),
labels,
sm::impl::shard(),
aggregate_labels),
sm::make_counter(
"batches_written",
[this] { return _batches_written; },
sm::description("Total number of batches written"),
labels),
labels,
aggregate_labels),
sm::make_total_bytes(
"read_bytes",
[this] { return _bytes_read; },
sm::description("Total number of bytes read"),
labels),
labels,
sm::impl::shard(),
aggregate_labels),
sm::make_total_bytes(
"cached_read_bytes",
[this] { return _cached_bytes_read; },
sm::description("Total number of cached bytes read"),
labels),
labels,
sm::impl::shard(),
aggregate_labels),
sm::make_counter(
"batches_read",
[this] { return _batches_read; },
sm::description("Total number of batches read"),
labels),
labels,
aggregate_labels),
sm::make_counter(
"cached_batches_read",
[this] { return _cached_batches_read; },
sm::description("Total number of cached batches read"),
labels),
labels,
aggregate_labels),
sm::make_counter(
"log_segments_created",
[this] { return _log_segments_created; },
sm::description("Number of created log segments"),
labels),
labels,
aggregate_labels),
sm::make_counter(
"log_segments_removed",
[this] { return _log_segments_removed; },
sm::description("Number of removed log segments"),
labels),
labels,
aggregate_labels),
sm::make_counter(
"log_segments_active",
[this] { return _log_segments_active; },
sm::description("Number of active log segments"),
labels),
labels,
aggregate_labels),
sm::make_counter(
"batch_parse_errors",
[this] { return _batch_parse_errors; },
sm::description("Number of batch parsing (reading) errors"),
labels),
labels,
aggregate_labels),
sm::make_counter(
"batch_write_errors",
[this] { return _batch_write_errors; },
sm::description("Number of batch write errors"),
labels),
labels,
aggregate_labels),
sm::make_counter(
"corrupted_compaction_indices",
[this] { return _corrupted_compaction_index; },
sm::description("Number of times we had to re-construct the "
".compaction index on a segment"),
labels),
labels,
aggregate_labels),
sm::make_counter(
"compacted_segment",
[this] { return _segment_compacted; },
sm::description("Number of compacted segments"),
labels),
labels,
aggregate_labels),
sm::make_gauge(
"partition_size",
[this] { return _partition_bytes; },
sm::description("Current size of partition in bytes"),
labels),
labels,
aggregate_labels),
sm::make_total_bytes(
"compaction_ratio",
[this] { return _compaction_ratio; },
sm::description("Average segment compaction ratio"),
labels),
labels,
sm::impl::shard(),
aggregate_labels),
});
}

Expand All @@ -168,6 +191,11 @@ void readers_cache_probe::setup_metrics(const model::ntp& ntp) {
auto ns_label = sm::label("namespace");
auto topic_label = sm::label("topic");
auto partition_label = sm::label("partition");
auto aggregate_labels
= config::shard_local_cfg().aggregate_metrics()
? std::vector<sm::label>{sm::shard_label, partition_label}
: std::vector<sm::label>{};

const std::vector<sm::label_instance> labels = {
ns_label(ntp.ns()),
topic_label(ntp.tp.topic()),
Expand All @@ -181,22 +209,26 @@ void readers_cache_probe::setup_metrics(const model::ntp& ntp) {
"readers_added",
[this] { return _readers_added; },
sm::description("Number of readers added to cache"),
labels),
labels,
aggregate_labels),
sm::make_counter(
"readers_evicted",
[this] { return _readers_evicted; },
sm::description("Number of readers evicted from cache"),
labels),
labels,
aggregate_labels),
sm::make_counter(
"cache_hits",
[this] { return _cache_hits; },
sm::description("Reader cache hits"),
labels),
labels,
aggregate_labels),
sm::make_counter(
"cache_misses",
[this] { return _cache_misses; },
sm::description("Reader cache misses"),
labels),
labels,
aggregate_labels),
});
}
} // namespace storage

0 comments on commit 8e5765c

Please sign in to comment.