Skip to content

Commit d736254

Browse files
Merge pull request #12216 from rabbitmq/mergify/bp/v4.0.x/pr-12148
2 parents 268804c + 983ac8c commit d736254

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

deps/rabbitmq_prometheus/src/collectors/prometheus_rabbitmq_core_metrics_collector.erl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,19 @@ get_data(Table, false, VHostsFilter) when Table == channel_exchange_metrics;
640640
_ ->
641641
[Result]
642642
end;
643+
get_data(ra_metrics = Table, true, _) ->
644+
ets:foldl(
645+
fun ({#resource{kind = queue}, _, _, _, _, _, _} = Row, Acc) ->
646+
%% Metrics for QQ records use the queue resource as the table
647+
%% key. The queue name and vhost will be rendered as tags.
648+
[Row | Acc];
649+
({ClusterName, _, _, _, _, _, _} = Row, Acc) when is_atom(ClusterName) ->
650+
%% Other Ra clusters like Khepri and the stream coordinator use
651+
%% the cluster name as the metrics key. Transform this into a
652+
%% value that can be rendered as a "raft_cluster" tag.
653+
Row1 = setelement(1, Row, #{<<"raft_cluster">> => atom_to_binary(ClusterName, utf8)}),
654+
[Row1 | Acc]
655+
end, [], Table);
643656
get_data(exchange_metrics = Table, true, VHostsFilter) when is_map(VHostsFilter)->
644657
ets:foldl(fun
645658
({#resource{kind = exchange, virtual_host = VHost}, _, _, _, _, _} = Row, Acc) when

0 commit comments

Comments
 (0)