Skip to content

Commit 925b7d1

Browse files
committed
implement running and total mnesia node count metrics
1 parent b7cdd4f commit 925b7d1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/collectors/mnesia/prometheus_mnesia_collector.erl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,13 @@ metrics(EnabledMetrics) ->
157157
fun() -> TablewiseMemoryUsage end},
158158
{tablewise_size, gauge,
159159
"Number of rows present per table",
160-
fun() -> TablewiseSize end}
160+
fun() -> TablewiseSize end},
161+
{known_node_count, gauge,
162+
"Count of known mnesia nodes",
163+
fun() -> length(mnesia:system_info(db_nodes)) end},
164+
{running_node_count, gauge,
165+
"Count of running mnesia nodes",
166+
fun() -> length(mnesia:system_info(running_db_nodes)) end}
161167
].
162168

163169
%%====================================================================

test/eunit/collectors/mnesia/prometheus_mnesia_collector_tests.erl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ test_mnesia_on_collector_env_off() ->
5353
?assertMatch(nomatch, re:run(Metrics, "erlang_mnesia_logged_transactions")),
5454
?assertMatch(nomatch, re:run(Metrics, "erlang_mnesia_restarted_transactions")),
5555
?assertMatch(nomatch, re:run(Metrics, "erlang_mnesia_memory_usage_bytes")),
56+
?assertMatch(nomatch, re:run(Metrics, "erlang_mnesia_total_node_count")),
57+
?assertMatch(nomatch, re:run(Metrics, "erlang_mnesia_running_node_count")),
5658
application:unset_env(prometheus,mnesia_collector_metrics,[]).
5759

5860
test_mnesia_on_collector() ->
@@ -66,7 +68,9 @@ test_mnesia_on_collector() ->
6668
?assertMatch({match,_}, re:run(Metrics, "erlang_mnesia_committed_transactions")),
6769
?assertMatch({match,_}, re:run(Metrics, "erlang_mnesia_logged_transactions")),
6870
?assertMatch({match,_}, re:run(Metrics, "erlang_mnesia_restarted_transactions")),
69-
?assertMatch({match,_}, re:run(Metrics, "erlang_mnesia_memory_usage_bytes")).
71+
?assertMatch({match,_}, re:run(Metrics, "erlang_mnesia_memory_usage_bytes")),
72+
?assertMatch({match,_}, re:run(Metrics, "erlang_mnesia_known_node_count 1")),
73+
?assertMatch({match,_}, re:run(Metrics, "erlang_mnesia_running_node_count 1")).
7074

7175
test_mnesia_on_collector_global_labels() ->
7276
Metrics = try

0 commit comments

Comments
 (0)