dao-jun opened a new issue, #19601:
URL: https://github.com/apache/pulsar/issues/19601
### Motivation
Pulsar has 2 configurations for the backlog eviction:
`backlogQuotaDefaultLimitBytes` and `backlogQuotaDefaultLimitSecond`, if topic
backlog reaches the threshold of any item, backlog eviction will be triggered.
Before backlog eviction happens, we don't have a metric to monitor how long
that it can reaches the threshold.
We can provide a progress bar metric to tell users some topics is about to
trigger backlog eviction. And users can subscribe the alter to schedule
consumers.
### Goal
Provide a metric named `pulsar_backlog_eviction_proximity` in topic level.
### API Changes
_No response_
### Implementation
Because of there are 2 configurations for the backlog eviction, if topic
backlog reaches anyone of them will trigger the backlog eviction, so we need to
calculate both of them and select the max value:
```
long backlogQuotaLimitInBytes =
getBacklogQuota(BacklogQuotaType.destination_storage).getLimitSize();
int backlogQuotaLimitInSecond =
getBacklogQuota(BacklogQuotaType.message_age).getLimitTime();
long topicBacklogSize = getBacklogSize();
topicBacklogSize = topicBacklogSize < 0 ? 0 : topicBacklogSize;
long topicBacklogSeconds = getBacklogSeconds();
topicBacklogSeconds = topicBacklogSeconds < 0 ? 0 :
topicBacklogSeconds;
return Math.max(topicBacklogSize / backlogQuotaLimitInBytesD,
topicBacklogSeconds / backlogQuotaLimitInSecondD);
```
#### Metric
| Name | Type | Description | Labels |
| -- | -- | -- | -- |
| pulsar_backlog_eviction_proximity | Gauge | Proximity to trigger backlog
eviction. | cluster, tenant, namespace, topic, slowest_subscription |
### Alternatives
_No response_
### Anything else?
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]