Detailed metrics for a queue are only reported from the node hosting the leader replica of that queue #12022
-
Describe the bugWe are running RabbitMQ cluster in Kubernetes, deployed using RabbitMQ Kubernetes Operator. We are working on a project that suppose to scrape the prometheus metrics from the cluster. I've noticed that a lot of my requests for detailed metrics info curl -sS 'http://:15692/metrics/detailed?family=queue_coarse_metrics&family=queue_metrics' do not include some of the queues in their metrics. After an investigation and querying each RabbitMQ pod individually, I've realized that only the pod that is the leader for the queue, reports metrics about the queue. Since the scraping applications will be pointing at the service, that is load-balancing the requests between the 3 nodes, this means that 66% of the time metrics do not include information for a particular queue. I don't know if this is a configuration issue of some kind, but it seems like a bug to me. The application consuming the metrics from a cluster should not be aware of which node of the cluster to query for which queue. Perhaps I'm missing something. Any help would be appreciated. Thank you. Reproduction steps
Expected behaviorI would expect to get the metrics about a queue regardless on which node of the cluster the request for metrics lands. Additional contextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
@kvasserman "repeatedly query the K8S service" is not a reproduction step. We will not guess how exactly you "query the service". We do not guess in this community. In fact, you haven't even provided the RabbitMQ version used or any details on how the queue was declared. If you use Prometheus to gather metrics, then every node will return its own local metrics only, by design. They are supposed to be aggregated, and since every queue and stream have a leader, by aggregating data from all nodes you will have a complete data set. This is different from the RabbitMQ HTTP API where a request to any node will be routed to the node hosting the queue leader, and cached on the node handling the HTTP API request. This approach can work work but not how the Prometheus plugin works, again, by design. |
Beta Was this translation helpful? Give feedback.
-
Given a cluster of three nodes started with bazel run start-cluster NODES=3 RABBITMQ_ENABLED_PLUGINS=rabbitmq_management,rabbitmq_prometheus and three quorum queues Publish one message in a way that it will be routed to Then query the Prometheus per-object metrics endpoint on every node. Node 1, port 15692
Node 2, port 15693
Node 3, Port 15694Node 3's results are omitted for brevity but it consistently reports more metrics for ObservationsThese results are expected from the Prometheus plugin. If the same experiment is repeated with Aggregating the above metrics the way our Grafana dashboard does it will provide a complete set In addition, the Prometheus plugin never has to cache any data from other nodes, reducing |
Beta Was this translation helpful? Give feedback.
-
This is a configuration issue on your side. There is no bug. Prometheus metrics must be scraped from each pod.
From https://observability.thomasriley.co.uk/prometheus/configuring-prometheus/using-service-monitors/ :
|
Beta Was this translation helpful? Give feedback.
-
Note that in #12022 (comment) each node emits Raft metrics (because each node has a Raft member), but queue metrics are only reported by the leader (even though each node also has a queue member). This makes sense because a queue is a single entity conceptually whether it is replicated or not but as soon as you look at Raft metrics, where different members are at becomes more important, e.g. detecting replication lag etc. |
Beta Was this translation helpful? Give feedback.
-
Thank you, everyone for valuable information. I was able to adjust my scraping code to get and aggregate the metrics from each RabbitMQ server pod and everything works fine now. For general metrics our company doesn't use Prometheus, we use DataDog. DataDog scraper only seem to allow for one endpoint setting to get RabbitMQ prometheus metrics. This was part of the confusion, I figured they scrape everything from the RabbitMQ service (which load-balances the requests between the nodes). I wonder if DataDog folks realize that they are missing per queue metrics 2 out of 3 requests. But perhaps they do something behind the scenes to discover and scrape metrics per pod. It's unclear to me. Anyway, thank you. |
Beta Was this translation helpful? Give feedback.
This is a configuration issue on your side. There is no bug. Prometheus metrics must be scraped from each pod.
See https://www.rabbitmq.com/blog/2021/05/03/alerting: