fix(prometheus): update config in cluster
This commit is contained in:
parent
f5288e895f
commit
7bc59969eb
|
@ -67,16 +67,22 @@ prometheus(get, _Params) ->
|
||||||
{200, emqx:get_raw_config([<<"prometheus">>], #{})};
|
{200, emqx:get_raw_config([<<"prometheus">>], #{})};
|
||||||
|
|
||||||
prometheus(put, #{body := Body}) ->
|
prometheus(put, #{body := Body}) ->
|
||||||
{ok, Config} = emqx:update_config([prometheus], Body),
|
case emqx:update_config([prometheus],
|
||||||
case maps:get(<<"enable">>, Body) of
|
Body,
|
||||||
true ->
|
#{rawconf_with_defaults => true, override_to => cluster}) of
|
||||||
_ = emqx_prometheus_sup:stop_child(?APP),
|
{ok, #{raw_config := NewConfig, config := Config}} ->
|
||||||
emqx_prometheus_sup:start_child(?APP, maps:get(config, Config));
|
case maps:get(<<"enable">>, Body) of
|
||||||
false ->
|
true ->
|
||||||
_ = emqx_prometheus_sup:stop_child(?APP),
|
_ = emqx_prometheus_sup:stop_child(?APP),
|
||||||
ok
|
emqx_prometheus_sup:start_child(?APP, Config);
|
||||||
end,
|
false ->
|
||||||
{200, emqx:get_raw_config([<<"prometheus">>], #{})}.
|
_ = emqx_prometheus_sup:stop_child(?APP)
|
||||||
|
end,
|
||||||
|
{200, NewConfig};
|
||||||
|
{error, Reason} ->
|
||||||
|
Message = list_to_binary(io_lib:format("Update config failed ~p", [Reason])),
|
||||||
|
{500, 'INTERNAL_ERROR', Message}
|
||||||
|
end.
|
||||||
|
|
||||||
stats(get, #{headers := Headers}) ->
|
stats(get, #{headers := Headers}) ->
|
||||||
Type =
|
Type =
|
||||||
|
|
Loading…
Reference in New Issue