Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 789c704

Browse files
Merge pull request #57 from dcorbacho/queue-labels
Add policy and overflow, mode and type arguments as labels on queues
2 parents ea5b355 + 0cc4dcb commit 789c704

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

Diff for: src/collectors/prometheus_rabbitmq_queues_collector.erl

+29-2
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,26 @@ metric(boolean, Labels, Value0) ->
122122
%%====================================================================
123123

124124
labels(Queue) ->
125-
[{vhost, queue_vhost(Queue)},
126-
{queue, queue_name(Queue)}].
125+
%% exclusive_consumer_tag should not be used as a label. Prometheus documentation
126+
%% states that labels should not be used to store dimensions with high cardinality,
127+
%% as every unique combination of key-value label pairs represents a new time
128+
%% series, which can dramatically increase the amount of data stored.
129+
%% As such, from the arguments only x-overflow, x-queue-mode and x-queue-type
130+
%% should be represented as arguments.
131+
add_if_not_empty(
132+
{queue_mode, queue_argument(<<"x-queue-mode">>, Queue)},
133+
add_if_not_empty(
134+
{type, queue_argument(<<"x-queue-type">>, Queue, <<"classic">>)},
135+
add_if_not_empty(
136+
{overflow, queue_argument(<<"x-overflow">>, Queue)},
137+
add_if_not_empty({policy, queue_policy(Queue)},
138+
[{vhost, queue_vhost(Queue)},
139+
{queue, queue_name(Queue)}])))).
140+
141+
add_if_not_empty({_, ''}, Acc) ->
142+
Acc;
143+
add_if_not_empty(Tuple, Acc) ->
144+
[Tuple | Acc].
127145

128146
catch_boolean(boolean) ->
129147
untyped;
@@ -158,6 +176,15 @@ queue_vhost(Queue) ->
158176
queue_name(Queue) ->
159177
proplists:get_value(name, Queue).
160178

179+
queue_policy(Queue) ->
180+
proplists:get_value(policy, Queue).
181+
182+
queue_argument(Arg, Queue) ->
183+
queue_argument(Arg, Queue, '').
184+
185+
queue_argument(Arg, Queue, Default) ->
186+
maps:get(Arg, proplists:get_value(arguments, Queue), Default).
187+
161188
queue_dir_size(Queue) ->
162189
QueueDirName = queue_dir_name(Queue),
163190
FullPath = [mnesia:system_info(directory), "/queues/", QueueDirName],

0 commit comments

Comments
 (0)