This repository has been archived by the owner on Nov 14, 2020. It is now read-only.
Prevent non-zero publisher count in Grafana when aggregating metrics #61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the case where there are 0 channels (and as such 0 publishers), the
dashboard reports there are actually
n
publishers in ann
-nodecluster.
Proposed Changes
This changes the calculation of publishers to be number of
channels (which is always known) minus the number of consumers (which is
always known). This avoids the issue where there is ambiguity where a channel
which is publishing, but has not actively published yet.
Prior to this change, a cluster configured with

prometheus.return_per_object_metrics = false
will always report a non-zero number of publishers, even if there is no traffic on that cluster. For my example screenshots, I am using a three-node cluster with a random RabbitMQ pod being killed every minute, over the course of 5 minutes. You can see that there are always n publishers reported in Grafana for n nodes:After this change, this is correctly reported as 0:

I confirmed that the metric behaves as usual where there are non-zero publishers using PerfTest with 5 consumers & publishers:

Types of Changes
What types of changes does your code introduce to this project?
Put an
x
in the boxes that applyChecklist
Put an
x
in the boxes that apply. You can also fill these out after creatingthe PR. If you're unsure about any of them, don't hesitate to ask on the
mailing list. We're here to help! This is simply a reminder of what we are
going to look for before merging your code.
CONTRIBUTING.md
documentFurther Comments
Discovered this with @gerhard while we were working on rabbitmq/tgir#19