Get Total number of queues, channels,connections,consumers running within a specific host

692 views
Skip to first unread message

Chavya Khanna

unread,
May 16, 2022, 3:12:04 PM5/16/22
to rabbitmq-users
Hello Everyone,

Was hoping if one of you could assist - so basically we have multiple vhosts on RMQ cluster and we have several queues under every vhost.

Is there a way we can get total number of :
  1. Queues
  2. Channels
  3. Connections
  4. Consumers
On the basis of filter vhost. Unfortunately vhost is not supported as a parameter of "rabbitmq_queues" and so on.

Was hoping if someone could assist on it.

Regards,

Chavya Khanna

Michal Kuratczyk

unread,
May 16, 2022, 5:07:24 PM5/16/22
to rabbitm...@googlegroups.com
Hi,

What are you referring to when you say "rabbitmq_queues"?

There are per-vhost endpoints such as /api/queues/vhost, /api/vhosts/vhost/connections, /api/vhosts/vhost/channels and /api/consumers/vhost

There is also a Prometheus endpoint from which you can get that list, although perhaps not directly. For example in the /metrics/per-object endpoint, you'll find:
rabbitmq_queue_consumers{vhost="/",queue="myqq"} 1

Since Prometheus metrics only have numerical values, the list of queues will be the list of "queue" label values for a given "vhost" label value.

Best,

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/300d54f4-0356-4872-b771-0abc004638afn%40googlegroups.com.


--
Michał

Chavya Khanna

unread,
May 16, 2022, 5:17:26 PM5/16/22
to rabbitmq-users
Thanks Michael,

So in Prometheus we do have  rabbitmq_queue_consumers{vhost="/",queue="myqq"} , However the metric listed below does not accept vhost as a parameter.

  1. rabbitmq_channel_consumers
  2. rabbitmq_queues
  3. rabbitmq_identity_info
  4. rabbitmq_channels
  5. rabbitmq_connections
As per my use case, i need Total queues, Total channels, etc that fall under a specific vhost.

Let me know if this clarified my ask?

Regards

Michal Kuratczyk

unread,
May 16, 2022, 5:35:51 PM5/16/22
to rabbitm...@googlegroups.com
As you noticed, these aggregated metrics are not split into per-vhost values (because they are aggregated :) ). Some metrics returned by /metrics/per-object, do return the vhost, so for example, you can count
the number of values returned by "rabbitmq_queue_messages_ready{vhost="/"}" to get a number of queues in vhost /. Similarly, you can count the number of values returned by "rabbitmq_channel_get_empty_total{vhost="/"}",
to get a number of channels in the / vhost.

The point is - the fact that the value you are looking for is not explicitly there, doesn't mean you can't calculate it - you can use the count() function, as in:
count(rabbitmq_queue_messages_ready{vhost="/"}")

But the Management API could be a simpler solution.



--
Michał
RabbitMQ team

Chavya Khanna

unread,
May 17, 2022, 10:59:39 AM5/17/22
to rabbitmq-users
thanks alot Michal,

Apologies to bother you but it seems the metrics to get Channels does not show accurate results when we compare with RMQ Console

  1. Total Channels
    count(rabbitmq_channel_get_total{vhost="$rabbitmq_vhost"} * on(instance) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster="$rabbitmq_cluster"})Output: 322 - Expected: 2046 
    tried using rabbitmq_channel_get_empty_total - still not accurate
  2. Could not find any way to get total connections, consumers, publishers ,  "queue declared, queue created, queue deleted" at Host level  - there's no metric anywhere close to it that is fetching this info - for consumers i could find one but it seems to reflect data at individual queue level and not just the vhost level - for vhost it just shows "N/A" when there are consumers 
  3. Would you happen to know where we can get parameter information for "label_values" which is usually used in Prometheus at the time of defining variables, just curious if we can filter queues in dropdown based on vhost
Thanks alot for your assistance on this matter, hope to hear from you on this.

Michal Kuratczyk

unread,
May 17, 2022, 1:47:41 PM5/17/22
to rabbitm...@googlegroups.com
You need to play around and see where the problem is. The metrics are collected here https://github.com/rabbitmq/rabbitmq-server/blob/master/deps/rabbitmq_prometheus/src/collectors/prometheus_rabbitmq_core_metrics_collector.erl but it's one of the most cryptic piece of code we have as it exposes metrics mostly designed pre-Prometheus into a Prometheus data model.

If you have specific requests to add a label to a given metric - please raise an issue/PR.





--
Michał
RabbitMQ team
Reply all
Reply to author
Forward
0 new messages