fix(mgmt): fix stats api by applying filter to running_nodes

This commit is contained in:
Ivan Dyachkov 2023-04-03 14:14:21 +02:00
parent c20da5ffa6
commit 3d7ceb01a0
2 changed files with 14 additions and 2 deletions

View File

@ -2,7 +2,7 @@
{application, emqx_management, [ {application, emqx_management, [
{description, "EMQX Management API and CLI"}, {description, "EMQX Management API and CLI"},
% strict semver, bump manually! % strict semver, bump manually!
{vsn, "5.0.16"}, {vsn, "5.0.17"},
{modules, []}, {modules, []},
{registered, [emqx_management_sup]}, {registered, [emqx_management_sup]},
{applications, [kernel, stdlib, emqx_plugins, minirest, emqx, emqx_ctl]}, {applications, [kernel, stdlib, emqx_plugins, minirest, emqx, emqx_ctl]},

View File

@ -129,7 +129,19 @@ list(get, #{query_string := Qs}) ->
_ -> _ ->
Data = [ Data = [
maps:from_list(emqx_mgmt:get_stats(Node) ++ [{node, Node}]) maps:from_list(emqx_mgmt:get_stats(Node) ++ [{node, Node}])
|| Node <- mria:running_nodes() || Node <- running_nodes()
], ],
{200, Data} {200, Data}
end. end.
%%%==============================================================================================
%% Internal
running_nodes() ->
Nodes = erlang:nodes([visible, this]),
RpcResults = erpc:multicall(Nodes, emqx, is_running, [], 15000),
[
Node
|| {Node, IsRunning} <- lists:zip(Nodes, RpcResults),
IsRunning =:= {ok, true}
].