rabbitmq-server
                                
                                
                                
                                    rabbitmq-server copied to clipboard
                            
                            
                            
                        Move message rate metrics from aggregated to global counters
Proposed Changes
This PR moves the counters used in the RabbitMQ-Overview Grafana dashboard from using the inaccurate, aggregated metrics to the new global counters released in v3.9.
Currently marked as WIP as it is dependent on the changes in #5449 .
N.B.: in making this PR I also raised #5462 .
Types of Changes
What types of changes does your code introduce to this project?
Put an x in the boxes that apply
- [ ] Bug fix (non-breaking change which fixes issue #NNNN)
 - [ ] New feature (non-breaking change which adds functionality)
 - [ ] Breaking change (fix or feature that would cause an observable behavior change in existing systems)
 - [ ] Documentation improvements (corrections, new content, etc)
 - [x] Cosmetic change (whitespace, formatting, etc)
 - [ ] Build system and/or CI
 
Checklist
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.
- [ ] I have read the 
CONTRIBUTING.mddocument - [ ] I have signed the CA (see https://cla.pivotal.io/sign/rabbitmq)
 - [ ] I have added tests that prove my fix is effective or that my feature works
 - [ ] All tests pass locally with my changes
 - [ ] If relevant, I have added necessary documentation to https://github.com/rabbitmq/rabbitmq-website
 - [ ] If relevant, I have added this change to the first version(s) in release-notes that I expect to introduce it
 
Further Comments
I used the following migration of old metrics to new:
rabbitmq_channel_consumers                          -> rabbitmq_global_consumers
rabbitmq_channel_get_ack_total                      -> rabbitmq_global_messages_delivered_get_manual_ack_total
rabbitmq_channel_get_empty_total                    -> rabbitmq_global_messages_get_empty_total
rabbitmq_channel_get_total                          -> rabbitmq_global_messages_delivered_get_auto_ack_total
rabbitmq_channel_messages_acked_total               -> rabbitmq_global_messages_acknowledged_total
rabbitmq_channel_messages_confirmed_total           -> rabbitmq_global_messages_confirmed_total
rabbitmq_channel_messages_delivered_ack_total       -> rabbitmq_global_messages_delivered_consume_manual_ack_total
rabbitmq_channel_messages_delivered_total           -> rabbitmq_global_messages_delivered_consume_auto_ack_total
rabbitmq_channel_messages_published_total           -> rabbitmq_global_messages_received_total
rabbitmq_channel_messages_redelivered_total         -> rabbitmq_global_messages_redelivered_total
rabbitmq_channel_messages_unconfirmed**             -> rabbitmq_global_messages_received_confirm_total - rabbitmq_global_messages_confirmed_total
rabbitmq_channel_messages_unroutable_dropped_total  -> rabbitmq_global_messages_unroutable_dropped_total
rabbitmq_channel_messages_unroutable_returned_total -> rabbitmq_global_messages_unroutable_returned_total
rabbitmq_channels                                   -> UNCHANGED
rabbitmq_channels_closed_total                      -> UNCHANGED
rabbitmq_channels_opened_total                      -> UNCHANGED
rabbitmq_connections                                -> UNCHANGED
rabbitmq_connections_closed_total                   -> UNCHANGED
rabbitmq_connections_opened_total                   -> UNCHANGED
rabbitmq_queue_messages_published_total             -> rabbitmq_global_messages_routed_total
rabbitmq_queue_messages_ready                       -> UNCHANGED
rabbitmq_queue_messages_unacked                     -> UNCHANGED
rabbitmq_queues                                     -> UNCHANGED
rabbitmq_queues_created_total                       -> UNCHANGED
rabbitmq_queues_declared_total                      -> UNCHANGED
rabbitmq_queues_deleted_total                       -> UNCHANGED
Things to note
- The graphs "Publishers" and "Consumers" were affected by #5462, and so I could not change them.
 - The graphs "Connections", "Queues", "Channels" and "Queues", as well as the sections "Connections", "Queues" and "Channels" of the dashboard, all used metrics with no global equivalent, so I left them be.
 - **The graph "Messages unconfirmed to publishers" was, in my opinion, bugged, as it was previously attempting to take a rate of the gauge metric 
rabbitmq_channel_messages_unconfirmedrather than a counter. As part of this migration, I have reworked it to reflect the delta between the rate of messages expecting a confirm and rate of messages being confirmed - For the graphs "Ready messages", "Unacknowledged messages", "Messages ready to be delivered to consumers" and "Messages pending consumer acknowledgement", these are all representing current state rather than rate, however the global metrics backing this information are counters not gauges, meaning they're inappropriate for a current state assessment. I have therefore left them be.