diff options
author | Alexey Lebedeff <binarin@binarin.info> | 2021-11-24 16:49:43 +0100 |
---|---|---|
committer | Alexey Lebedeff <binarin@binarin.info> | 2021-11-24 16:49:43 +0100 |
commit | 7676ed96857772ad812b4fc4fc9acd0df9df71d8 (patch) | |
tree | 75c281942ccc295b3a0e9398359c3d1670dcd80f | |
parent | 38d64a54b1d4cee7d22cd2512155370993cc58ce (diff) | |
download | rabbitmq-server-git-vhost-exchange-count.tar.gz |
Use `rabbitmq_cluster_` prefix for cluster-wide metricsvhost-exchange-count
3 files changed, 20 insertions, 18 deletions
diff --git a/deps/rabbitmq_prometheus/metrics-detailed.md b/deps/rabbitmq_prometheus/metrics-detailed.md index 5762976cf7..bec732f8db 100644 --- a/deps/rabbitmq_prometheus/metrics-detailed.md +++ b/deps/rabbitmq_prometheus/metrics-detailed.md @@ -246,21 +246,21 @@ These metrics **must not** be aggregated across cluster nodes. Group `vhost_status`: -| Metric | Description | -|--------------------------------|----------------------------------| -| rabbitmq_detailed_vhost_status | Whether a given vhost is running | +| Metric | Description | +|-------------------------------|----------------------------------| +| rabbitmq_cluster_vhost_status | Whether a given vhost is running | Group `exchange_names`: -| Metric | Description | -|---------------------------------|----------------------------------------------------------------------------------------------------------| -| rabbitmq_detailed_exchange_name | Enumerates exchanges without any additional info. This value is cluster-wide. A cheaper alternative to `exchange_bindings` | +| Metric | Description | +|--------------------------------|----------------------------------------------------------------------------------------------------------------------------| +| rabbitmq_cluster_exchange_name | Enumerates exchanges without any additional info. This value is cluster-wide. A cheaper alternative to `exchange_bindings` | Group `exchange_bindings`: -| Metric | Description | -|-------------------------------------|------------------------------------------------------------------------| -| rabbitmq_detailed_exchange_bindings | Number of bindings for an exchange. This value is cluster-wide. | +| Metric | Description | +|------------------------------------|-----------------------------------------------------------------| +| rabbitmq_cluster_exchange_bindings | Number of bindings for an exchange. This value is cluster-wide. | diff --git a/deps/rabbitmq_prometheus/src/collectors/prometheus_rabbitmq_core_metrics_collector.erl b/deps/rabbitmq_prometheus/src/collectors/prometheus_rabbitmq_core_metrics_collector.erl index 1d77a7b2da..7c31b71b92 100644 --- a/deps/rabbitmq_prometheus/src/collectors/prometheus_rabbitmq_core_metrics_collector.erl +++ b/deps/rabbitmq_prometheus/src/collectors/prometheus_rabbitmq_core_metrics_collector.erl @@ -29,6 +29,7 @@ %% Used by `/metrics/detailed` endpoint -define(DETAILED_METRIC_NAME_PREFIX, <<"rabbitmq_detailed_">>). +-define(CLUSTER_METRIC_NAME_PREFIX, <<"rabbitmq_cluster_">>). %% ==The source of these metrics can be found in the rabbit_core_metrics module== %% The relevant files are: @@ -215,15 +216,15 @@ ]). %% Metrics that can be only requested through `/metrics/detailed` --define(METRICS_RAW_DETAILED,[ +-define(METRICS_CLUSTER,[ {vhost_status, [ {2, undefined, vhost_status, gauge, "Whether a given vhost is running"} ]}, {exchange_bindings, [ - {2, undefined, exchange_bindings, gauge, "Number of bindings for an exchange (WARNING: it's cluster-wide number)"} + {2, undefined, exchange_bindings, gauge, "Number of bindings for an exchange. This value is cluster-wide."} ]}, {exchange_names, [ - {2, undefined, exchange_name, gauge, "Enumerates exchanges without any additional info (cheaper than `exchange_bindings`, cluster-wide number)"} + {2, undefined, exchange_name, gauge, "Enumerates exchanges without any additional info. This value is cluster-wide. A cheaper alternative to `exchange_bindings`"} ]} ]). @@ -245,7 +246,8 @@ register() -> deregister_cleanup(_) -> ok. collect_mf('detailed', Callback) -> - collect(true, ?DETAILED_METRIC_NAME_PREFIX, vhosts_filter_from_pdict(), queues_filter_from_pdict(), enabled_mfs_from_pdict(), Callback), + collect(true, ?DETAILED_METRIC_NAME_PREFIX, vhosts_filter_from_pdict(), queues_filter_from_pdict(), enabled_mfs_from_pdict(?METRICS_RAW), Callback), + collect(true, ?CLUSTER_METRIC_NAME_PREFIX, vhosts_filter_from_pdict(), queues_filter_from_pdict(), enabled_mfs_from_pdict(?METRICS_CLUSTER), Callback), %% identity is here to enable filtering on a cluster name (as already happens in existing dashboards) emit_identity_info(Callback), ok; @@ -703,13 +705,13 @@ sum('', B) -> sum(A, B) -> A + B. -enabled_mfs_from_pdict() -> +enabled_mfs_from_pdict(AllMFs) -> case get(prometheus_mf_filter) of undefined -> []; MFNames -> MFNameSet = sets:from_list(MFNames), - [ MF || MF = {Table, _} <- ?METRICS_RAW ++ ?METRICS_RAW_DETAILED, sets:is_element(Table, MFNameSet) ] + [ MF || MF = {Table, _} <- AllMFs, sets:is_element(Table, MFNameSet) ] end. vhosts_filter_from_pdict() -> diff --git a/deps/rabbitmq_prometheus/test/rabbit_prometheus_http_SUITE.erl b/deps/rabbitmq_prometheus/test/rabbit_prometheus_http_SUITE.erl index 1db499ec14..c8be5fae28 100644 --- a/deps/rabbitmq_prometheus/test/rabbit_prometheus_http_SUITE.erl +++ b/deps/rabbitmq_prometheus/test/rabbit_prometheus_http_SUITE.erl @@ -501,7 +501,7 @@ detailed_metrics_no_families_enabled_by_default(Config) -> vhost_status_metric(Config) -> {_, Body1} = http_get_with_pal(Config, "/metrics/detailed?family=vhost_status", [], 200), - Expected = #{rabbitmq_detailed_vhost_status => + Expected = #{rabbitmq_cluster_vhost_status => #{#{vhost => "vhost-1"} => [1], #{vhost => "vhost-2"} => [1], #{vhost => "/"} => [1]}}, @@ -511,7 +511,7 @@ vhost_status_metric(Config) -> exchange_bindings_metric(Config) -> {_, Body1} = http_get_with_pal(Config, "/metrics/detailed?family=exchange_bindings", [], 200), - Bindings = map_get(rabbitmq_detailed_exchange_bindings, parse_response(Body1)), + Bindings = map_get(rabbitmq_cluster_exchange_bindings, parse_response(Body1)), ?assertEqual([11], map_get(#{vhost=>"vhost-2",exchange=>"vhost-2-queue-with-messages-topic-exchange",type=>"topic"}, Bindings)), ?assertEqual([1], map_get(#{vhost=>"vhost-2",exchange=>"vhost-2-queue-with-messages-direct-exchange",type=>"direct"}, Bindings)), ok. @@ -526,7 +526,7 @@ exchange_names_metric(Config) -> (_, _) -> true end, - map_get(rabbitmq_detailed_exchange_name, parse_response(Body1))), + map_get(rabbitmq_cluster_exchange_name, parse_response(Body1))), ?assertEqual(#{ #{vhost=>"vhost-2",exchange=>"vhost-2-queue-with-messages-topic-exchange",type=>"topic"} => [1], #{vhost=>"vhost-2",exchange=>"vhost-2-queue-with-messages-direct-exchange",type=>"direct"} => [1], |