@@ -246,26 +246,26 @@ register() ->
246246deregister_cleanup (_ ) -> ok .
247247
248248collect_mf ('detailed' , Callback ) ->
249- collect (true , ? DETAILED_METRIC_NAME_PREFIX , vhosts_filter_from_pdict (), queues_filter_from_pdict (), enabled_mfs_from_pdict (? METRICS_RAW ), Callback ),
250- collect (true , ? CLUSTER_METRIC_NAME_PREFIX , vhosts_filter_from_pdict (), queues_filter_from_pdict (), enabled_mfs_from_pdict (? METRICS_CLUSTER ), Callback ),
249+ collect (true , ? DETAILED_METRIC_NAME_PREFIX , vhosts_filter_from_pdict (), enabled_mfs_from_pdict (? METRICS_RAW ), Callback ),
250+ collect (true , ? CLUSTER_METRIC_NAME_PREFIX , vhosts_filter_from_pdict (), enabled_mfs_from_pdict (? METRICS_CLUSTER ), Callback ),
251251 % % identity is here to enable filtering on a cluster name (as already happens in existing dashboards)
252252 emit_identity_info (Callback ),
253253 ok ;
254254collect_mf ('per-object' , Callback ) ->
255- collect (true , ? METRIC_NAME_PREFIX , false , queues_filter_from_pdict (), ? METRICS_RAW , Callback ),
255+ collect (true , ? METRIC_NAME_PREFIX , false , ? METRICS_RAW , Callback ),
256256 totals (Callback ),
257257 emit_identity_info (Callback ),
258258 ok ;
259259collect_mf (_Registry , Callback ) ->
260260 PerObjectMetrics = application :get_env (rabbitmq_prometheus , return_per_object_metrics , false ),
261- collect (PerObjectMetrics , ? METRIC_NAME_PREFIX , false , queues_filter_from_pdict (), ? METRICS_RAW , Callback ),
261+ collect (PerObjectMetrics , ? METRIC_NAME_PREFIX , false , ? METRICS_RAW , Callback ),
262262 totals (Callback ),
263263 emit_identity_info (Callback ),
264264 ok .
265265
266- collect (PerObjectMetrics , Prefix , VHostsFilter , QueuesFilter , IncludedMFs , Callback ) ->
266+ collect (PerObjectMetrics , Prefix , VHostsFilter , IncludedMFs , Callback ) ->
267267 _ = [begin
268- Data = get_data (Table , PerObjectMetrics , VHostsFilter , QueuesFilter ),
268+ Data = get_data (Table , PerObjectMetrics , VHostsFilter ),
269269 mf (Callback , Prefix , Contents , Data )
270270 end || {Table , Contents } <- IncludedMFs , not mutually_exclusive_mf (PerObjectMetrics , Table , IncludedMFs )],
271271 ok .
@@ -492,7 +492,7 @@ emit_gauge_metric_if_defined(Labels, Value) ->
492492 gauge_metric (Labels , Value )
493493 end .
494494
495- get_data (connection_metrics = Table , false , _ , _ ) ->
495+ get_data (connection_metrics = Table , false , _ ) ->
496496 {Table , A1 , A2 , A3 , A4 } = ets :foldl (fun ({_ , Props }, {T , A1 , A2 , A3 , A4 }) ->
497497 {T ,
498498 sum (proplists :get_value (recv_cnt , Props ), A1 ),
@@ -501,7 +501,7 @@ get_data(connection_metrics = Table, false, _, _) ->
501501 sum (proplists :get_value (channels , Props ), A4 )}
502502 end , empty (Table ), Table ),
503503 [{Table , [{recv_cnt , A1 }, {send_cnt , A2 }, {send_pend , A3 }, {channels , A4 }]}];
504- get_data (channel_metrics = Table , false , _ , _ ) ->
504+ get_data (channel_metrics = Table , false , _ ) ->
505505 {Table , A1 , A2 , A3 , A4 , A5 , A6 , A7 } =
506506 ets :foldl (fun ({_ , Props }, {T , A1 , A2 , A3 , A4 , A5 , A6 , A7 }) ->
507507 {T ,
@@ -516,40 +516,22 @@ get_data(channel_metrics = Table, false, _, _) ->
516516 [{Table , [{consumer_count , A1 }, {messages_unacknowledged , A2 }, {messages_unconfirmed , A3 },
517517 {messages_uncommitted , A4 }, {acks_uncommitted , A5 }, {prefetch_count , A6 },
518518 {global_prefetch_count , A7 }]}];
519- get_data (queue_consumer_count = MF , false , VHostsFilter , QueuesFilter ) ->
519+ get_data (queue_consumer_count = MF , false , VHostsFilter ) ->
520520 Table = queue_metrics , % % Real table name
521521 {_ , A1 } = ets :foldl (fun
522- ({# resource {kind = queue , virtual_host = VHost }, _ , _ }, Acc ) when is_map (VHostsFilter ), map_get (VHost , VHostsFilter ) == false ->
522+ ({# resource {kind = queue , virtual_host = VHost }, _ , _ }, Acc ) when is_map (VHostsFilter ), map_get (VHost , VHostsFilter ) == false ->
523523 Acc ;
524- ({# resource {kind = queue , name = Name }, Props , _ }, {T , A1 } = Acc )
525- when is_list (QueuesFilter ) ->
526- case re :run (Name , QueuesFilter , [{capture , none }]) of
527- match ->
528- Acc ;
529- nomatch ->
530- {T ,
531- sum (proplists :get_value (consumers , Props ), A1 )
532- }
533- end ;
534524 ({_ , Props , _ }, {T , A1 }) ->
535525 {T ,
536526 sum (proplists :get_value (consumers , Props ), A1 )
537527 }
538528 end , empty (MF ), Table ),
539529 [{Table , [{consumers , A1 }]}];
540- get_data (queue_metrics = Table , false , VHostsFilter , QueuesFilter ) ->
530+ get_data (queue_metrics = Table , false , VHostsFilter ) ->
541531 {Table , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 } =
542532 ets :foldl (fun
543533 ({# resource {kind = queue , virtual_host = VHost }, _ , _ }, Acc ) when is_map (VHostsFilter ), map_get (VHost , VHostsFilter ) == false ->
544534 Acc ;
545- ({# resource {kind = queue , name = Name }, Props , _ }, Acc )
546- when is_list (QueuesFilter ) ->
547- case re :run (Name , QueuesFilter , [{capture , none }]) of
548- match ->
549- Acc ;
550- nomatch ->
551- sum_queue_metrics (Props , Acc )
552- end ;
553535 ({_ , Props , _ }, Acc ) ->
554536 sum_queue_metrics (Props , Acc )
555537 end , empty (Table ), Table ),
@@ -560,7 +542,7 @@ get_data(queue_metrics = Table, false, VHostsFilter, QueuesFilter) ->
560542 {message_bytes_ready , A11 }, {message_bytes_unacknowledged , A12 },
561543 {messages_paged_out , A13 }, {message_bytes_paged_out , A14 },
562544 {disk_reads , A15 }, {disk_writes , A16 }, {segments , A17 }]}];
563- get_data (Table , false , VHostsFilter , QueuesFilter ) when Table == channel_exchange_metrics ;
545+ get_data (Table , false , VHostsFilter ) when Table == channel_exchange_metrics ;
564546 Table == queue_coarse_metrics ;
565547 Table == channel_queue_metrics ;
566548 Table == connection_coarse_metrics ;
@@ -571,14 +553,6 @@ get_data(Table, false, VHostsFilter, QueuesFilter) when Table == channel_exchang
571553 % % For queue_coarse_metrics
572554 ({# resource {kind = queue , virtual_host = VHost }, _ , _ , _ , _ }, Acc ) when is_map (VHostsFilter ), map_get (VHost , VHostsFilter ) == false ->
573555 Acc ;
574- ({# resource {kind = queue , name = Name }, V1 , V2 , V3 , V4 }, {T , A1 , A2 , A3 , A4 } = Acc )
575- when is_list (QueuesFilter ) ->
576- case re :run (Name , QueuesFilter , [{capture , none }]) of
577- match ->
578- Acc ;
579- nomatch ->
580- {T , V1 + A1 , V2 + A2 , V3 + A3 , V4 + A4 }
581- end ;
582556 ({_ , V1 }, {T , A1 }) ->
583557 {T , V1 + A1 };
584558 ({_ , V1 , _ }, {T , A1 }) ->
@@ -605,31 +579,31 @@ get_data(Table, false, VHostsFilter, QueuesFilter) when Table == channel_exchang
605579 _ ->
606580 [Result ]
607581 end ;
608- get_data (queue_coarse_metrics = Table , true , VHostsFilter , _ ) when is_map (VHostsFilter ) ->
582+ get_data (queue_coarse_metrics = Table , true , VHostsFilter ) when is_map (VHostsFilter ) ->
609583 ets :foldl (fun
610584 ({# resource {kind = queue , virtual_host = VHost }, _ , _ , _ , _ } = Row , Acc ) when map_get (VHost , VHostsFilter ) ->
611585 [Row |Acc ];
612586 (_ , Acc ) ->
613587 Acc
614588 end , [], Table );
615- get_data (MF , true , VHostsFilter , _ ) when is_map (VHostsFilter ), MF == queue_metrics orelse MF == queue_consumer_count ->
589+ get_data (MF , true , VHostsFilter ) when is_map (VHostsFilter ), MF == queue_metrics orelse MF == queue_consumer_count ->
616590 Table = queue_metrics ,
617591 ets :foldl (fun
618592 ({# resource {kind = queue , virtual_host = VHost }, _ , _ } = Row , Acc ) when map_get (VHost , VHostsFilter ) ->
619593 [Row |Acc ];
620594 (_ , Acc ) ->
621595 Acc
622596 end , [], Table );
623- get_data (queue_consumer_count , true , _ , _ ) ->
597+ get_data (queue_consumer_count , true , _ ) ->
624598 ets :tab2list (queue_metrics );
625- get_data (vhost_status , _ , _ , _ ) ->
599+ get_data (vhost_status , _ , _ ) ->
626600 [ { #{<<" vhost" >> => VHost },
627601 case rabbit_vhost_sup_sup :is_vhost_alive (VHost ) of
628602 true -> 1 ;
629603 false -> 0
630604 end }
631605 || VHost <- rabbit_vhost :list () ];
632- get_data (exchange_bindings , _ , _ , _ ) ->
606+ get_data (exchange_bindings , _ , _ ) ->
633607 Exchanges = lists :foldl (fun
634608 (# exchange {internal = true }, Acc ) ->
635609 Acc ;
@@ -653,7 +627,7 @@ get_data(exchange_bindings, _, _, _) ->
653627 [{<<" vhost=\" " , VHost /binary , " \" ,exchange=\" " , Name /binary , " \" ,type=\" " , Type /binary , " \" " >>,
654628 Bindings }|Acc ]
655629 end , [], WithCount );
656- get_data (exchange_names , _ , _ , _ ) ->
630+ get_data (exchange_names , _ , _ ) ->
657631 lists :foldl (fun
658632 (# exchange {internal = true }, Acc ) ->
659633 Acc ;
@@ -663,7 +637,7 @@ get_data(exchange_names, _, _, _) ->
663637 Label = <<" vhost=\" " , VHost /binary , " \" ,exchange=\" " , Name /binary , " \" ,type=\" " , (atom_to_binary (EType ))/binary , " \" " >>,
664638 [{Label , 1 }|Acc ]
665639 end , [], rabbit_exchange :list ());
666- get_data (Table , _ , _ , _ ) ->
640+ get_data (Table , _ , _ ) ->
667641 ets :tab2list (Table ).
668642
669643
@@ -737,10 +711,3 @@ vhosts_filter_from_pdict() ->
737711 maps :merge (All , Enabled )
738712 end .
739713
740- queues_filter_from_pdict () ->
741- case get (prometheus_queue_filter ) of
742- undefined ->
743- false ;
744- Pattern ->
745- Pattern
746- end .
0 commit comments