Quorum queues declared on 3.13 do not emit Raft metrics for Prometheus after upgrading to 4.2
Describe the bug
Hi, I've weirdly not seen this reported, and it not the same as #16974 , so here we go:
I have a potential patch available, however unsure I am of whether it's the correct one, PRs to follow in rabbitmq-server & ra.
A 3.13 quorum queue in a cluster upgraded to 4.2.5 then 4.3.4 or to 4.2.9 (the 2 I had at hand, I believe it's a 4.2/4.3-wide issue) will not emit raft metrics to Prometheus correctly (raft_commit_index is one of them, further list at the bottom).
In 3.13, it used to emit rabbitmq_raft_log_commit_index (unless I'm mistaken on the name), that metric is now gone, replaced by rabbitmq_raft_commit_index, which my 4.2 queue actually emits.
Reproduction steps
- Spin up a 3.13.7 3-node cluster from Docker (
rabbitmq:3.13.7-management) - Create a quorum queue qq-3.13.7
rabbitmqadmin declare queue queue_type=quorum name=qq-3.13.7 - Standard rolling upgrade 3.13.7 to 4.2.9 (into
rabbitmq:4.2.9-management),rabbitmqctl enable_feature_flag allat the end - Create a quorum queue qq-4.2.9
rabbitmqadmin declare queue queue_type=quorum name=qq-4.2.9 - curl -s http://localhost:15692/metrics/per-object | grep rabbitmq_raft_commit_index
# TYPE rabbitmq_raft_commit_index counter
# HELP rabbitmq_raft_commit_index The current commit index.
rabbitmq_raft_commit_index{queue="qq-4.2.9",vhost="/"} 4212.0Expected behavior
3.13 migrated queue emit rabbitmq_raft_commit_index (and related) in Prometheus.
Additional context
After a remove_member -> add_member on my 3rd node, the metric started appearing
# TYPE rabbitmq_raft_commit_index counter
# HELP rabbitmq_raft_commit_index The current commit index.
rabbitmq_raft_commit_index{queue="qq-3.13.7",vhost="/"} 4221.0
rabbitmq_raft_commit_index{queue="qq-4.2.9",vhost="/"} 4212.0Claude pinpointed the absence of metrics_labels, and I've traced it all the way:
In 3.13, there was no metrics_labels in the ra config, and, in ra_server_sup_sup, the list of mutables in MUTABLE_CONFIG_KEYS do not include metrics_labels, so it can't enter the configuration correctly.
Sure enough:
- The metric flows from
ra_server_proc:do_init/1,MetricLabels = maps:get(metrics_labels, Config0, #{}), so an empty map here. ra_server_proc:config_defaults/2ra_counters:new/3<- this one sets theraatom as the keyseshat:new/4seshat:new_counter/4seshat:register_counter/5, that does anets:insert/2with that empty label forra,
Then prometheus_rabbitmq_raft_metrics_collector:collect_per_object_metrics/2 calls seshat:format/2, which reads the ra key in the ets table, sees the empty label, hits map_size(LabelsAsMap) > 0 = false into %% skip filtered-out and unlabeled entries
So, the code is working as intended.
I have focused on commit_index, the list of metrics is (hopefully exhaustive):
rabbitmq_raft_commit_index
rabbitmq_raft_num_segments
rabbitmq_raft_last_written_index
rabbitmq_raft_term
rabbitmq_raft_commit_latency_seconds
rabbitmq_raft_last_applied
rabbitmq_raft_snapshot_index
rabbitmq_detailed_raft_aer_received_follower_empty
rabbitmq_detailed_raft_aer_received_follower
rabbitmq_detailed_raft_aer_replies_fail
rabbitmq_detailed_raft_aer_replies_success
rabbitmq_detailed_raft_aux_commands
rabbitmq_detailed_raft_checkpoint_bytes_written
rabbitmq_detailed_raft_checkpoint_index
rabbitmq_detailed_raft_checkpoints_promoted
rabbitmq_detailed_raft_checkpoints_written
rabbitmq_detailed_raft_checkpoints
rabbitmq_detailed_raft_command_flushes
rabbitmq_detailed_raft_commands
rabbitmq_detailed_raft_commit_index
rabbitmq_detailed_raft_commit_latency_seconds
rabbitmq_detailed_raft_consistent_queries
rabbitmq_detailed_raft_dropped_sends
rabbitmq_detailed_raft_effective_machine_version
rabbitmq_detailed_raft_elections
rabbitmq_detailed_raft_fetch_term
rabbitmq_detailed_raft_forced_gcs
rabbitmq_detailed_raft_invalid_reply_mode_commands
rabbitmq_detailed_raft_last_applied
rabbitmq_detailed_raft_last_index
rabbitmq_detailed_raft_last_written_index
rabbitmq_detailed_raft_local_queries
rabbitmq_detailed_raft_msgs_sent
rabbitmq_detailed_raft_num_segments
rabbitmq_detailed_raft_open_segments
rabbitmq_detailed_raft_pre_vote_elections
rabbitmq_detailed_raft_read_cache
rabbitmq_detailed_raft_read_closed_mem_tbl
rabbitmq_detailed_raft_read_mem_table
rabbitmq_detailed_raft_read_ops
rabbitmq_detailed_raft_read_segment
rabbitmq_detailed_raft_release_cursors
rabbitmq_detailed_raft_reserved_1
rabbitmq_detailed_raft_reserved_2
rabbitmq_detailed_raft_rpcs_sent
rabbitmq_detailed_raft_send_msg_effects_sent
rabbitmq_detailed_raft_snapshot_bytes_written
rabbitmq_detailed_raft_snapshot_index
rabbitmq_detailed_raft_snapshot_installed
rabbitmq_detailed_raft_snapshots_sent
rabbitmq_detailed_raft_snapshots_written
rabbitmq_detailed_raft_term_and_voted_for_updates
rabbitmq_detailed_raft_term
rabbitmq_detailed_raft_write_ops
rabbitmq_detailed_raft_write_resends
Source: rabbitmq/rabbitmq-server