-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9473 from rabbitmq/mergify/bp/v3.12.x/pr-9465
Expose number of unreachable cluster peers via Prometheus (backport #9465)
- Loading branch information
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
deps/rabbitmq_prometheus/src/collectors/prometheus_rabbitmq_dynamic_collector.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())}]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters