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 00f2451
Showing
3 changed files
with
52 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
48 changes: 48 additions & 0 deletions
48
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,48 @@ | ||
%%% 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) -> | ||
[{[{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