diff --git a/apps/emqx/include/emqx_metrics.hrl b/apps/emqx/include/emqx_metrics.hrl new file mode 100644 index 000000000..ddb537e6c --- /dev/null +++ b/apps/emqx/include/emqx_metrics.hrl @@ -0,0 +1,258 @@ +%%-------------------------------------------------------------------- +%% Copyright (c) 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. +%%-------------------------------------------------------------------- + +-ifndef(EMQX_METRICS_HRL). +-define(EMQX_METRICS_HRL, true). + +%% Bytes sent and received +-define(BYTES_METRICS, [ + {counter, 'bytes.received', <<"Number of bytes received ">>}, + {counter, 'bytes.sent', <<"Number of bytes sent on this connection">>} +]). + +%% Packets sent and received +-define(PACKET_METRICS, [ + {counter, 'packets.received', <<"Number of received packet">>}, + {counter, 'packets.sent', <<"Number of sent packet">>}, + {counter, 'packets.connect.received', <<"Number of received CONNECT packet">>}, + {counter, 'packets.connack.sent', <<"Number of sent CONNACK packet">>}, + {counter, 'packets.connack.error', + <<"Number of received CONNECT packet with unsuccessful connections">>}, + {counter, 'packets.connack.auth_error', + <<"Number of received CONNECT packet with failed Authentication">>}, + {counter, 'packets.publish.received', <<"Number of received PUBLISH packet">>}, + %% PUBLISH packets sent + {counter, 'packets.publish.sent', <<"Number of sent PUBLISH packet">>}, + %% PUBLISH packet_id inuse + {counter, 'packets.publish.inuse', + <<"Number of received PUBLISH packet with occupied identifiers">>}, + %% PUBLISH failed for error + {counter, 'packets.publish.error', + <<"Number of received PUBLISH packet that cannot be published">>}, + %% PUBLISH failed for auth error + {counter, 'packets.publish.auth_error', + <<"Number of received PUBLISH packets with failed the Authorization check">>}, + %% PUBLISH(QoS2) packets dropped + {counter, 'packets.publish.dropped', + <<"Number of messages discarded due to the receiving limit">>}, + %% PUBACK packets received + {counter, 'packets.puback.received', <<"Number of received PUBACK packet">>}, + %% PUBACK packets sent + {counter, 'packets.puback.sent', <<"Number of sent PUBACK packet">>}, + %% PUBACK packet_id inuse + {counter, 'packets.puback.inuse', + <<"Number of received PUBACK packet with occupied identifiers">>}, + %% PUBACK packets missed + {counter, 'packets.puback.missed', <<"Number of received packet with identifiers.">>}, + %% PUBREC packets received + {counter, 'packets.pubrec.received', <<"Number of received PUBREC packet">>}, + %% PUBREC packets sent + {counter, 'packets.pubrec.sent', <<"Number of sent PUBREC packet">>}, + %% PUBREC packet_id inuse + {counter, 'packets.pubrec.inuse', + <<"Number of received PUBREC packet with occupied identifiers">>}, + %% PUBREC packets missed + {counter, 'packets.pubrec.missed', + <<"Number of received PUBREC packet with unknown identifiers">>}, + %% PUBREL packets received + {counter, 'packets.pubrel.received', <<"Number of received PUBREL packet">>}, + %% PUBREL packets sent + {counter, 'packets.pubrel.sent', <<"Number of sent PUBREL packet">>}, + %% PUBREL packets missed + {counter, 'packets.pubrel.missed', + <<"Number of received PUBREC packet with unknown identifiers">>}, + %% PUBCOMP packets received + {counter, 'packets.pubcomp.received', <<"Number of received PUBCOMP packet">>}, + %% PUBCOMP packets sent + {counter, 'packets.pubcomp.sent', <<"Number of sent PUBCOMP packet">>}, + %% PUBCOMP packet_id inuse + {counter, 'packets.pubcomp.inuse', + <<"Number of received PUBCOMP packet with occupied identifiers">>}, + %% PUBCOMP packets missed + {counter, 'packets.pubcomp.missed', <<"Number of missed PUBCOMP packet">>}, + %% SUBSCRIBE Packets received + {counter, 'packets.subscribe.received', <<"Number of received SUBSCRIBE packet">>}, + %% SUBSCRIBE error + {counter, 'packets.subscribe.error', + <<"Number of received SUBSCRIBE packet with failed subscriptions">>}, + %% SUBSCRIBE failed for not auth + {counter, 'packets.subscribe.auth_error', + <<"Number of received SUBACK packet with failed Authorization check">>}, + %% SUBACK packets sent + {counter, 'packets.suback.sent', <<"Number of sent SUBACK packet">>}, + %% UNSUBSCRIBE Packets received + {counter, 'packets.unsubscribe.received', <<"Number of received UNSUBSCRIBE packet">>}, + %% UNSUBSCRIBE error + {counter, 'packets.unsubscribe.error', + <<"Number of received UNSUBSCRIBE packet with failed unsubscriptions">>}, + %% UNSUBACK Packets sent + {counter, 'packets.unsuback.sent', <<"Number of sent UNSUBACK packet">>}, + %% PINGREQ packets received + {counter, 'packets.pingreq.received', <<"Number of received PINGREQ packet">>}, + %% PINGRESP Packets sent + {counter, 'packets.pingresp.sent', <<"Number of sent PUBRESP packet">>}, + %% DISCONNECT Packets received + {counter, 'packets.disconnect.received', <<"Number of received DISCONNECT packet">>}, + %% DISCONNECT Packets sent + {counter, 'packets.disconnect.sent', <<"Number of sent DISCONNECT packet">>}, + %% Auth Packets received + {counter, 'packets.auth.received', <<"Number of received AUTH packet">>}, + %% Auth Packets sent + {counter, 'packets.auth.sent', <<"Number of sent AUTH packet">>} +]). + +%% Messages sent/received and pubsub +-define(MESSAGE_METRICS, [ + %% All Messages received + {counter, 'messages.received', << + "Number of messages received from the client, equal to the sum of " + "messages.qos0.received\fmessages.qos1.received and messages.qos2.received" + >>}, + %% All Messages sent + {counter, 'messages.sent', << + "Number of messages sent to the client, equal to the sum of " + "messages.qos0.sent\fmessages.qos1.sent and messages.qos2.sent" + >>}, + %% QoS0 Messages received + {counter, 'messages.qos0.received', <<"Number of QoS 0 messages received from clients">>}, + %% QoS0 Messages sent + {counter, 'messages.qos0.sent', <<"Number of QoS 0 messages sent to clients">>}, + %% QoS1 Messages received + {counter, 'messages.qos1.received', <<"Number of QoS 1 messages received from clients">>}, + %% QoS1 Messages sent + {counter, 'messages.qos1.sent', <<"Number of QoS 1 messages sent to clients">>}, + %% QoS2 Messages received + {counter, 'messages.qos2.received', <<"Number of QoS 2 messages received from clients">>}, + %% QoS2 Messages sent + {counter, 'messages.qos2.sent', <<"Number of QoS 2 messages sent to clients">>}, + %% PubSub Metrics + + %% Messages Publish + {counter, 'messages.publish', + <<"Number of messages published in addition to system messages">>}, + %% Messages dropped due to no subscribers + {counter, 'messages.dropped', + <<"Number of messages dropped before forwarding to the subscription process">>}, + %% Messages that failed validations + {counter, 'messages.validation_failed', <<"Number of message validation failed">>}, + %% Messages that passed validations + {counter, 'messages.validation_succeeded', <<"Number of message validation successful">>}, + %% % Messages that failed transformations + {counter, 'messages.transformation_failed', <<"Number fo message transformation failed">>}, + %% % Messages that passed transformations + {counter, 'messages.transformation_succeeded', + <<"Number fo message transformation succeeded">>}, + %% QoS2 Messages expired + {counter, 'messages.dropped.await_pubrel_timeout', + <<"Number of messages dropped due to waiting PUBREL timeout">>}, + %% Messages dropped + {counter, 'messages.dropped.no_subscribers', + <<"Number of messages dropped due to no subscribers">>}, + %% Messages forward + {counter, 'messages.forward', <<"Number of messages forwarded to other nodes">>}, + %% Messages delayed + {counter, 'messages.delayed', <<"Number of delay-published messages">>}, + %% Messages delivered + {counter, 'messages.delivered', + <<"Number of messages forwarded to the subscription process internally">>}, + %% Messages acked + {counter, 'messages.acked', <<"Number of received PUBACK and PUBREC packet">>}, + %% Messages persistently stored + {counter, 'messages.persisted', <<"Number of message persisted">>} +]). + +%% Delivery metrics +-define(DELIVERY_METRICS, [ + %% All Dropped during delivery + {counter, 'delivery.dropped', <<"Total number of discarded messages when sending">>}, + %% Dropped due to no_local + {counter, 'delivery.dropped.no_local', << + "Number of messages that were dropped due to the No Local subscription " + "option when sending" + >>}, + %% Dropped due to message too large + {counter, 'delivery.dropped.too_large', << + "The number of messages that were dropped because the length exceeded " + "the limit when sending" + >>}, + %% Dropped qos0 message + {counter, 'delivery.dropped.qos0_msg', << + "Number of messages with QoS 0 that were dropped because the message " + "queue was full when sending" + >>}, + %% Dropped due to queue full + {counter, 'delivery.dropped.queue_full', << + "Number of messages with a non-zero QoS that were dropped because the " + "message queue was full when sending" + >>}, + %% Dropped due to expired + {counter, 'delivery.dropped.expired', + <<"Number of messages dropped due to message expiration on sending">>} +]). + +%% Client Lifecircle metrics +-define(CLIENT_METRICS, [ + {counter, 'client.connect', <<"Number of client connections">>}, + {counter, 'client.connack', <<"Number of CONNACK packet sent">>}, + {counter, 'client.connected', <<"Number of successful client connected">>}, + {counter, 'client.authenticate', <<"Number of client Authentication">>}, + {counter, 'client.auth.anonymous', <<"Number of clients who log in anonymously">>}, + {counter, 'client.authorize', <<"Number of Authorization rule checks">>}, + {counter, 'client.subscribe', <<"Number of client subscriptions">>}, + {counter, 'client.unsubscribe', <<"Number of client unsubscriptions">>}, + {counter, 'client.disconnected', <<"Number of client disconnects">>} +]). + +%% Session Lifecircle metrics +-define(SESSION_METRICS, [ + {counter, 'session.created', <<"Number of sessions created">>}, + {counter, 'session.resumed', + <<"Number of sessions resumed because Clean Session or Clean Start is false">>}, + {counter, 'session.takenover', + <<"Number of sessions takenover because Clean Session or Clean Start is false">>}, + {counter, 'session.discarded', + <<"Number of sessions dropped because Clean Session or Clean Start is true">>}, + {counter, 'session.terminated', <<"Number of terminated sessions">>} +]). + +%% Statistic metrics for ACL checking +-define(STASTS_ACL_METRICS, [ + {counter, 'authorization.allow', <<"Number of Authorization allow">>}, + {counter, 'authorization.deny', <<"Number of Authorization deny">>}, + {counter, 'authorization.cache_hit', <<"Number of Authorization hits the cache">>}, + {counter, 'authorization.cache_miss', <<"Number of Authorization cache missing">>} +]). + +%% Statistic metrics for auth checking +-define(STASTS_AUTHN_METRICS, [ + {counter, 'authentication.success', <<"Number of successful client Authentication">>}, + {counter, 'authentication.success.anonymous', + <<"Number of successful client Authentication due to anonymous">>}, + {counter, 'authentication.failure', <<"Number of failed client Authentication">>} +]). + +%% Overload protection counters +-define(OLP_METRICS, [ + {counter, 'overload_protection.delay.ok', <<"Number of overload protection delayed">>}, + {counter, 'overload_protection.delay.timeout', + <<"Number of overload protection delay timeout">>}, + {counter, 'overload_protection.hibernation', <<"Number of overload protection hibernation">>}, + {counter, 'overload_protection.gc', <<"Number of overload protection garbage collection">>}, + {counter, 'overload_protection.new_conn', + <<"Number of overload protection close new incoming connection">>} +]). + +-endif. diff --git a/apps/emqx/src/emqx_access_control.erl b/apps/emqx/src/emqx_access_control.erl index e3c730cd5..2d75feea3 100644 --- a/apps/emqx/src/emqx_access_control.erl +++ b/apps/emqx/src/emqx_access_control.erl @@ -238,6 +238,7 @@ inc_authn_metrics(error) -> inc_authn_metrics(ok) -> emqx_metrics:inc('authentication.success'); inc_authn_metrics(anonymous) -> + emqx_metrics:inc('client.auth.anonymous'), emqx_metrics:inc('authentication.success.anonymous'), emqx_metrics:inc('authentication.success'). diff --git a/apps/emqx/src/emqx_metrics.erl b/apps/emqx/src/emqx_metrics.erl index 06d0046ec..9f949633d 100644 --- a/apps/emqx/src/emqx_metrics.erl +++ b/apps/emqx/src/emqx_metrics.erl @@ -22,6 +22,7 @@ -include("logger.hrl"). -include("types.hrl"). -include("emqx_mqtt.hrl"). +-include("emqx_metrics.hrl"). -export([ start_link/0, @@ -86,210 +87,8 @@ -define(TAB, ?MODULE). -define(SERVER, ?MODULE). -%% Bytes sent and received --define(BYTES_METRICS, - % Total bytes received - [ - {counter, 'bytes.received'}, - % Total bytes sent - {counter, 'bytes.sent'} - ] -). - -%% Packets sent and received --define(PACKET_METRICS, - % All Packets received - [ - {counter, 'packets.received'}, - % All Packets sent - {counter, 'packets.sent'}, - % CONNECT Packets received - {counter, 'packets.connect.received'}, - % CONNACK Packets sent - {counter, 'packets.connack.sent'}, - % CONNACK error sent - {counter, 'packets.connack.error'}, - % CONNACK auth_error sent - {counter, 'packets.connack.auth_error'}, - % PUBLISH packets received - {counter, 'packets.publish.received'}, - % PUBLISH packets sent - {counter, 'packets.publish.sent'}, - % PUBLISH packet_id inuse - {counter, 'packets.publish.inuse'}, - % PUBLISH failed for error - {counter, 'packets.publish.error'}, - % PUBLISH failed for auth error - {counter, 'packets.publish.auth_error'}, - % PUBLISH(QoS2) packets dropped - {counter, 'packets.publish.dropped'}, - % PUBACK packets received - {counter, 'packets.puback.received'}, - % PUBACK packets sent - {counter, 'packets.puback.sent'}, - % PUBACK packet_id inuse - {counter, 'packets.puback.inuse'}, - % PUBACK packets missed - {counter, 'packets.puback.missed'}, - % PUBREC packets received - {counter, 'packets.pubrec.received'}, - % PUBREC packets sent - {counter, 'packets.pubrec.sent'}, - % PUBREC packet_id inuse - {counter, 'packets.pubrec.inuse'}, - % PUBREC packets missed - {counter, 'packets.pubrec.missed'}, - % PUBREL packets received - {counter, 'packets.pubrel.received'}, - % PUBREL packets sent - {counter, 'packets.pubrel.sent'}, - % PUBREL packets missed - {counter, 'packets.pubrel.missed'}, - % PUBCOMP packets received - {counter, 'packets.pubcomp.received'}, - % PUBCOMP packets sent - {counter, 'packets.pubcomp.sent'}, - % PUBCOMP packet_id inuse - {counter, 'packets.pubcomp.inuse'}, - % PUBCOMP packets missed - {counter, 'packets.pubcomp.missed'}, - % SUBSCRIBE Packets received - {counter, 'packets.subscribe.received'}, - % SUBSCRIBE error - {counter, 'packets.subscribe.error'}, - % SUBSCRIBE failed for not auth - {counter, 'packets.subscribe.auth_error'}, - % SUBACK packets sent - {counter, 'packets.suback.sent'}, - % UNSUBSCRIBE Packets received - {counter, 'packets.unsubscribe.received'}, - % UNSUBSCRIBE error - {counter, 'packets.unsubscribe.error'}, - % UNSUBACK Packets sent - {counter, 'packets.unsuback.sent'}, - % PINGREQ packets received - {counter, 'packets.pingreq.received'}, - % PINGRESP Packets sent - {counter, 'packets.pingresp.sent'}, - % DISCONNECT Packets received - {counter, 'packets.disconnect.received'}, - % DISCONNECT Packets sent - {counter, 'packets.disconnect.sent'}, - % Auth Packets received - {counter, 'packets.auth.received'}, - % Auth Packets sent - {counter, 'packets.auth.sent'} - ] -). - -%% Messages sent/received and pubsub --define(MESSAGE_METRICS, - % All Messages received - [ - {counter, 'messages.received'}, - % All Messages sent - {counter, 'messages.sent'}, - % QoS0 Messages received - {counter, 'messages.qos0.received'}, - % QoS0 Messages sent - {counter, 'messages.qos0.sent'}, - % QoS1 Messages received - {counter, 'messages.qos1.received'}, - % QoS1 Messages sent - {counter, 'messages.qos1.sent'}, - % QoS2 Messages received - {counter, 'messages.qos2.received'}, - % QoS2 Messages sent - {counter, 'messages.qos2.sent'}, - %% PubSub Metrics - - % Messages Publish - {counter, 'messages.publish'}, - % Messages dropped due to no subscribers - {counter, 'messages.dropped'}, - %% % Messages that failed validations - {counter, 'messages.validation_failed'}, - %% % Messages that passed validations - {counter, 'messages.validation_succeeded'}, - %% % Messages that failed transformations - {counter, 'messages.transformation_failed'}, - %% % Messages that passed transformations - {counter, 'messages.transformation_succeeded'}, - % QoS2 Messages expired - {counter, 'messages.dropped.await_pubrel_timeout'}, - % Messages dropped - {counter, 'messages.dropped.no_subscribers'}, - % Messages forward - {counter, 'messages.forward'}, - % Messages delayed - {counter, 'messages.delayed'}, - % Messages delivered - {counter, 'messages.delivered'}, - % Messages acked - {counter, 'messages.acked'}, - % Messages persistently stored - {counter, 'messages.persisted'} - ] -). - -%% Delivery metrics --define(DELIVERY_METRICS, [ - {counter, 'delivery.dropped'}, - {counter, 'delivery.dropped.no_local'}, - {counter, 'delivery.dropped.too_large'}, - {counter, 'delivery.dropped.qos0_msg'}, - {counter, 'delivery.dropped.queue_full'}, - {counter, 'delivery.dropped.expired'} -]). - -%% Client Lifecircle metrics --define(CLIENT_METRICS, [ - {counter, 'client.connect'}, - {counter, 'client.connack'}, - {counter, 'client.connected'}, - {counter, 'client.authenticate'}, - {counter, 'client.auth.anonymous'}, - {counter, 'client.authorize'}, - {counter, 'client.subscribe'}, - {counter, 'client.unsubscribe'}, - {counter, 'client.disconnected'} -]). - -%% Session Lifecircle metrics --define(SESSION_METRICS, [ - {counter, 'session.created'}, - {counter, 'session.resumed'}, - {counter, 'session.takenover'}, - {counter, 'session.discarded'}, - {counter, 'session.terminated'} -]). - -%% Statistic metrics for ACL checking --define(STASTS_ACL_METRICS, [ - {counter, 'authorization.allow'}, - {counter, 'authorization.deny'}, - {counter, 'authorization.cache_hit'}, - {counter, 'authorization.cache_miss'} -]). - -%% Statistic metrics for auth checking --define(STASTS_AUTHN_METRICS, [ - {counter, 'authentication.success'}, - {counter, 'authentication.success.anonymous'}, - {counter, 'authentication.failure'} -]). - -%% Overload protection counters --define(OLP_METRICS, [ - {counter, 'overload_protection.delay.ok'}, - {counter, 'overload_protection.delay.timeout'}, - {counter, 'overload_protection.hibernation'}, - {counter, 'overload_protection.gc'}, - {counter, 'overload_protection.new_conn'} -]). - olp_metrics() -> - lists:map(fun({_, Metric}) -> Metric end, ?OLP_METRICS). + lists:map(fun({_, Metric, _}) -> Metric end, ?OLP_METRICS). -record(state, {next_idx = 1}). @@ -570,7 +369,7 @@ init([]) -> ]), % Store reserved indices ok = lists:foreach( - fun({Type, Name}) -> + fun({Type, Name, _Desc}) -> Idx = reserved_idx(Name), Metric = #metric{name = Name, type = Type, idx = Idx}, true = ets:insert(?TAB, Metric), @@ -684,11 +483,11 @@ reserved_idx('messages.dropped') -> 109; reserved_idx('messages.dropped.await_pubrel_timeout') -> 110; reserved_idx('messages.dropped.no_subscribers') -> 111; reserved_idx('messages.forward') -> 112; -%%reserved_idx('messages.retained') -> 113; %% keep the index, new metrics can use this +%% reserved_idx('messages.retained') -> 113; %% keep the index, new metrics can use this reserved_idx('messages.delayed') -> 114; reserved_idx('messages.delivered') -> 115; reserved_idx('messages.acked') -> 116; -reserved_idx('delivery.expired') -> 117; +%% reserved_idx('delivery.expired') -> 117; %% have never used reserved_idx('delivery.dropped') -> 118; reserved_idx('delivery.dropped.no_local') -> 119; reserved_idx('delivery.dropped.too_large') -> 120; @@ -699,7 +498,7 @@ reserved_idx('client.connect') -> 200; reserved_idx('client.connack') -> 201; reserved_idx('client.connected') -> 202; reserved_idx('client.authenticate') -> 203; -reserved_idx('client.enhanced_authenticate') -> 204; +%% reserved_idx('client.enhanced_authenticate') -> 204; %% have never used reserved_idx('client.auth.anonymous') -> 205; reserved_idx('client.authorize') -> 206; reserved_idx('client.subscribe') -> 207; diff --git a/apps/emqx_management/src/emqx_mgmt_api_metrics.erl b/apps/emqx_management/src/emqx_mgmt_api_metrics.erl index f2e302569..8d9539978 100644 --- a/apps/emqx_management/src/emqx_mgmt_api_metrics.erl +++ b/apps/emqx_management/src/emqx_mgmt_api_metrics.erl @@ -20,6 +20,7 @@ -include_lib("typerefl/include/types.hrl"). -include_lib("hocon/include/hocon_types.hrl"). +-include_lib("emqx/include/emqx_metrics.hrl"). -import(hoconsc, [mk/2, ref/2]). @@ -112,354 +113,26 @@ fields(node_metrics) -> [{node, mk(binary(), #{desc => <<"Node name">>})}] ++ properties(). properties() -> - [ - m( - 'actions.failure', - <<"Number of failure executions of the rule engine action">> - ), - m( - 'actions.success', - <<"Number of successful executions of the rule engine action">> - ), - m( - 'bytes.received', - <<"Number of bytes received ">> - ), - m( - 'bytes.sent', - <<"Number of bytes sent on this connection">> - ), - m( - 'client.auth.anonymous', - <<"Number of clients who log in anonymously">> - ), - m( - 'client.authenticate', - <<"Number of client authentications">> - ), - m( - 'client.check_authz', - <<"Number of Authorization rule checks">> - ), - m( - 'client.connack', - <<"Number of CONNACK packet sent">> - ), - m( - 'client.connect', - <<"Number of client connections">> - ), - m( - 'client.connected', - <<"Number of successful client connections">> - ), - m( - 'client.disconnected', - <<"Number of client disconnects">> - ), - m( - 'client.subscribe', - <<"Number of client subscriptions">> - ), - m( - 'client.unsubscribe', - <<"Number of client unsubscriptions">> - ), - m( - 'delivery.dropped', - <<"Total number of discarded messages when sending">> - ), - m( - 'delivery.dropped.expired', - <<"Number of messages dropped due to message expiration on sending">> - ), - m( - 'delivery.dropped.no_local', - << - "Number of messages that were dropped due to the No Local subscription " - "option when sending" - >> - ), - m( - 'delivery.dropped.qos0_msg', - << - "Number of messages with QoS 0 that were dropped because the message " - "queue was full when sending" - >> - ), - m( - 'delivery.dropped.queue_full', - << - "Number of messages with a non-zero QoS that were dropped because the " - "message queue was full when sending" - >> - ), - m( - 'delivery.dropped.too_large', - << - "The number of messages that were dropped because the length exceeded " - "the limit when sending" - >> - ), - m( - 'messages.acked', - <<"Number of received PUBACK and PUBREC packet">> - ), - m( - 'messages.delayed', - <<"Number of delay-published messages">> - ), - m( - 'messages.delivered', - <<"Number of messages forwarded to the subscription process internally">> - ), - m( - 'messages.dropped', - <<"Total number of messages dropped before forwarding to the subscription process">> - ), - m( - 'messages.dropped.await_pubrel_timeout', - <<"Number of messages dropped due to waiting PUBREL timeout">> - ), - m( - 'messages.dropped.no_subscribers', - <<"Number of messages dropped due to no subscribers">> - ), - m( - 'messages.forward', - <<"Number of messages forwarded to other nodes">> - ), - m( - 'messages.publish', - <<"Number of messages published in addition to system messages">> - ), - m( - 'messages.qos0.received', - <<"Number of QoS 0 messages received from clients">> - ), - m( - 'messages.qos0.sent', - <<"Number of QoS 0 messages sent to clients">> - ), - m( - 'messages.qos1.received', - <<"Number of QoS 1 messages received from clients">> - ), - m( - 'messages.qos1.sent', - <<"Number of QoS 1 messages sent to clients">> - ), - m( - 'messages.qos2.received', - <<"Number of QoS 2 messages received from clients">> - ), - m( - 'messages.qos2.sent', - <<"Number of QoS 2 messages sent to clients">> - ), - m( - 'messages.received', - << - "Number of messages received from the client, equal to the sum of " - "messages.qos0.received\fmessages.qos1.received and messages.qos2.received" - >> - ), - %% m( - %% 'messages.retained', - %% <<"Number of retained messages">> - %% ), - m( - 'messages.sent', - << - "Number of messages sent to the client, equal to the sum of " - "messages.qos0.sent\fmessages.qos1.sent and messages.qos2.sent" - >> - ), - m( - 'packets.auth.received', - <<"Number of received AUTH packet">> - ), - m( - 'packets.auth.sent', - <<"Number of sent AUTH packet">> - ), - m( - 'packets.connack.auth_error', - <<"Number of received CONNECT packet with failed authentication">> - ), - m( - 'packets.connack.error', - <<"Number of received CONNECT packet with unsuccessful connections">> - ), - m( - 'packets.connack.sent', - <<"Number of sent CONNACK packet">> - ), - m( - 'packets.connect.received', - <<"Number of received CONNECT packet">> - ), - m( - 'packets.disconnect.received', - <<"Number of received DISCONNECT packet">> - ), - m( - 'packets.disconnect.sent', - <<"Number of sent DISCONNECT packet">> - ), - m( - 'packets.pingreq.received', - <<"Number of received PINGREQ packet">> - ), - m( - 'packets.pingresp.sent', - <<"Number of sent PUBRESP packet">> - ), - m( - 'packets.puback.inuse', - <<"Number of received PUBACK packet with occupied identifiers">> - ), - m( - 'packets.puback.missed', - <<"Number of received packet with identifiers.">> - ), - m( - 'packets.puback.received', - <<"Number of received PUBACK packet">> - ), - m( - 'packets.puback.sent', - <<"Number of sent PUBACK packet">> - ), - m( - 'packets.pubcomp.inuse', - <<"Number of received PUBCOMP packet with occupied identifiers">> - ), - m( - 'packets.pubcomp.missed', - <<"Number of missed PUBCOMP packet">> - ), - m( - 'packets.pubcomp.received', - <<"Number of received PUBCOMP packet">> - ), - m( - 'packets.pubcomp.sent', - <<"Number of sent PUBCOMP packet">> - ), - m( - 'packets.publish.auth_error', - <<"Number of received PUBLISH packets with failed the Authorization check">> - ), - m( - 'packets.publish.dropped', - <<"Number of messages discarded due to the receiving limit">> - ), - m( - 'packets.publish.error', - <<"Number of received PUBLISH packet that cannot be published">> - ), - m( - 'packets.publish.inuse', - <<"Number of received PUBLISH packet with occupied identifiers">> - ), - m( - 'packets.publish.received', - <<"Number of received PUBLISH packet">> - ), - m( - 'packets.publish.sent', - <<"Number of sent PUBLISH packet">> - ), - m( - 'packets.pubrec.inuse', - <<"Number of received PUBREC packet with occupied identifiers">> - ), - m( - 'packets.pubrec.missed', - <<"Number of received PUBREC packet with unknown identifiers">> - ), - m( - 'packets.pubrec.received', - <<"Number of received PUBREC packet">> - ), - m( - 'packets.pubrec.sent', - <<"Number of sent PUBREC packet">> - ), - m( - 'packets.pubrel.missed', - <<"Number of received PUBREC packet with unknown identifiers">> - ), - m( - 'packets.pubrel.received', - <<"Number of received PUBREL packet">> - ), - m( - 'packets.pubrel.sent', - <<"Number of sent PUBREL packet">> - ), - m( - 'packets.received', - <<"Number of received packet">> - ), - m( - 'packets.sent', - <<"Number of sent packet">> - ), - m( - 'packets.suback.sent', - <<"Number of sent SUBACK packet">> - ), - m( - 'packets.subscribe.auth_error', - <<"Number of received SUBACK packet with failed Authorization check">> - ), - m( - 'packets.subscribe.error', - <<"Number of received SUBSCRIBE packet with failed subscriptions">> - ), - m( - 'packets.subscribe.received', - <<"Number of received SUBSCRIBE packet">> - ), - m( - 'packets.unsuback.sent', - <<"Number of sent UNSUBACK packet">> - ), - m( - 'packets.unsubscribe.error', - <<"Number of received UNSUBSCRIBE packet with failed unsubscriptions">> - ), - m( - 'packets.unsubscribe.received', - <<"Number of received UNSUBSCRIBE packet">> - ), - m( - 'rules.matched', - <<"Number of rule matched">> - ), - m( - 'session.created', - <<"Number of sessions created">> - ), - m( - 'session.discarded', - <<"Number of sessions dropped because Clean Session or Clean Start is true">> - ), - m( - 'session.resumed', - <<"Number of sessions resumed because Clean Session or Clean Start is false">> - ), - m( - 'session.takenover', - <<"Number of sessions takenover because Clean Session or Clean Start is false">> - ), - m( - 'session.terminated', - <<"Number of terminated sessions">> + Metrics = lists:append([ + ?BYTES_METRICS, + ?PACKET_METRICS, + ?MESSAGE_METRICS, + ?DELIVERY_METRICS, + ?CLIENT_METRICS, + ?SESSION_METRICS, + ?STASTS_ACL_METRICS, + ?STASTS_AUTHN_METRICS, + ?OLP_METRICS + ]), + lists:reverse( + lists:foldl( + fun({_Type, MetricName, Desc}, Acc) -> + [m(MetricName, Desc) | Acc] + end, + [], + Metrics ) - ]. + ). m(K, Desc) -> {K, mk(non_neg_integer(), #{desc => Desc})}.