-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Add global histogram metrics for received message sizes per-protocol #12087
base: main
Are you sure you want to change the base?
Conversation
|
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.
To expose a histogram, I'm in favour of using a Prometheus histogram data type instead of counter data type.
This PR uses counter
~/workspace/rabbitmq-server$ curl -s localhost:15692/metrics | grep rabbitmq_global_message_size
# TYPE rabbitmq_global_message_size_16KiB counter
# HELP rabbitmq_global_message_size_16KiB Total number of messages received from publishers with a size =< 16KiB
rabbitmq_global_message_size_16KiB{protocol="amqp091"} 0
rabbitmq_global_message_size_16KiB{protocol="amqp10"} 0
rabbitmq_global_message_size_16KiB{protocol="mqtt310"} 0
rabbitmq_global_message_size_16KiB{protocol="mqtt311"} 0
rabbitmq_global_message_size_16KiB{protocol="mqtt50"} 0
rabbitmq_global_message_size_16KiB{protocol="stream"} 0
# TYPE rabbitmq_global_message_size_1MiB counter
# HELP rabbitmq_global_message_size_1MiB Total number of messages received from publishers with a size =< 1MiB
rabbitmq_global_message_size_1MiB{protocol="amqp091"} 0
rabbitmq_global_message_size_1MiB{protocol="amqp10"} 0
rabbitmq_global_message_size_1MiB{protocol="mqtt310"} 0
rabbitmq_global_message_size_1MiB{protocol="mqtt311"} 0
rabbitmq_global_message_size_1MiB{protocol="mqtt50"} 0
rabbitmq_global_message_size_1MiB{protocol="stream"} 0
# TYPE rabbitmq_global_message_size_512MiB counter
# HELP rabbitmq_global_message_size_512MiB Total number of messages received from publishers with a size =< 512MiB
rabbitmq_global_message_size_512MiB{protocol="amqp091"} 0
rabbitmq_global_message_size_512MiB{protocol="amqp10"} 0
rabbitmq_global_message_size_512MiB{protocol="mqtt310"} 0
rabbitmq_global_message_size_512MiB{protocol="mqtt311"} 0
rabbitmq_global_message_size_512MiB{protocol="mqtt50"} 0
rabbitmq_global_message_size_512MiB{protocol="stream"} 0
# TYPE rabbitmq_global_message_size_64B counter
# HELP rabbitmq_global_message_size_64B Total number of messages received from publishers with a size =< 64B
rabbitmq_global_message_size_64B{protocol="amqp091"} 0
rabbitmq_global_message_size_64B{protocol="amqp10"} 0
rabbitmq_global_message_size_64B{protocol="mqtt310"} 0
rabbitmq_global_message_size_64B{protocol="mqtt311"} 0
rabbitmq_global_message_size_64B{protocol="mqtt50"} 0
rabbitmq_global_message_size_64B{protocol="stream"} 0
# TYPE rabbitmq_global_message_size_16MiB counter
# HELP rabbitmq_global_message_size_16MiB Total number of messages received from publishers with a size =< 16MiB
rabbitmq_global_message_size_16MiB{protocol="amqp091"} 0
rabbitmq_global_message_size_16MiB{protocol="amqp10"} 0
rabbitmq_global_message_size_16MiB{protocol="mqtt310"} 0
rabbitmq_global_message_size_16MiB{protocol="mqtt311"} 0
rabbitmq_global_message_size_16MiB{protocol="mqtt50"} 0
rabbitmq_global_message_size_16MiB{protocol="stream"} 0
# TYPE rabbitmq_global_message_size_256MiB counter
# HELP rabbitmq_global_message_size_256MiB Total number of messages received from publishers with a size =< 256MiB
rabbitmq_global_message_size_256MiB{protocol="amqp091"} 0
rabbitmq_global_message_size_256MiB{protocol="amqp10"} 0
rabbitmq_global_message_size_256MiB{protocol="mqtt310"} 0
rabbitmq_global_message_size_256MiB{protocol="mqtt311"} 0
rabbitmq_global_message_size_256MiB{protocol="mqtt50"} 0
rabbitmq_global_message_size_256MiB{protocol="stream"} 0
# TYPE rabbitmq_global_message_size_4MiB counter
# HELP rabbitmq_global_message_size_4MiB Total number of messages received from publishers with a size =< 4MiB
rabbitmq_global_message_size_4MiB{protocol="amqp091"} 0
rabbitmq_global_message_size_4MiB{protocol="amqp10"} 0
rabbitmq_global_message_size_4MiB{protocol="mqtt310"} 0
rabbitmq_global_message_size_4MiB{protocol="mqtt311"} 0
rabbitmq_global_message_size_4MiB{protocol="mqtt50"} 0
rabbitmq_global_message_size_4MiB{protocol="stream"} 0
# TYPE rabbitmq_global_message_size_1KiB counter
# HELP rabbitmq_global_message_size_1KiB Total number of messages received from publishers with a size =< 1KiB
rabbitmq_global_message_size_1KiB{protocol="amqp091"} 0
rabbitmq_global_message_size_1KiB{protocol="amqp10"} 0
rabbitmq_global_message_size_1KiB{protocol="mqtt310"} 0
rabbitmq_global_message_size_1KiB{protocol="mqtt311"} 0
rabbitmq_global_message_size_1KiB{protocol="mqtt50"} 0
rabbitmq_global_message_size_1KiB{protocol="stream"} 0
# TYPE rabbitmq_global_message_size_4KiB counter
# HELP rabbitmq_global_message_size_4KiB Total number of messages received from publishers with a size =< 4KiB
rabbitmq_global_message_size_4KiB{protocol="amqp091"} 0
rabbitmq_global_message_size_4KiB{protocol="amqp10"} 0
rabbitmq_global_message_size_4KiB{protocol="mqtt310"} 0
rabbitmq_global_message_size_4KiB{protocol="mqtt311"} 0
rabbitmq_global_message_size_4KiB{protocol="mqtt50"} 0
rabbitmq_global_message_size_4KiB{protocol="stream"} 0
# TYPE rabbitmq_global_message_size_64MiB counter
# HELP rabbitmq_global_message_size_64MiB Total number of messages received from publishers with a size =< 64MiB
rabbitmq_global_message_size_64MiB{protocol="amqp091"} 0
rabbitmq_global_message_size_64MiB{protocol="amqp10"} 0
rabbitmq_global_message_size_64MiB{protocol="mqtt310"} 0
rabbitmq_global_message_size_64MiB{protocol="mqtt311"} 0
rabbitmq_global_message_size_64MiB{protocol="mqtt50"} 0
rabbitmq_global_message_size_64MiB{protocol="stream"} 0
# TYPE rabbitmq_global_message_size_256KiB counter
# HELP rabbitmq_global_message_size_256KiB Total number of messages received from publishers with a size =< 256KiB
rabbitmq_global_message_size_256KiB{protocol="amqp091"} 0
rabbitmq_global_message_size_256KiB{protocol="amqp10"} 0
rabbitmq_global_message_size_256KiB{protocol="mqtt310"} 0
rabbitmq_global_message_size_256KiB{protocol="mqtt311"} 0
rabbitmq_global_message_size_256KiB{protocol="mqtt50"} 0
rabbitmq_global_message_size_256KiB{protocol="stream"} 0
# TYPE rabbitmq_global_message_size_256B counter
# HELP rabbitmq_global_message_size_256B Total number of messages received from publishers with a size =< 256B
rabbitmq_global_message_size_256B{protocol="amqp091"} 0
rabbitmq_global_message_size_256B{protocol="amqp10"} 0
rabbitmq_global_message_size_256B{protocol="mqtt310"} 0
rabbitmq_global_message_size_256B{protocol="mqtt311"} 0
rabbitmq_global_message_size_256B{protocol="mqtt50"} 0
rabbitmq_global_message_size_256B{protocol="stream"} 0
# TYPE rabbitmq_global_message_size_64KiB counter
# HELP rabbitmq_global_message_size_64KiB Total number of messages received from publishers with a size =< 64KiB
rabbitmq_global_message_size_64KiB{protocol="amqp091"} 0
rabbitmq_global_message_size_64KiB{protocol="amqp10"} 0
rabbitmq_global_message_size_64KiB{protocol="mqtt310"} 0
rabbitmq_global_message_size_64KiB{protocol="mqtt311"} 0
rabbitmq_global_message_size_64KiB{protocol="mqtt50"} 0
rabbitmq_global_message_size_64KiB{protocol="stream"} 0
I'd prefer a histogram something along these lines
# TYPE rabbitmq_global_message_size_bytes histogram
HELP rabbitmq_global_message_size_bytes Message Size
rabbitmq_global_message_size_bytes_bucket{protocol="amqp091",le="64"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp091",le="256"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp091",le="1024"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp091",le="4096"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp091",le="16384"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp091",le="65536"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp091",le="262144"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp091",le="1048576"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp091",le="4194304"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp091",le="1048576"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp091",le="16777216"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp091",le="25165824"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp091",le="268435456"} 0
rabbitmq_global_message_size_bytes_count{protocol="amqp091"} 0
rabbitmq_global_message_size_bytes_sum{protocol="amqp091"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp10",le="64"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp10",le="256"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp10",le="1024"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp10",le="4096"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp10",le="16384"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp10",le="65536"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp10",le="262144"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp10",le="1048576"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp10",le="4194304"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp10",le="1048576"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp10",le="16777216"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp10",le="25165824"} 0
rabbitmq_global_message_size_bytes_bucket{protocol="amqp10",le="268435456"} 0
rabbitmq_global_message_size_bytes_count{protocol="amqp10"} 0
rabbitmq_global_message_size_bytes_sum{protocol="amqp10"} 0
This PR also doesn't name metrics correctly because it uses names such as rabbitmq_global_message_size_64MiB
.
According to https://prometheus.io/docs/practices/naming/#metric-names:
A metric name should use base units (e.g. seconds, bytes, meters - not milliseconds, megabytes, kilometers).
As a bonus, it might be worth even trying out experimental native Prometheus histograms because we want exactly these properties:
Anyway, for now we can start with the current |
Thank you @ansd for the valuable feedback, I din't know about the histogram prometheus type |
reading up on native histograms I found:
I guess the fact that native histograms can only be exposed via protobuf is a blocker for now. But interesting topic for the future. |
2c57cc8
to
f57efe2
Compare
Updated to expose prometheus classic histograms. (I realize the bellow example could go into a unit test, will add on Monday)
|
`rabbit_msg_size_metrics` does not use `seshat` any more, but `counters` directly.
f57efe2
to
f4034f3
Compare
rebased to latest |
Thank you @gomoripeti. |
Proposed Changes
Keep track of message size distribution received via AMQP 0.9.1, AMQP 1.0 and MQTT protocols. This is useful information to set an appropriate
max_message_size
config or otherwise tune RabbitMQ or the clients.This metric is bumped right after message size check happens.
A separate module is added to hold the set of seshat counters of the histogram buckets, in order to groupd them better together as opposed to just adding the additional counters in the per-protocol global counters list.
Partially implements #11637
TODO: document new prometheus metrics
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 creating the 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
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution
you did and what alternatives you considered, etc.