feat(dashboard): endpoint `/monitor_current` provides mor fields
- `retained_msg_count` Current retained_msg_count on each node and should be same on all nodes. - `license_quota` Only for enterprise edition, provides the max limited connections num.
This commit is contained in:
parent
a40a13b786
commit
a35698009c
|
@ -173,7 +173,9 @@ handle_call(current_rate, _From, State = #state{last = Last}) ->
|
|||
NowTime = erlang:system_time(millisecond),
|
||||
NowSamplers = sample(NowTime),
|
||||
Rate = cal_rate(NowSamplers, Last),
|
||||
{reply, {ok, Rate}, State};
|
||||
NonRateValue = non_rate_value(),
|
||||
Samples = maps:merge(Rate, NonRateValue),
|
||||
{reply, {ok, Samples}, State};
|
||||
handle_call(_Request, _From, State = #state{}) ->
|
||||
{reply, ok, State}.
|
||||
|
||||
|
@ -409,3 +411,21 @@ stats(received_bytes) -> emqx_metrics:val('bytes.received');
|
|||
stats(sent) -> emqx_metrics:val('messages.sent');
|
||||
stats(sent_bytes) -> emqx_metrics:val('bytes.sent');
|
||||
stats(dropped) -> emqx_metrics:val('messages.dropped').
|
||||
|
||||
%% -------------------------------------------------------------------------------------------------
|
||||
%% Retained && License Quota
|
||||
|
||||
%% the non rate values should be same on all nodes
|
||||
non_rate_value() ->
|
||||
#{
|
||||
retained_msg_count => emqx_retainer:retained_count(),
|
||||
license_quota => license_quota()
|
||||
}.
|
||||
|
||||
license_quota() ->
|
||||
case emqx_license_checker:limits() of
|
||||
{ok, #{max_connections := Quota}} ->
|
||||
Quota;
|
||||
{error, no_license} ->
|
||||
0
|
||||
end.
|
||||
|
|
|
@ -1,5 +1,17 @@
|
|||
%%--------------------------------------------------------------------
|
||||
%% Copyright (c) 2019-2023 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||
%% Copyright (c) 2020-2024 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||
%%
|
||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||
%% you may not use this file except in compliance with the License.
|
||||
%% You may obtain a copy of the License at
|
||||
%%
|
||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||
%%
|
||||
%% Unless required by applicable law or agreed to in writing, software
|
||||
%% distributed under the License is distributed on an "AS IS" BASIS,
|
||||
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
%% See the License for the specific language governing permissions and
|
||||
%% limitations under the License.
|
||||
%%--------------------------------------------------------------------
|
||||
|
||||
-module(emqx_dashboard_monitor_api).
|
||||
|
|
|
@ -44,7 +44,11 @@ api_spec() ->
|
|||
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).
|
||||
|
||||
paths() ->
|
||||
[?PREFIX, ?PREFIX ++ "/messages", ?PREFIX ++ "/message/:topic"].
|
||||
[
|
||||
?PREFIX,
|
||||
?PREFIX ++ "/messages",
|
||||
?PREFIX ++ "/message/:topic"
|
||||
].
|
||||
|
||||
schema(?PREFIX) ->
|
||||
#{
|
||||
|
|
Loading…
Reference in New Issue