feat: add overload_protection metrics to prometheus
This commit is contained in:
parent
61536b5362
commit
df9f8da178
|
@ -2,7 +2,7 @@
|
||||||
{application, emqx_prometheus, [
|
{application, emqx_prometheus, [
|
||||||
{description, "Prometheus for EMQX"},
|
{description, "Prometheus for EMQX"},
|
||||||
% strict semver, bump manually!
|
% strict semver, bump manually!
|
||||||
{vsn, "5.0.15"},
|
{vsn, "5.0.16"},
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{registered, [emqx_prometheus_sup]},
|
{registered, [emqx_prometheus_sup]},
|
||||||
{applications, [kernel, stdlib, prometheus, emqx, emqx_management]},
|
{applications, [kernel, stdlib, prometheus, emqx, emqx_management]},
|
||||||
|
|
|
@ -168,6 +168,7 @@ collect_mf(_Registry, Callback) ->
|
||||||
_ = [add_collect_family(Name, Metrics, Callback, counter) || Name <- emqx_metrics_delivery()],
|
_ = [add_collect_family(Name, Metrics, Callback, counter) || Name <- emqx_metrics_delivery()],
|
||||||
_ = [add_collect_family(Name, Metrics, Callback, counter) || Name <- emqx_metrics_client()],
|
_ = [add_collect_family(Name, Metrics, Callback, counter) || Name <- emqx_metrics_client()],
|
||||||
_ = [add_collect_family(Name, Metrics, Callback, counter) || Name <- emqx_metrics_session()],
|
_ = [add_collect_family(Name, Metrics, Callback, counter) || Name <- emqx_metrics_session()],
|
||||||
|
_ = [add_collect_family(Name, Metrics, Callback, counter) || Name <- emqx_metrics_olp()],
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
%% @private
|
%% @private
|
||||||
|
@ -437,6 +438,19 @@ emqx_collect(emqx_session_discarded, Stats) ->
|
||||||
emqx_collect(emqx_session_terminated, Stats) ->
|
emqx_collect(emqx_session_terminated, Stats) ->
|
||||||
counter_metric(?C('session.terminated', Stats));
|
counter_metric(?C('session.terminated', Stats));
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
|
%% Metrics - overload protection
|
||||||
|
emqx_collect(emqx_overload_protection_delay_ok, Stats) ->
|
||||||
|
counter_metric(?C('olp.delay.ok', Stats));
|
||||||
|
emqx_collect(emqx_overload_protection_delay_timeout, Stats) ->
|
||||||
|
counter_metric(?C('olp.delay.timeout', Stats));
|
||||||
|
emqx_collect(emqx_overload_protection_hibernation, Stats) ->
|
||||||
|
counter_metric(?C('olp.hbn', Stats));
|
||||||
|
emqx_collect(emqx_overload_protection_gc, Stats) ->
|
||||||
|
counter_metric(?C('olp.gc', Stats));
|
||||||
|
emqx_collect(emqx_overload_protection_new_conn, Stats) ->
|
||||||
|
counter_metric(?C('olp.new_conn', Stats));
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
%% VM
|
%% VM
|
||||||
|
|
||||||
emqx_collect(emqx_vm_cpu_use, VMData) ->
|
emqx_collect(emqx_vm_cpu_use, VMData) ->
|
||||||
|
@ -506,6 +520,30 @@ emqx_metrics_packets() ->
|
||||||
emqx_packets_auth_sent
|
emqx_packets_auth_sent
|
||||||
].
|
].
|
||||||
|
|
||||||
|
emqx_metrics_olp() ->
|
||||||
|
case is_olp_enabled() of
|
||||||
|
true ->
|
||||||
|
[
|
||||||
|
emqx_overload_protection_delay_ok,
|
||||||
|
emqx_overload_protection_delay_timeout,
|
||||||
|
emqx_overload_protection_hibernation,
|
||||||
|
emqx_overload_protection_gc,
|
||||||
|
emqx_overload_protection_new_conn
|
||||||
|
];
|
||||||
|
false ->
|
||||||
|
[]
|
||||||
|
end.
|
||||||
|
|
||||||
|
is_olp_enabled() ->
|
||||||
|
maps:fold(
|
||||||
|
fun
|
||||||
|
(_, #{overload_protection := #{enable := true}}, _Acc) -> true;
|
||||||
|
(_, _, Acc) -> Acc
|
||||||
|
end,
|
||||||
|
false,
|
||||||
|
emqx_conf:get([zones], #{})
|
||||||
|
).
|
||||||
|
|
||||||
emqx_metrics_messages() ->
|
emqx_metrics_messages() ->
|
||||||
[
|
[
|
||||||
emqx_messages_received,
|
emqx_messages_received,
|
||||||
|
|
Loading…
Reference in New Issue