@@ -246,26 +246,26 @@ register() ->
246
246
deregister_cleanup (_ ) -> ok .
247
247
248
248
collect_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 ),
251
251
% % identity is here to enable filtering on a cluster name (as already happens in existing dashboards)
252
252
emit_identity_info (Callback ),
253
253
ok ;
254
254
collect_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 ),
256
256
totals (Callback ),
257
257
emit_identity_info (Callback ),
258
258
ok ;
259
259
collect_mf (_Registry , Callback ) ->
260
260
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 ),
262
262
totals (Callback ),
263
263
emit_identity_info (Callback ),
264
264
ok .
265
265
266
- collect (PerObjectMetrics , Prefix , VHostsFilter , QueuesFilter , IncludedMFs , Callback ) ->
266
+ collect (PerObjectMetrics , Prefix , VHostsFilter , IncludedMFs , Callback ) ->
267
267
_ = [begin
268
- Data = get_data (Table , PerObjectMetrics , VHostsFilter , QueuesFilter ),
268
+ Data = get_data (Table , PerObjectMetrics , VHostsFilter ),
269
269
mf (Callback , Prefix , Contents , Data )
270
270
end || {Table , Contents } <- IncludedMFs , not mutually_exclusive_mf (PerObjectMetrics , Table , IncludedMFs )],
271
271
ok .
@@ -492,7 +492,7 @@ emit_gauge_metric_if_defined(Labels, Value) ->
492
492
gauge_metric (Labels , Value )
493
493
end .
494
494
495
- get_data (connection_metrics = Table , false , _ , _ ) ->
495
+ get_data (connection_metrics = Table , false , _ ) ->
496
496
{Table , A1 , A2 , A3 , A4 } = ets :foldl (fun ({_ , Props }, {T , A1 , A2 , A3 , A4 }) ->
497
497
{T ,
498
498
sum (proplists :get_value (recv_cnt , Props ), A1 ),
@@ -501,7 +501,7 @@ get_data(connection_metrics = Table, false, _, _) ->
501
501
sum (proplists :get_value (channels , Props ), A4 )}
502
502
end , empty (Table ), Table ),
503
503
[{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 , _ ) ->
505
505
{Table , A1 , A2 , A3 , A4 , A5 , A6 , A7 } =
506
506
ets :foldl (fun ({_ , Props }, {T , A1 , A2 , A3 , A4 , A5 , A6 , A7 }) ->
507
507
{T ,
@@ -516,40 +516,22 @@ get_data(channel_metrics = Table, false, _, _) ->
516
516
[{Table , [{consumer_count , A1 }, {messages_unacknowledged , A2 }, {messages_unconfirmed , A3 },
517
517
{messages_uncommitted , A4 }, {acks_uncommitted , A5 }, {prefetch_count , A6 },
518
518
{global_prefetch_count , A7 }]}];
519
- get_data (queue_consumer_count = MF , false , VHostsFilter , QueuesFilter ) ->
519
+ get_data (queue_consumer_count = MF , false , VHostsFilter ) ->
520
520
Table = queue_metrics , % % Real table name
521
521
{_ , 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 ->
523
523
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 ;
534
524
({_ , Props , _ }, {T , A1 }) ->
535
525
{T ,
536
526
sum (proplists :get_value (consumers , Props ), A1 )
537
527
}
538
528
end , empty (MF ), Table ),
539
529
[{Table , [{consumers , A1 }]}];
540
- get_data (queue_metrics = Table , false , VHostsFilter , QueuesFilter ) ->
530
+ get_data (queue_metrics = Table , false , VHostsFilter ) ->
541
531
{Table , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 } =
542
532
ets :foldl (fun
543
533
({# resource {kind = queue , virtual_host = VHost }, _ , _ }, Acc ) when is_map (VHostsFilter ), map_get (VHost , VHostsFilter ) == false ->
544
534
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 ;
553
535
({_ , Props , _ }, Acc ) ->
554
536
sum_queue_metrics (Props , Acc )
555
537
end , empty (Table ), Table ),
@@ -560,7 +542,7 @@ get_data(queue_metrics = Table, false, VHostsFilter, QueuesFilter) ->
560
542
{message_bytes_ready , A11 }, {message_bytes_unacknowledged , A12 },
561
543
{messages_paged_out , A13 }, {message_bytes_paged_out , A14 },
562
544
{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 ;
564
546
Table == queue_coarse_metrics ;
565
547
Table == channel_queue_metrics ;
566
548
Table == connection_coarse_metrics ;
@@ -571,14 +553,6 @@ get_data(Table, false, VHostsFilter, QueuesFilter) when Table == channel_exchang
571
553
% % For queue_coarse_metrics
572
554
({# resource {kind = queue , virtual_host = VHost }, _ , _ , _ , _ }, Acc ) when is_map (VHostsFilter ), map_get (VHost , VHostsFilter ) == false ->
573
555
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 ;
582
556
({_ , V1 }, {T , A1 }) ->
583
557
{T , V1 + A1 };
584
558
({_ , V1 , _ }, {T , A1 }) ->
@@ -605,31 +579,31 @@ get_data(Table, false, VHostsFilter, QueuesFilter) when Table == channel_exchang
605
579
_ ->
606
580
[Result ]
607
581
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 ) ->
609
583
ets :foldl (fun
610
584
({# resource {kind = queue , virtual_host = VHost }, _ , _ , _ , _ } = Row , Acc ) when map_get (VHost , VHostsFilter ) ->
611
585
[Row |Acc ];
612
586
(_ , Acc ) ->
613
587
Acc
614
588
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 ->
616
590
Table = queue_metrics ,
617
591
ets :foldl (fun
618
592
({# resource {kind = queue , virtual_host = VHost }, _ , _ } = Row , Acc ) when map_get (VHost , VHostsFilter ) ->
619
593
[Row |Acc ];
620
594
(_ , Acc ) ->
621
595
Acc
622
596
end , [], Table );
623
- get_data (queue_consumer_count , true , _ , _ ) ->
597
+ get_data (queue_consumer_count , true , _ ) ->
624
598
ets :tab2list (queue_metrics );
625
- get_data (vhost_status , _ , _ , _ ) ->
599
+ get_data (vhost_status , _ , _ ) ->
626
600
[ { #{<<" vhost" >> => VHost },
627
601
case rabbit_vhost_sup_sup :is_vhost_alive (VHost ) of
628
602
true -> 1 ;
629
603
false -> 0
630
604
end }
631
605
|| VHost <- rabbit_vhost :list () ];
632
- get_data (exchange_bindings , _ , _ , _ ) ->
606
+ get_data (exchange_bindings , _ , _ ) ->
633
607
Exchanges = lists :foldl (fun
634
608
(# exchange {internal = true }, Acc ) ->
635
609
Acc ;
@@ -653,7 +627,7 @@ get_data(exchange_bindings, _, _, _) ->
653
627
[{<<" vhost=\" " , VHost /binary , " \" ,exchange=\" " , Name /binary , " \" ,type=\" " , Type /binary , " \" " >>,
654
628
Bindings }|Acc ]
655
629
end , [], WithCount );
656
- get_data (exchange_names , _ , _ , _ ) ->
630
+ get_data (exchange_names , _ , _ ) ->
657
631
lists :foldl (fun
658
632
(# exchange {internal = true }, Acc ) ->
659
633
Acc ;
@@ -663,7 +637,7 @@ get_data(exchange_names, _, _, _) ->
663
637
Label = <<" vhost=\" " , VHost /binary , " \" ,exchange=\" " , Name /binary , " \" ,type=\" " , (atom_to_binary (EType ))/binary , " \" " >>,
664
638
[{Label , 1 }|Acc ]
665
639
end , [], rabbit_exchange :list ());
666
- get_data (Table , _ , _ , _ ) ->
640
+ get_data (Table , _ , _ ) ->
667
641
ets :tab2list (Table ).
668
642
669
643
@@ -737,10 +711,3 @@ vhosts_filter_from_pdict() ->
737
711
maps :merge (All , Enabled )
738
712
end .
739
713
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