feat(metrics): refactor authz metrics name
In the current implementation: ``` Authz checking times = client.authorize + client.authorization.cache_hit = client.authorization.allow + client.authorization.deny client.authorize means how many times the `client.authorize` hook has been executed. client.authorize = client.authorization.matched.allow + client.authorization.matched.deny + client.authorization.nomatch ```
This commit is contained in:
parent
0dcf0545be
commit
1597ea50c1
|
@ -50,7 +50,7 @@ authorize(ClientInfo, PubSub, Topic) ->
|
|||
true -> check_authorization_cache(ClientInfo, PubSub, Topic);
|
||||
false -> do_authorize(ClientInfo, PubSub, Topic)
|
||||
end,
|
||||
inc_acl_metrics(Result),
|
||||
inc_authz_metrics(Result),
|
||||
Result.
|
||||
|
||||
check_authorization_cache(ClientInfo, PubSub, Topic) ->
|
||||
|
@ -64,7 +64,7 @@ check_authorization_cache(ClientInfo, PubSub, Topic) ->
|
|||
'client.check_authz_complete',
|
||||
[ClientInfo, PubSub, Topic, AuthzResult, cache]
|
||||
),
|
||||
inc_acl_metrics(cache_hit),
|
||||
inc_authz_metrics(cache_hit),
|
||||
AuthzResult
|
||||
end.
|
||||
|
||||
|
@ -80,10 +80,10 @@ run_hooks(Name, Args, Acc) ->
|
|||
ok = emqx_metrics:inc(Name),
|
||||
emqx_hooks:run_fold(Name, Args, Acc).
|
||||
|
||||
-compile({inline, [inc_acl_metrics/1]}).
|
||||
inc_acl_metrics(allow) ->
|
||||
emqx_metrics:inc('client.acl.allow');
|
||||
inc_acl_metrics(deny) ->
|
||||
emqx_metrics:inc('client.acl.deny');
|
||||
inc_acl_metrics(cache_hit) ->
|
||||
emqx_metrics:inc('client.acl.cache_hit').
|
||||
-compile({inline, [inc_authz_metrics/1]}).
|
||||
inc_authz_metrics(allow) ->
|
||||
emqx_metrics:inc('client.authorization.allow');
|
||||
inc_authz_metrics(deny) ->
|
||||
emqx_metrics:inc('client.authorization.deny');
|
||||
inc_authz_metrics(cache_hit) ->
|
||||
emqx_metrics:inc('client.authorization.cache_hit').
|
||||
|
|
|
@ -255,9 +255,9 @@
|
|||
|
||||
%% Statistic metrics for ACL checking
|
||||
-define(STASTS_ACL_METRICS, [
|
||||
{counter, 'client.acl.allow'},
|
||||
{counter, 'client.acl.deny'},
|
||||
{counter, 'client.acl.cache_hit'}
|
||||
{counter, 'client.authorization.allow'},
|
||||
{counter, 'client.authorization.deny'},
|
||||
{counter, 'client.authorization.cache_hit'}
|
||||
]).
|
||||
|
||||
%% Overload protetion counters
|
||||
|
@ -677,9 +677,9 @@ reserved_idx('session.resumed') -> 221;
|
|||
reserved_idx('session.takenover') -> 222;
|
||||
reserved_idx('session.discarded') -> 223;
|
||||
reserved_idx('session.terminated') -> 224;
|
||||
reserved_idx('client.acl.allow') -> 300;
|
||||
reserved_idx('client.acl.deny') -> 301;
|
||||
reserved_idx('client.acl.cache_hit') -> 302;
|
||||
reserved_idx('client.authorization.allow') -> 300;
|
||||
reserved_idx('client.authorization.deny') -> 301;
|
||||
reserved_idx('client.authorization.cache_hit') -> 302;
|
||||
reserved_idx('olp.delay.ok') -> 400;
|
||||
reserved_idx('olp.delay.timeout') -> 401;
|
||||
reserved_idx('olp.hbn') -> 402;
|
||||
|
|
|
@ -52,9 +52,9 @@
|
|||
|
||||
-type sources() :: [source()].
|
||||
|
||||
-define(METRIC_ALLOW, 'client.authorize.allow').
|
||||
-define(METRIC_DENY, 'client.authorize.deny').
|
||||
-define(METRIC_NOMATCH, 'client.authorize.nomatch').
|
||||
-define(METRIC_ALLOW, 'client.authorization.matched.allow').
|
||||
-define(METRIC_DENY, 'client.authorization.matched.deny').
|
||||
-define(METRIC_NOMATCH, 'client.authorization.nomatch').
|
||||
|
||||
-define(METRICS, [?METRIC_ALLOW, ?METRIC_DENY, ?METRIC_NOMATCH]).
|
||||
|
||||
|
|
Loading…
Reference in New Issue