forked from rabbitmq/rabbitmq-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose netsplit/partition info via Prometheus
- Loading branch information
1 parent
d50e318
commit db5c0aa
Showing
3 changed files
with
53 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
49 changes: 49 additions & 0 deletions
49
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,49 @@ | ||
%%% 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]). | ||
|
||
-import(prometheus_model_helpers, [create_mf/5, | ||
gauge_metric/1, | ||
gauge_metric/2]). | ||
|
||
-define(METRIC_NAME_PREFIX, "rabbitmq_"). | ||
|
||
-define(METRICS, [{partitioned_from, gauge, | ||
"Indicates that the current node is partitioned " | ||
"from the peer node during a network partition."} | ||
]). | ||
|
||
%%==================================================================== | ||
%% 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(partitioned_from) -> | ||
%% Note: partition info comes from Mnesia under the hood | ||
[{[{peer, Node}], 1} | ||
|| Node <- rabbit_node_monitor:partitions()]. |
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