feat: add some authz/connection missing metrics
This commit is contained in:
parent
141676185d
commit
b9a97923c4
|
@ -177,7 +177,9 @@ names() ->
|
||||||
emqx_subscriptions_shared_count,
|
emqx_subscriptions_shared_count,
|
||||||
emqx_subscriptions_shared_max,
|
emqx_subscriptions_shared_max,
|
||||||
emqx_retained_count,
|
emqx_retained_count,
|
||||||
emqx_retained_max
|
emqx_retained_max,
|
||||||
|
emqx_delayed_count,
|
||||||
|
emqx_delayed_max
|
||||||
].
|
].
|
||||||
|
|
||||||
%% @doc Get stats by name.
|
%% @doc Get stats by name.
|
||||||
|
|
|
@ -87,10 +87,17 @@ create_metric_views() ->
|
||||||
create_gauge(Meter, VmGauge, fun ?MODULE:get_vm_gauge/1),
|
create_gauge(Meter, VmGauge, fun ?MODULE:get_vm_gauge/1),
|
||||||
ClusterGauge = [{'node.running', 0}, {'node.stopped', 0}],
|
ClusterGauge = [{'node.running', 0}, {'node.stopped', 0}],
|
||||||
create_gauge(Meter, ClusterGauge, fun ?MODULE:get_cluster_gauge/1),
|
create_gauge(Meter, ClusterGauge, fun ?MODULE:get_cluster_gauge/1),
|
||||||
Metrics = lists:map(fun({K, V}) -> {K, V, unit(K)} end, emqx_metrics:all()),
|
Metrics = lists:map(fun({K, V}) -> {to_metric_name(K), V, unit(K)} end, emqx_metrics:all()),
|
||||||
create_counter(Meter, Metrics, fun ?MODULE:get_metric_counter/1),
|
create_counter(Meter, Metrics, fun ?MODULE:get_metric_counter/1),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
to_metric_name('messages.dropped.await_pubrel_timeout') ->
|
||||||
|
'messages.dropped.expired';
|
||||||
|
to_metric_name('packets.connect.received') ->
|
||||||
|
'packets.connect';
|
||||||
|
to_metric_name(Name) ->
|
||||||
|
Name.
|
||||||
|
|
||||||
unit(K) ->
|
unit(K) ->
|
||||||
case lists:member(K, bytes_metrics()) of
|
case lists:member(K, bytes_metrics()) of
|
||||||
true -> kb;
|
true -> kb;
|
||||||
|
|
|
@ -231,6 +231,10 @@ emqx_collect(emqx_sessions_count, Stats) ->
|
||||||
gauge_metric(?C('sessions.count', Stats));
|
gauge_metric(?C('sessions.count', Stats));
|
||||||
emqx_collect(emqx_sessions_max, Stats) ->
|
emqx_collect(emqx_sessions_max, Stats) ->
|
||||||
gauge_metric(?C('sessions.max', Stats));
|
gauge_metric(?C('sessions.max', Stats));
|
||||||
|
emqx_collect(emqx_channels_count, Stats) ->
|
||||||
|
gauge_metric(?C('channels.count', Stats));
|
||||||
|
emqx_collect(emqx_channels_max, Stats) ->
|
||||||
|
gauge_metric(?C('channels.max', Stats));
|
||||||
%% pub/sub stats
|
%% pub/sub stats
|
||||||
emqx_collect(emqx_topics_count, Stats) ->
|
emqx_collect(emqx_topics_count, Stats) ->
|
||||||
gauge_metric(?C('topics.count', Stats));
|
gauge_metric(?C('topics.count', Stats));
|
||||||
|
@ -257,6 +261,11 @@ emqx_collect(emqx_retained_count, Stats) ->
|
||||||
gauge_metric(?C('retained.count', Stats));
|
gauge_metric(?C('retained.count', Stats));
|
||||||
emqx_collect(emqx_retained_max, Stats) ->
|
emqx_collect(emqx_retained_max, Stats) ->
|
||||||
gauge_metric(?C('retained.max', Stats));
|
gauge_metric(?C('retained.max', Stats));
|
||||||
|
%% delayed
|
||||||
|
emqx_collect(emqx_delayed_count, Stats) ->
|
||||||
|
gauge_metric(?C('delayed.count', Stats));
|
||||||
|
emqx_collect(emqx_delayed_max, Stats) ->
|
||||||
|
gauge_metric(?C('delayed.max', Stats));
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Metrics - packets & bytes
|
%% Metrics - packets & bytes
|
||||||
|
|
||||||
|
@ -411,7 +420,10 @@ emqx_collect(emqx_delivery_dropped_expired, Stats) ->
|
||||||
counter_metric(?C('delivery.dropped.expired', Stats));
|
counter_metric(?C('delivery.dropped.expired', Stats));
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Metrics - client
|
%% Metrics - client
|
||||||
|
emqx_collect(emqx_client_connect, Stats) ->
|
||||||
|
counter_metric(?C('client.connect', Stats));
|
||||||
|
emqx_collect(emqx_client_connack, Stats) ->
|
||||||
|
counter_metric(?C('client.connack', Stats));
|
||||||
emqx_collect(emqx_client_connected, Stats) ->
|
emqx_collect(emqx_client_connected, Stats) ->
|
||||||
counter_metric(?C('client.connected', Stats));
|
counter_metric(?C('client.connected', Stats));
|
||||||
emqx_collect(emqx_client_authenticate, Stats) ->
|
emqx_collect(emqx_client_authenticate, Stats) ->
|
||||||
|
@ -460,6 +472,14 @@ emqx_collect(emqx_authorization_deny, Stats) ->
|
||||||
counter_metric(?C('authorization.deny', Stats));
|
counter_metric(?C('authorization.deny', Stats));
|
||||||
emqx_collect(emqx_authorization_cache_hit, Stats) ->
|
emqx_collect(emqx_authorization_cache_hit, Stats) ->
|
||||||
counter_metric(?C('authorization.cache_hit', Stats));
|
counter_metric(?C('authorization.cache_hit', Stats));
|
||||||
|
emqx_collect(emqx_authorization_superuser, Stats) ->
|
||||||
|
counter_metric(?C('authorization.superuser', Stats));
|
||||||
|
emqx_collect(emqx_authorization_nomatch, Stats) ->
|
||||||
|
counter_metric(?C('authorization.nomatch', Stats));
|
||||||
|
emqx_collect(emqx_authorization_matched_allow, Stats) ->
|
||||||
|
counter_metric(?C('authorization.matched_allow', Stats));
|
||||||
|
emqx_collect(emqx_authorization_matched_deny, Stats) ->
|
||||||
|
counter_metric(?C('authorization.matched_deny', Stats));
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Metrics - authn
|
%% Metrics - authn
|
||||||
emqx_collect(emqx_authentication_success, Stats) ->
|
emqx_collect(emqx_authentication_success, Stats) ->
|
||||||
|
@ -566,7 +586,11 @@ emqx_metrics_acl() ->
|
||||||
[
|
[
|
||||||
emqx_authorization_allow,
|
emqx_authorization_allow,
|
||||||
emqx_authorization_deny,
|
emqx_authorization_deny,
|
||||||
emqx_authorization_cache_hit
|
emqx_authorization_cache_hit,
|
||||||
|
emqx_authorization_superuser,
|
||||||
|
emqx_authorization_nomatch,
|
||||||
|
emqx_authorization_matched_allow,
|
||||||
|
emqx_authorization_matched_deny
|
||||||
].
|
].
|
||||||
|
|
||||||
emqx_metrics_authn() ->
|
emqx_metrics_authn() ->
|
||||||
|
@ -609,6 +633,8 @@ emqx_metrics_delivery() ->
|
||||||
|
|
||||||
emqx_metrics_client() ->
|
emqx_metrics_client() ->
|
||||||
[
|
[
|
||||||
|
emqx_client_connect,
|
||||||
|
emqx_client_connack,
|
||||||
emqx_client_connected,
|
emqx_client_connected,
|
||||||
emqx_client_authenticate,
|
emqx_client_authenticate,
|
||||||
emqx_client_auth_anonymous,
|
emqx_client_auth_anonymous,
|
||||||
|
|
Loading…
Reference in New Issue