-
Notifications
You must be signed in to change notification settings - Fork 143
Feat[MQBSTAT]: Add queue utilization metrics #678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feat[MQBSTAT]: Add queue utilization metrics #678
Conversation
Signed-off-by: Aleksandr Ivanov <[email protected]>
src/plugins/bmqprometheus/bmqprometheus_prometheusstatconsumer.cpp
Outdated
Show resolved
Hide resolved
double avg = 0; | ||
if (latestSnapshot > oldestSnapshot) { | ||
avg = bmqst::StatUtil::average( | ||
context.value(bmqst::StatContext::e_DIRECT_VALUE, currentValue), | ||
latestSnapshot, | ||
oldestSnapshot); | ||
} | ||
else { | ||
avg = static_cast<double>(bmqst::StatUtil::value( | ||
context.value(bmqst::StatContext::e_DIRECT_VALUE, currentValue), | ||
latestSnapshot)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the exact semantic of the calculated value? Is it "current utilization", "max utilization", etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I consider that utilization is calculated as average value of current messages/bytes within publish period divided by limit value. Snapshot interval is usually 1 sec, publish interval is usually 10 sec. So, the average value of messages/bytes for the last 10 snapshots is calculated. Added comments into the code describing this logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep the semantics aligned with the existing history metrics, which are either current or max. Given the choice between the two, I think max is the more useful option. Domains already provide the ability to alarm (internally in the broker) if capacity crosses a threshold (e.g. 80% full), so exposing that max would be the the closest stat to the stat triggering that alarm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, refactored to use max value for calculation of queue utilization.
Signed-off-by: Aleksandr Ivanov <[email protected]>
Signed-off-by: Aleksandr Ivanov <[email protected]>
@@ -110,8 +110,10 @@ class QueueStatsDomain { | |||
e_NB_CONSUMER, | |||
e_MESSAGES_CURRENT, | |||
e_MESSAGES_MAX, | |||
e_MESSAGES_UTILIZATION, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about ending with "_MAX" to make it clear it's peak utilization? Otherwise, lgtm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, added suffix _MAX
to the new metrics.
Add two new queue metrics representing queue utilization (in precents):
queue.content_msgs / queue.cfg_msgs * 100%
;queue.content_bytes/ queue.cfg_bytes * 100%
;