apache / apache/doris

[Enhancement] Expose the actual tablet version-limit counter (_approximate_num_rowsets) as a Prometheus metric

Open
#67,458 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
15.9k
Forks
3.9k
Avg merge
2d 23h
Merged PRs (30d)
520

Description

### Search before asking

- [x] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues.

### Description

Writes to a tablet are rejected once its version count passes `max_tablet_version_num`, and it fails with `TOO_MANY_VERSION` (E235). The check reads a counter called [_approximate_num_rowsets](https://github.com/apache/doris/blob/master/be/src/cloud/cloud_rowset_builder.cpp#L204).
The only related metric, `tablet_version_num_distribution`, reads a different counter that updates less frequently and skips tablets that are currently being written to. This hides potential issues until there is a failure.
There's no Prometheus metric for `_approximate_num_rowsets`. The only way to read it is via admin HTTP GET to /api/hotspot/tablet?metrics=num_rowsets.

### Solution

1. Add a metric fed from [_approximate_num_rowsets](https://github.com/apache/doris/blob/master/be/src/cloud/cloud_rowset_builder.cpp#L204) using the same pattern as the existing histogram in doris_metrics.{h,cpp}.
2. Report it for all tablets, including ones under active load

### Are you willing to submit PR?

- [x] Yes I am willing to submit a PR!

### Code of Conduct

- [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)

Contributor guide

Open the contributing guide

Research direction

Start with the _approximate_num_rowsets use in be/src/cloud/cloud_rowset_builder.cpp, then read the existing histogram pattern in doris_metrics.h and doris_metrics.cpp. Trace how tablet metrics are reported and confirm the new Prometheus metric includes tablets under active load and reflects the actual counter rather than the existing distribution.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, prometheus
Domain
observability
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.