chore(prometheus): update prometheus conf root name
This commit is contained in:
parent
4afae79be9
commit
0ef38c75ed
|
@ -1,7 +1,7 @@
|
|||
##--------------------------------------------------------------------
|
||||
## emqx_prometheus for EMQ X
|
||||
##--------------------------------------------------------------------
|
||||
emqx_prometheus:{
|
||||
prometheus: {
|
||||
push_gateway_server: "http://127.0.0.1:9091"
|
||||
interval: "15s"
|
||||
enable: true
|
||||
|
|
|
@ -106,14 +106,14 @@ prometheus_api() ->
|
|||
% {"/prometheus/stats", Metadata, stats}.
|
||||
|
||||
prometheus(get, _Request) ->
|
||||
Response = emqx_config:get_raw([<<"emqx_prometheus">>], #{}),
|
||||
Response = emqx_config:get_raw([<<"prometheus">>], #{}),
|
||||
{200, Response};
|
||||
|
||||
prometheus(put, Request) ->
|
||||
{ok, Body, _} = cowboy_req:read_body(Request),
|
||||
Params = emqx_json:decode(Body, [return_maps]),
|
||||
Enable = maps:get(<<"enable">>, Params),
|
||||
ok = emqx_config:update([?APP], Params),
|
||||
ok = emqx_config:update([prometheus], Params),
|
||||
enable_prometheus(Enable).
|
||||
|
||||
% stats(_Bindings, Params) ->
|
||||
|
@ -128,11 +128,11 @@ prometheus(put, Request) ->
|
|||
|
||||
enable_prometheus(true) ->
|
||||
ok = emqx_prometheus_sup:stop_child(?APP),
|
||||
emqx_prometheus_sup:start_child(?APP, emqx_config:get([?APP], #{})),
|
||||
emqx_prometheus_sup:start_child(?APP, emqx_config:get([prometheus], #{})),
|
||||
{200};
|
||||
enable_prometheus(false) ->
|
||||
_ = emqx_prometheus_sup:stop_child(?APP),
|
||||
{200}.
|
||||
|
||||
get_raw(Key, Def) ->
|
||||
emqx_config:get_raw([<<"emqx_prometheus">>] ++ [Key], Def).
|
||||
emqx_config:get_raw([<<"prometheus">>] ++ [Key], Def).
|
||||
|
|
|
@ -34,9 +34,9 @@ stop(_State) ->
|
|||
ok.
|
||||
|
||||
maybe_enable_prometheus() ->
|
||||
case emqx_config:get([?APP, enable], false) of
|
||||
case emqx_config:get([prometheus, enable], false) of
|
||||
true ->
|
||||
emqx_prometheus_sup:start_child(?APP, emqx_config:get([?APP], #{}));
|
||||
emqx_prometheus_sup:start_child(?APP, emqx_config:get([prometheus], #{}));
|
||||
false ->
|
||||
ok
|
||||
end.
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
-export([ structs/0
|
||||
, fields/1]).
|
||||
|
||||
structs() -> ["emqx_prometheus"].
|
||||
structs() -> ["prometheus"].
|
||||
|
||||
fields("emqx_prometheus") ->
|
||||
fields("prometheus") ->
|
||||
[ {push_gateway_server, emqx_schema:t(string())}
|
||||
, {interval, emqx_schema:t(emqx_schema:duration_ms(), undefined, "15s")}
|
||||
, {enable, emqx_schema:t(boolean(), undefined, false)}
|
||||
|
|
|
@ -12,6 +12,6 @@
|
|||
, {"emqx_management", emqx_management_schema}
|
||||
, {"emqx_dashboard", emqx_dashboard_schema}
|
||||
, {"emqx_gateway", emqx_gateway_schema}
|
||||
, {"emqx_prometheus", emqx_prometheus_schema}
|
||||
, {"prometheus", emqx_prometheus_schema}
|
||||
, {"statsd", emqx_statsd_schema}
|
||||
].
|
||||
|
|
Loading…
Reference in New Issue