Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose number of unreachable cluster peers via Prometheus #9465

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions deps/rabbitmq_prometheus/app.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def all_beam_files(name = "all_beam_files"):
"src/collectors/prometheus_process_collector.erl",
"src/collectors/prometheus_rabbitmq_alarm_metrics_collector.erl",
"src/collectors/prometheus_rabbitmq_core_metrics_collector.erl",
"src/collectors/prometheus_rabbitmq_dynamic_collector.erl",
"src/collectors/prometheus_rabbitmq_global_metrics_collector.erl",
"src/rabbit_prometheus_app.erl",
"src/rabbit_prometheus_dispatcher.erl",
Expand Down Expand Up @@ -42,6 +43,7 @@ def all_test_beam_files(name = "all_test_beam_files"):
"src/collectors/prometheus_process_collector.erl",
"src/collectors/prometheus_rabbitmq_alarm_metrics_collector.erl",
"src/collectors/prometheus_rabbitmq_core_metrics_collector.erl",
"src/collectors/prometheus_rabbitmq_dynamic_collector.erl",
"src/collectors/prometheus_rabbitmq_global_metrics_collector.erl",
"src/rabbit_prometheus_app.erl",
"src/rabbit_prometheus_dispatcher.erl",
Expand Down Expand Up @@ -83,6 +85,7 @@ def all_srcs(name = "all_srcs"):
"src/collectors/prometheus_process_collector.erl",
"src/collectors/prometheus_rabbitmq_alarm_metrics_collector.erl",
"src/collectors/prometheus_rabbitmq_core_metrics_collector.erl",
"src/collectors/prometheus_rabbitmq_dynamic_collector.erl",
"src/collectors/prometheus_rabbitmq_global_metrics_collector.erl",
"src/rabbit_prometheus_app.erl",
"src/rabbit_prometheus_dispatcher.erl",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
%%% Collector for dynamic metrics that are calculated at collection time
-module(prometheus_rabbitmq_dynamic_collector).

-behaviour(prometheus_collector).
-include_lib("prometheus/include/prometheus.hrl").

-export([deregister_cleanup/1,
collect_mf/2]).

-define(METRIC_NAME_PREFIX, "rabbitmq_").

-define(METRICS, [{unreachable_cluster_peers_count, gauge,
"Number of peers in the cluster the current node cannot reach."}
]).

%%====================================================================
%% Collector API
%%====================================================================

deregister_cleanup(_) -> ok.

collect_mf(_Registry, Callback) ->
_ = lists:foreach(
fun({Name, Type, Help}) ->
Callback(
prometheus_model_helpers:create_mf(
?METRIC_NAME(Name),
Help,
Type,
values(Name))
)
end,
?METRICS
),
ok.

%%====================================================================
%% Private Parts
%%====================================================================

values(unreachable_cluster_peers_count) ->
[{[], length(rabbit_nodes:list_unreachable())}].
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ build_dispatcher() ->
prometheus_rabbitmq_core_metrics_collector,
prometheus_rabbitmq_global_metrics_collector,
prometheus_rabbitmq_alarm_metrics_collector,
prometheus_rabbitmq_dynamic_collector,
prometheus_process_collector]),
prometheus_registry:register_collectors('per-object', [
prometheus_vm_system_info_collector,
Expand Down