Skip to content

Commit

Permalink
implement running and total mnesia node metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
luos committed Jan 8, 2021
1 parent b7cdd4f commit 2314751
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/collectors/mnesia/prometheus_mnesia_collector.erl
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,13 @@ metrics(EnabledMetrics) ->
fun() -> TablewiseMemoryUsage end},
{tablewise_size, gauge,
"Number of rows present per table",
fun() -> TablewiseSize end}
fun() -> TablewiseSize end},
{known_node_count, gauge,
"Count of known mnesia nodes",
fun() -> length(mnesia:system_info(db_nodes)) end},
{running_node_count, gauge,
"Count of running mnesia nodes",
fun() -> length(mnesia:system_info(running_db_nodes)) end}
].

%%====================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ test_mnesia_on_collector_env_off() ->
?assertMatch(nomatch, re:run(Metrics, "erlang_mnesia_logged_transactions")),
?assertMatch(nomatch, re:run(Metrics, "erlang_mnesia_restarted_transactions")),
?assertMatch(nomatch, re:run(Metrics, "erlang_mnesia_memory_usage_bytes")),
?assertMatch(nomatch, re:run(Metrics, "erlang_mnesia_total_node_count")),
?assertMatch(nomatch, re:run(Metrics, "erlang_mnesia_running_node_count")),
application:unset_env(prometheus,mnesia_collector_metrics,[]).

test_mnesia_on_collector() ->
Expand All @@ -66,7 +68,9 @@ test_mnesia_on_collector() ->
?assertMatch({match,_}, re:run(Metrics, "erlang_mnesia_committed_transactions")),
?assertMatch({match,_}, re:run(Metrics, "erlang_mnesia_logged_transactions")),
?assertMatch({match,_}, re:run(Metrics, "erlang_mnesia_restarted_transactions")),
?assertMatch({match,_}, re:run(Metrics, "erlang_mnesia_memory_usage_bytes")).
?assertMatch({match,_}, re:run(Metrics, "erlang_mnesia_memory_usage_bytes")),
?assertMatch({match,_}, re:run(Metrics, "erlang_mnesia_known_node_count 1")),
?assertMatch({match,_}, re:run(Metrics, "erlang_mnesia_running_node_count 1")).

test_mnesia_on_collector_global_labels() ->
Metrics = try
Expand Down

0 comments on commit 2314751

Please sign in to comment.