rabbitmq / rabbitmq-prometheus

A minimalistic Prometheus exporter of core RabbitMQ metrics
Other
145 stars 109 forks source link

No exchange stats (published in/published out) #60

Closed danielllek closed 3 years ago

danielllek commented 3 years ago

rabbitmq-prometheus plugin currently doesn't return exchange stats (published in/published out).

Is it possible to add this feature?

michaelklishin commented 3 years ago

You haven't provided any evidence. This plugin aggregates object stats by default so individual exchange metrics won't be available. Why this is the case and what are the downsides of disabling aggregation are documented in the Prometheus guide.

michaelklishin commented 3 years ago

…in Aggregated and Per-Object Metrics.

danielllek commented 3 years ago

I was hoping for metrics that are graphed on UI under URL/#/exchanges/VHOST/EXCHANGE

image

For example rabbitmq telegraf plugin returns these stats.

michaelklishin commented 3 years ago

Exchange metrics are computed from channel metrics, exchanges do not emit stats.

rabbitmq_channel_messages_published_total - rabbitmq_channel_messages_unroutable_returned_total - rabbitmq_channel_messages_unroutable_dropped_total

gerhard commented 3 years ago

To calculate Publish (In) for exchange direct I would use the following

sum(rate(rabbitmq_channel_messages_published_total{exchange="direct"}[60s]))

To calculate Publish (Out) for the same exchange I would use:

sum(rate(rabbitmq_channel_messages_published_total{exchange="direct"}[60s])) -
sum(rate(rabbitmq_channel_messages_unroutable_returned_total{exchange="direct"}[60s])) -
sum(rate(rabbitmq_channel_messages_unroutable_dropped_total{exchange="direct"}[60s]))

Per object metrics will need to be enabled, otherwise there will be no exchange label.

Filtering by cluster name will be necessary to distinguish metrics between multiple RabbitMQ deployments.

FWIW, all available channel metrics related to exchanges: https://github.com/rabbitmq/rabbitmq-prometheus/blob/d4aeb428e9d3c869e5640137f0540e2f35344a32/src/collectors/prometheus_rabbitmq_core_metrics_collector.erl#L65-L70

danielllek commented 3 years ago

Thx, I'll try that :+1:

danielllek commented 3 years ago

Thanks for clarification (it wasn't clear for me that exchange stats come from channel stats).

@gerhard suggestion works perfectly :+1: