fix: remove routes
This commit is contained in:
parent
587fbf07ba
commit
b8e2c76382
|
@ -178,7 +178,6 @@ stats_fun() ->
|
||||||
undefined ->
|
undefined ->
|
||||||
ok;
|
ok;
|
||||||
Size ->
|
Size ->
|
||||||
emqx_stats:setstat('routes.count', 'routes.max', Size),
|
|
||||||
emqx_stats:setstat('topics.count', 'topics.max', Size)
|
emqx_stats:setstat('topics.count', 'topics.max', Size)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
|
@ -116,12 +116,6 @@
|
||||||
'subscriptions.shared.max'
|
'subscriptions.shared.max'
|
||||||
]).
|
]).
|
||||||
|
|
||||||
%% Route stats
|
|
||||||
-define(ROUTE_STATS, [
|
|
||||||
'routes.count',
|
|
||||||
'routes.max'
|
|
||||||
]).
|
|
||||||
|
|
||||||
%% Retained stats
|
%% Retained stats
|
||||||
-define(RETAINED_STATS, [
|
-define(RETAINED_STATS, [
|
||||||
'retained.count',
|
'retained.count',
|
||||||
|
@ -213,7 +207,6 @@ init(#{tick_ms := TickMs}) ->
|
||||||
?CHANNEL_STATS,
|
?CHANNEL_STATS,
|
||||||
?SESSION_STATS,
|
?SESSION_STATS,
|
||||||
?PUBSUB_STATS,
|
?PUBSUB_STATS,
|
||||||
?ROUTE_STATS,
|
|
||||||
?RETAINED_STATS
|
?RETAINED_STATS
|
||||||
]),
|
]),
|
||||||
true = ets:insert(?TAB, [{Name, 0} || Name <- Stats]),
|
true = ets:insert(?TAB, [{Name, 0} || Name <- Stats]),
|
||||||
|
|
|
@ -328,9 +328,7 @@ systopic_stats() ->
|
||||||
<<"subscriptions/shared/max">>,
|
<<"subscriptions/shared/max">>,
|
||||||
<<"subscriptions/shared/count">>,
|
<<"subscriptions/shared/count">>,
|
||||||
<<"topics/max">>,
|
<<"topics/max">>,
|
||||||
<<"topics/count">>,
|
<<"topics/count">>
|
||||||
<<"routes/max">>,
|
|
||||||
<<"routes/count">>
|
|
||||||
],
|
],
|
||||||
?LET(
|
?LET(
|
||||||
{Nodename, T},
|
{Nodename, T},
|
||||||
|
|
|
@ -1,88 +1 @@
|
||||||
|
# TODO: Doc
|
||||||
emqx-dashboard
|
|
||||||
==============
|
|
||||||
|
|
||||||
EMQX Dashboard
|
|
||||||
|
|
||||||
REST API
|
|
||||||
--------
|
|
||||||
|
|
||||||
The prefix of REST API is '/api/v4/'.
|
|
||||||
|
|
||||||
Method | Path | Description
|
|
||||||
-------|---------------------------------------|------------------------------------
|
|
||||||
GET | /nodes/ | A list of nodes in the cluster
|
|
||||||
GET | /nodes/:node | Lookup a node in the cluster
|
|
||||||
GET | /brokers/ | A list of brokers in the cluster
|
|
||||||
GET | /brokers/:node | Get broker info of a node
|
|
||||||
GET | /metrics/ | A list of metrics of all nodes in the cluster
|
|
||||||
GET | /nodes/:node/metrics/ | A list of metrics of a node
|
|
||||||
GET | /stats/ | A list of stats of all nodes in the cluster
|
|
||||||
GET | /nodes/:node/stats/ | A list of stats of a node
|
|
||||||
GET | /nodes/:node/clients/ | A list of clients on a node
|
|
||||||
GET | /listeners/ | A list of listeners in the cluster
|
|
||||||
GET | /nodes/:node/listeners | A list of listeners on the node
|
|
||||||
GET | /nodes/:node/sessions/ | A list of sessions on a node
|
|
||||||
GET | /subscriptions/:clientid | A list of subscriptions of a client
|
|
||||||
GET | /nodes/:node/subscriptions/:clientid | A list of subscriptions of a client on the node
|
|
||||||
GET | /nodes/:node/subscriptions/ | A list of subscriptions on a node
|
|
||||||
PUT | /clients/:clientid/clean_authz_cache | Clean Authorization cache of a client
|
|
||||||
GET | /configs/ | Get all configs
|
|
||||||
GET | /nodes/:node/configs/ | Get all configs of a node
|
|
||||||
GET | /nodes/:node/plugin_configs/:plugin | Get configurations of a plugin on the node
|
|
||||||
DELETE | /clients/:clientid | Kick out a client
|
|
||||||
GET | /alarms/:node | List alarms of a node
|
|
||||||
GET | /alarms/ | List all alarms
|
|
||||||
GET | /plugins/ | List all plugins in the cluster
|
|
||||||
GET | /nodes/:node/plugins/ | List all plugins on a node
|
|
||||||
GET | /routes/ | List routes
|
|
||||||
POST | /nodes/:node/plugins/:plugin/load | Load a plugin
|
|
||||||
GET | /clients/:clientid | Lookup a client in the cluster
|
|
||||||
GET | nodes/:node/clients/:clientid | Lookup a client on node
|
|
||||||
GET | nodes/:node/sessions/:clientid | Lookup a session in the cluster
|
|
||||||
GET | nodes/:node/sessions/:clientid | Lookup a session on the node
|
|
||||||
POST | /mqtt/publish | Publish a MQTT message
|
|
||||||
POST | /mqtt/subscribe | Subscribe a topic
|
|
||||||
POST | /nodes/:node/plugins/:plugin/unload | Unload a plugin
|
|
||||||
POST | /mqtt/unsubscribe | Unsubscribe a topic
|
|
||||||
PUT | /configs/:app | Update config of an application in the cluster
|
|
||||||
PUT | /nodes/:node/configs/:app | Update config of an application on a node
|
|
||||||
PUT | /nodes/:node/plugin_configs/:plugin | Update configurations of a plugin on the node
|
|
||||||
|
|
||||||
Build
|
|
||||||
-----
|
|
||||||
|
|
||||||
make && make ct
|
|
||||||
|
|
||||||
Configuration
|
|
||||||
------------
|
|
||||||
|
|
||||||
```
|
|
||||||
dashboard.listener = 18083
|
|
||||||
|
|
||||||
dashboard.listener.acceptors = 2
|
|
||||||
|
|
||||||
dashboard.listener.max_clients = 512
|
|
||||||
```
|
|
||||||
|
|
||||||
Load Plugin
|
|
||||||
-----------
|
|
||||||
|
|
||||||
```
|
|
||||||
./bin/emqx_ctl plugins load emqx_dashboard
|
|
||||||
```
|
|
||||||
|
|
||||||
Login
|
|
||||||
-----
|
|
||||||
|
|
||||||
URL: http://host:18083
|
|
||||||
|
|
||||||
Username: admin
|
|
||||||
|
|
||||||
Password: public
|
|
||||||
|
|
||||||
License
|
|
||||||
-------
|
|
||||||
|
|
||||||
Apache License Version 2.0
|
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
|
|
||||||
-define(GAUGE_SAMPLER_LIST,
|
-define(GAUGE_SAMPLER_LIST,
|
||||||
[ subscriptions
|
[ subscriptions
|
||||||
, routes
|
, topics
|
||||||
, connections
|
, connections
|
||||||
]).
|
]).
|
||||||
|
|
||||||
|
|
|
@ -352,7 +352,7 @@ count_map(M1, M2) ->
|
||||||
lists:foldl(Fun, #{}, ?SAMPLER_LIST).
|
lists:foldl(Fun, #{}, ?SAMPLER_LIST).
|
||||||
|
|
||||||
value(connections) -> emqx_stats:getstat('connections.count');
|
value(connections) -> emqx_stats:getstat('connections.count');
|
||||||
value(routes) -> emqx_stats:getstat('routes.count');
|
value(topics) -> emqx_stats:getstat('topics.count');
|
||||||
value(subscriptions) -> emqx_stats:getstat('subscriptions.count');
|
value(subscriptions) -> emqx_stats:getstat('subscriptions.count');
|
||||||
value(received) -> emqx_metrics:val('messages.received');
|
value(received) -> emqx_metrics:val('messages.received');
|
||||||
value(received_bytes) -> emqx_metrics:val('bytes.received');
|
value(received_bytes) -> emqx_metrics:val('bytes.received');
|
||||||
|
|
|
@ -148,8 +148,8 @@ swagger_desc(dropped) -> swagger_desc_format("Dropped messages ");
|
||||||
swagger_desc(subscriptions) ->
|
swagger_desc(subscriptions) ->
|
||||||
<<"Subscriptions at the time of sampling."
|
<<"Subscriptions at the time of sampling."
|
||||||
" Can only represent the approximate state">>;
|
" Can only represent the approximate state">>;
|
||||||
swagger_desc(routes) ->
|
swagger_desc(topics) ->
|
||||||
<<"Routes at the time of sampling."
|
<<"Count topics at the time of sampling."
|
||||||
" Can only represent the approximate state">>;
|
" Can only represent the approximate state">>;
|
||||||
swagger_desc(connections) ->
|
swagger_desc(connections) ->
|
||||||
<<"Connections at the time of sampling."
|
<<"Connections at the time of sampling."
|
||||||
|
|
|
@ -71,10 +71,6 @@
|
||||||
, do_list_subscriptions/0
|
, do_list_subscriptions/0
|
||||||
]).
|
]).
|
||||||
|
|
||||||
%% Routes
|
|
||||||
-export([ lookup_routes/1
|
|
||||||
]).
|
|
||||||
|
|
||||||
%% PubSub
|
%% PubSub
|
||||||
-export([ subscribe/2
|
-export([ subscribe/2
|
||||||
, do_subscribe/2
|
, do_subscribe/2
|
||||||
|
@ -183,8 +179,8 @@ get_stats() ->
|
||||||
GlobalStatsKeys =
|
GlobalStatsKeys =
|
||||||
[ 'retained.count'
|
[ 'retained.count'
|
||||||
, 'retained.max'
|
, 'retained.max'
|
||||||
, 'routes.count'
|
, 'topics.count'
|
||||||
, 'routes.max'
|
, 'topics.max'
|
||||||
, 'subscriptions.shared.count'
|
, 'subscriptions.shared.count'
|
||||||
, 'subscriptions.shared.max'
|
, 'subscriptions.shared.max'
|
||||||
],
|
],
|
||||||
|
@ -357,13 +353,6 @@ lookup_subscriptions(ClientId) ->
|
||||||
lookup_subscriptions(Node, ClientId) ->
|
lookup_subscriptions(Node, ClientId) ->
|
||||||
wrap_rpc(emqx_broker_proto_v1:list_client_subscriptions(Node, ClientId)).
|
wrap_rpc(emqx_broker_proto_v1:list_client_subscriptions(Node, ClientId)).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Routes
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
|
|
||||||
lookup_routes(Topic) ->
|
|
||||||
emqx_router:lookup_routes(Topic).
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% PubSub
|
%% PubSub
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
@ -470,6 +459,7 @@ delete_banned(Who) ->
|
||||||
item(subscription, {{Topic, ClientId}, Options}) ->
|
item(subscription, {{Topic, ClientId}, Options}) ->
|
||||||
#{topic => Topic, clientid => ClientId, options => Options};
|
#{topic => Topic, clientid => ClientId, options => Options};
|
||||||
|
|
||||||
|
%% TODO: may be delete
|
||||||
item(route, #route{topic = Topic, dest = Node}) ->
|
item(route, #route{topic = Topic, dest = Node}) ->
|
||||||
#{topic => Topic, node => Node};
|
#{topic => Topic, node => Node};
|
||||||
item(route, {Topic, Node}) ->
|
item(route, {Topic, Node}) ->
|
||||||
|
|
|
@ -93,12 +93,6 @@ fields(node_stats_data) ->
|
||||||
, { 'retained.max'
|
, { 'retained.max'
|
||||||
, mk( integer(), #{ desc => <<"Historical maximum number of retained messages">>
|
, mk( integer(), #{ desc => <<"Historical maximum number of retained messages">>
|
||||||
, example => 0})}
|
, example => 0})}
|
||||||
, { 'routes.count'
|
|
||||||
, mk( integer(), #{ desc => <<"Number of current routes">>
|
|
||||||
, example => 0})}
|
|
||||||
, { 'routes.max'
|
|
||||||
, mk( integer(), #{ desc => <<"Historical maximum number of routes">>
|
|
||||||
, example => 0})}
|
|
||||||
, { 'sessions.count'
|
, { 'sessions.count'
|
||||||
, mk( integer(), #{ desc => <<"Number of current sessions">>
|
, mk( integer(), #{ desc => <<"Number of current sessions">>
|
||||||
, example => 0})}
|
, example => 0})}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
%% limitations under the License.
|
%% limitations under the License.
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
-module(emqx_mgmt_api_routes).
|
-module(emqx_mgmt_api_topics).
|
||||||
|
|
||||||
-include_lib("emqx/include/emqx.hrl").
|
-include_lib("emqx/include/emqx.hrl").
|
||||||
-include_lib("typerefl/include/types.hrl").
|
-include_lib("typerefl/include/types.hrl").
|
||||||
|
@ -28,28 +28,28 @@
|
||||||
, fields/1
|
, fields/1
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-export([ routes/2
|
-export([ topics/2
|
||||||
, route/2
|
, topic/2
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-export([ query/4]).
|
-export([ query/4]).
|
||||||
|
|
||||||
-define(TOPIC_NOT_FOUND, 'TOPIC_NOT_FOUND').
|
-define(TOPIC_NOT_FOUND, 'TOPIC_NOT_FOUND').
|
||||||
|
|
||||||
-define(ROUTES_QSCHEMA, [{<<"topic">>, binary}, {<<"node">>, atom}]).
|
-define(TOPICS_QUERY_SCHEMA, [{<<"topic">>, binary}, {<<"node">>, atom}]).
|
||||||
|
|
||||||
|
|
||||||
api_spec() ->
|
api_spec() ->
|
||||||
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true, translate_body => true}).
|
emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true, translate_body => true}).
|
||||||
|
|
||||||
paths() ->
|
paths() ->
|
||||||
["/routes", "/routes/:topic"].
|
["/topics", "/topics/:topic"].
|
||||||
|
|
||||||
schema("/routes") ->
|
schema("/topics") ->
|
||||||
#{
|
#{
|
||||||
'operationId' => routes,
|
'operationId' => topics,
|
||||||
get => #{
|
get => #{
|
||||||
description => <<"EMQX Topics List">>,
|
description => <<"Topics list">>,
|
||||||
parameters => [
|
parameters => [
|
||||||
topic_param(query),
|
topic_param(query),
|
||||||
node_param(),
|
node_param(),
|
||||||
|
@ -64,11 +64,11 @@ schema("/routes") ->
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
schema("/routes/:topic") ->
|
schema("/topics/:topic") ->
|
||||||
#{
|
#{
|
||||||
'operationId' => route,
|
'operationId' => topic,
|
||||||
get => #{
|
get => #{
|
||||||
description => <<"EMQX Topic List">>,
|
description => <<"Lookup topic info by name">>,
|
||||||
parameters => [topic_param(path)],
|
parameters => [topic_param(path)],
|
||||||
responses => #{
|
responses => #{
|
||||||
200 => hoconsc:mk(hoconsc:ref(topic), #{}),
|
200 => hoconsc:mk(hoconsc:ref(topic), #{}),
|
||||||
|
@ -94,21 +94,21 @@ fields(meta) ->
|
||||||
|
|
||||||
%%%==============================================================================================
|
%%%==============================================================================================
|
||||||
%% parameters trans
|
%% parameters trans
|
||||||
routes(get, #{query_string := Qs}) ->
|
topics(get, #{query_string := Qs}) ->
|
||||||
do_list(generate_topic(Qs)).
|
do_list(generate_topic(Qs)).
|
||||||
|
|
||||||
route(get, #{bindings := Bindings}) ->
|
topic(get, #{bindings := Bindings}) ->
|
||||||
lookup(generate_topic(Bindings)).
|
lookup(generate_topic(Bindings)).
|
||||||
|
|
||||||
%%%==============================================================================================
|
%%%==============================================================================================
|
||||||
%% api apply
|
%% api apply
|
||||||
do_list(Params) ->
|
do_list(Params) ->
|
||||||
Response = emqx_mgmt_api:node_query(
|
Response = emqx_mgmt_api:node_query(
|
||||||
node(), Params, emqx_route, ?ROUTES_QSCHEMA, {?MODULE, query}),
|
node(), Params, emqx_route, ?TOPICS_QUERY_SCHEMA, {?MODULE, query}),
|
||||||
emqx_mgmt_util:generate_response(Response).
|
emqx_mgmt_util:generate_response(Response).
|
||||||
|
|
||||||
lookup(#{topic := Topic}) ->
|
lookup(#{topic := Topic}) ->
|
||||||
case emqx_mgmt:lookup_routes(Topic) of
|
case emqx_router:lookup_routes(Topic) of
|
||||||
[] ->
|
[] ->
|
||||||
{404, #{code => ?TOPIC_NOT_FOUND, message => <<"Topic not found">>}};
|
{404, #{code => ?TOPIC_NOT_FOUND, message => <<"Topic not found">>}};
|
||||||
[Route] ->
|
[Route] ->
|
|
@ -31,7 +31,7 @@
|
||||||
broker/1,
|
broker/1,
|
||||||
cluster/1,
|
cluster/1,
|
||||||
clients/1,
|
clients/1,
|
||||||
routes/1,
|
topics/1,
|
||||||
subscriptions/1,
|
subscriptions/1,
|
||||||
plugins/1,
|
plugins/1,
|
||||||
listeners/1,
|
listeners/1,
|
||||||
|
@ -164,17 +164,17 @@ if_client(ClientId, Fun) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% @doc Routes Command
|
%% @doc Topics Command
|
||||||
|
|
||||||
routes(["list"]) ->
|
topics(["list"]) ->
|
||||||
dump(emqx_route);
|
dump(emqx_route);
|
||||||
routes(["show", Topic]) ->
|
topics(["show", Topic]) ->
|
||||||
Routes = ets:lookup(emqx_route, bin(Topic)),
|
Routes = ets:lookup(emqx_route, bin(Topic)),
|
||||||
[print({emqx_route, Route}) || Route <- Routes];
|
[print({emqx_topic, Route}) || Route <- Routes];
|
||||||
routes(_) ->
|
topics(_) ->
|
||||||
emqx_ctl:usage([
|
emqx_ctl:usage([
|
||||||
{"routes list", "List all routes"},
|
{"topics list", "List all topics"},
|
||||||
{"routes show <Topic>", "Show a route"}
|
{"topics show <Topic>", "Show a topic"}
|
||||||
]).
|
]).
|
||||||
|
|
||||||
subscriptions(["list"]) ->
|
subscriptions(["list"]) ->
|
||||||
|
@ -750,9 +750,9 @@ print({client, {ClientId, ChanPid}}) ->
|
||||||
end,
|
end,
|
||||||
[format(K, maps:get(K, Info1)) || K <- InfoKeys]
|
[format(K, maps:get(K, Info1)) || K <- InfoKeys]
|
||||||
);
|
);
|
||||||
print({emqx_route, #route{topic = Topic, dest = {_, Node}}}) ->
|
print({emqx_topic, #route{topic = Topic, dest = {_, Node}}}) ->
|
||||||
emqx_ctl:print("~ts -> ~ts~n", [Topic, Node]);
|
emqx_ctl:print("~ts -> ~ts~n", [Topic, Node]);
|
||||||
print({emqx_route, #route{topic = Topic, dest = Node}}) ->
|
print({emqx_topic, #route{topic = Topic, dest = Node}}) ->
|
||||||
emqx_ctl:print("~ts -> ~ts~n", [Topic, Node]);
|
emqx_ctl:print("~ts -> ~ts~n", [Topic, Node]);
|
||||||
print(#plugin{name = Name, descr = Descr, active = Active}) ->
|
print(#plugin{name = Name, descr = Descr, active = Active}) ->
|
||||||
emqx_ctl:print(
|
emqx_ctl:print(
|
||||||
|
|
|
@ -218,10 +218,6 @@ emqx_connections_max 0
|
||||||
emqx_retained_count 3
|
emqx_retained_count 3
|
||||||
# TYPE emqx_retained_max gauge
|
# TYPE emqx_retained_max gauge
|
||||||
emqx_retained_max 3
|
emqx_retained_max 3
|
||||||
# TYPE emqx_routes_count gauge
|
|
||||||
emqx_routes_count 0
|
|
||||||
# TYPE emqx_routes_max gauge
|
|
||||||
emqx_routes_max 0
|
|
||||||
# TYPE emqx_sessions_count gauge
|
# TYPE emqx_sessions_count gauge
|
||||||
emqx_sessions_count 0
|
emqx_sessions_count 0
|
||||||
# TYPE emqx_sessions_max gauge
|
# TYPE emqx_sessions_max gauge
|
||||||
|
|
|
@ -248,12 +248,6 @@ emqx_collect(emqx_subscriptions_shared_count, Stats) ->
|
||||||
emqx_collect(emqx_subscriptions_shared_max, Stats) ->
|
emqx_collect(emqx_subscriptions_shared_max, Stats) ->
|
||||||
gauge_metric(?C('subscriptions.shared.max', Stats));
|
gauge_metric(?C('subscriptions.shared.max', Stats));
|
||||||
|
|
||||||
%% routes
|
|
||||||
emqx_collect(emqx_routes_count, Stats) ->
|
|
||||||
gauge_metric(?C('routes.count', Stats));
|
|
||||||
emqx_collect(emqx_routes_max, Stats) ->
|
|
||||||
gauge_metric(?C('routes.max', Stats));
|
|
||||||
|
|
||||||
%% retained
|
%% retained
|
||||||
emqx_collect(emqx_retained_count, Stats) ->
|
emqx_collect(emqx_retained_count, Stats) ->
|
||||||
gauge_metric(?C('retained.count', Stats));
|
gauge_metric(?C('retained.count', Stats));
|
||||||
|
@ -517,8 +511,6 @@ emqx_stats() ->
|
||||||
, emqx_subscriptions_max
|
, emqx_subscriptions_max
|
||||||
, emqx_subscriptions_shared_count
|
, emqx_subscriptions_shared_count
|
||||||
, emqx_subscriptions_shared_max
|
, emqx_subscriptions_shared_max
|
||||||
, emqx_routes_count
|
|
||||||
, emqx_routes_max
|
|
||||||
, emqx_retained_count
|
, emqx_retained_count
|
||||||
, emqx_retained_max
|
, emqx_retained_max
|
||||||
].
|
].
|
||||||
|
|
Loading…
Reference in New Issue