统计指标

GET /api/v4/metrics

返回集群下所有统计指标数据。

Path Parameters:

Success Response Body (JSON):

NameTypeDescription
codeInteger0
dataArray of Objects各节点上的统计指标列表
data[0].nodeString节点名称
data[0].metricsObject监控指标数据,详见下面的 metrics:

metrics:

NameTypeDescription
actions.failureInteger规则引擎 action 成功失败次数
actions.successInteger规则引擎 action 执行失败次数
bytes.receivedIntegerEMQ X 接收的字节数
bytes.sentIntegerEMQ X 在此连接上发送的字节数
client.authenticateInteger客户端认证次数
client.auth.anonymousInteger匿名登录的客户端数量
client.connectInteger客户端连接次数
client.connackInteger发送 CONNACK 报文的次数
client.connectedInteger客户端成功连接次数
client.disconnectedInteger客户端断开连接次数
client.check_aclIntegerACL 规则检查次数
client.subscribeInteger客户端订阅次数
client.unsubscribeInteger客户端取消订阅次数
delivery.dropped.too_largeInteger发送时由于长度超过限制而被丢弃的消息数量
delivery.dropped.queue_fullInteger发送时由于消息队列满而被丢弃的 QoS 不为 0 的消息数量
delivery.dropped.qos0_msgInteger发送时由于消息队列满而被丢弃的 QoS 为 0 的消息数量
delivery.dropped.expiredInteger发送时由于消息过期而被丢弃的消息数量
delivery.dropped.no_localInteger发送时由于 No Local 订阅选项而被丢弃的消息数量
delivery.droppedInteger发送时丢弃的消息总数
messages.delayedIntegerEMQ X 存储的延迟发布的消息数量
messages.deliveredIntegerEMQ X 内部转发到订阅进程的消息数量
messages.droppedIntegerEMQ X 内部转发到订阅进程前丢弃的消息总数
messages.dropped.expiredInteger接收时由于消息过期而被丢弃的消息数量
messages.dropped.no_subscribersInteger由于没有订阅者而被丢弃的消息数量
messages.forwardInteger向其他节点转发的消息数量
messages.publishInteger除系统消息外发布的消息数量
messages.qos0.receivedInteger接收来自客户端的 QoS 0 消息数量
messages.qos2.receivedInteger接收来自客户端的 QoS 1 消息数量
messages.qos1.receivedInteger接收来自客户端的 QoS 2 消息数量
messages.qos0.sentInteger发送给客户端的 QoS 0 消息数量
messages.qos1.sentInteger发送给客户端的 QoS 1 消息数量
messages.qos2.sentInteger发送给客户端的 QoS 2 消息数量
messages.receivedInteger接收来自客户端的消息数量,等于 messages.qos0.receivedmessages.qos1.receivedmessages.qos2.received 之和
messages.sentInteger发送给客户端的消息数量,等于 messages.qos0.sentmessages.qos1.sentmessages.qos2.sent 之和
messages.retainedIntegerEMQ X 存储的保留消息数量
messages.ackedInteger接收的 PUBACK 和 PUBREC 报文数量
packets.receivedInteger接收的报文数量
packets.sentInteger发送的报文数量
packets.connect.receivedInteger接收的 CONNECT 报文数量
packets.connack.auth_errorInteger接收的认证失败的 CONNECT 报文数量
packets.connack.errorInteger接收的未成功连接的 CONNECT 报文数量
packets.connack.sentInteger发送的 CONNACK 报文数量
packets.publish.receivedInteger接收的 PUBLISH 报文数量
packets.publish.sentInteger发送的 PUBLISH 报文数量
packets.publish.inuseInteger接收的报文标识符已被占用的 PUBLISH 报文数量
packets.publish.auth_errorInteger接收的未通过 ACL 检查的 PUBLISH 报文数量
packets.publish.errorInteger接收的无法被发布的 PUBLISH 报文数量
packets.publish.droppedInteger超出接收限制而被丢弃的消息数量
packets.puback.receivedInteger接收的 PUBACK 报文数量
packets.puback.sentInteger发送的 PUBACK 报文数量
packets.puback.inuseInteger接收的报文标识符已被占用的 PUBACK 报文数量
packets.puback.missedInteger接收的未知报文标识符 PUBACK 报文数量
packets.pubrec.receivedInteger接收的 PUBREC 报文数量
packets.pubrec.sentInteger发送的 PUBREC 报文数量
packets.pubrec.inuseInteger接收的报文标识符已被占用的 PUBREC 报文数量
packets.pubrec.missedInteger接收的未知报文标识符 PUBREC 报文数量
packets.pubrel.receivedInteger接收的 PUBREL 报文数量
packets.pubrel.sentInteger发送的 PUBREL 报文数量
packets.pubrel.missedInteger接收的未知报文标识符 PUBREL 报文数量
packets.pubcomp.receivedInteger接收的 PUBCOMP 报文数量
packets.pubcomp.sentInteger发送的 PUBCOMP 报文数量
packets.pubcomp.inuseInteger接收的报文标识符已被占用的 PUBCOMP 报文数量
packets.pubcomp.missedInteger发送的 PUBCOMP 报文数量
packets.subscribe.receivedInteger接收的 SUBSCRIBE 报文数量
packets.subscribe.errorInteger接收的订阅失败的 SUBSCRIBE 报文数量
packets.subscribe.auth_errorInteger接收的未通过 ACL 检查的 SUBACK 报文数量
packets.suback.sentInteger发送的 SUBACK 报文数量
packets.unsubscribe.receivedInteger接收的 UNSUBSCRIBE 报文数量
packets.unsubscribe.errorInteger接收的取消订阅失败的 UNSUBSCRIBE 报文数量
packets.unsuback.sentInteger发送的 UNSUBACK 报文数量
packets.pingreq.receivedInteger接收的 PINGREQ 报文数量
packets.pingresp.sentInteger发送的 PUBRESP 报文数量
packets.disconnect.receivedInteger接收的 DISCONNECT 报文数量
packets.disconnect.sentInteger发送的 DISCONNECT 报文数量
packets.auth.receivedInteger接收的 AUTH 报文数量
packets.auth.sentInteger发送的 AUTH 报文数量
rules.matchedInteger规则的匹配次数
session.createdInteger创建的会话数量
session.discardedInteger由于 Clean SessionClean Starttrue 而被丢弃的会话数量
session.resumedInteger由于 Clean SessionClean Startfalse 而恢复的会话数量
session.takeoveredInteger由于 Clean SessionClean Startfalse 而被接管的会话数量
session.terminatedInteger终结的会话数量

Examples:

  1. $ curl -i --basic -u admin:public -X GET "http://localhost:8081/api/v4/metrics"
  2. {"data":[{"node":"emqx@127.0.0.1","metrics":{"messages.dropped.no_subscribers":0,"packets.connack.sent":13,"bytes.received":805,"messages.received":0,"packets.unsuback.sent":0,"messages.delivered":0,"client.disconnected":0,"packets.puback.sent":0,"packets.subscribe.auth_error":0,"delivery.dropped.queue_full":0,"messages.forward":0,"delivery.dropped.qos0_msg":0,"delivery.dropped.expired":0,"bytes.sent":52,"messages.sent":0,"delivery.dropped.no_local":0,"packets.pubrec.received":0,"packets.pubcomp.received":0,"client.check_acl":0,"packets.puback.received":0,"session.takeovered":0,"messages.dropped.expired":0,"actions.success":0,"messages.qos1.sent":0,"messages.retained":0,"packets.pubcomp.inuse":0,"packets.pubrec.sent":0,"packets.received":13,"messages.acked":0,"session.terminated":0,"packets.sent":13,"packets.unsubscribe.error":0,"client.connect":13,"packets.pubrec.missed":0,"packets.auth.sent":0,"packets.disconnect.received":0,"messages.qos2.sent":0,"client.auth.anonymous":13,"packets.auth.received":0,"packets.unsubscribe.received":0,"packets.publish.auth_error":0,"client.connected":13,"rules.matched":0,"packets.disconnect.sent":0,"session.created":13,"packets.pingreq.received":0,"messages.dropped":0,"actions.failure":0,"packets.publish.sent":0,"session.resumed":0,"packets.connack.auth_error":0,"packets.pubrel.sent":0,"delivery.dropped":0,"packets.pubcomp.sent":0,"messages.qos2.received":0,"messages.qos0.received":0,"packets.publish.inuse":0,"client.unsubscribe":0,"packets.pubrel.received":0,"client.connack":13,"packets.connack.error":0,"packets.publish.dropped":0,"packets.publish.received":0,"client.subscribe":0,"packets.subscribe.error":0,"packets.suback.sent":0,"packets.pubcomp.missed":0,"messages.qos1.received":0,"delivery.dropped.too_large":0,"packets.pingresp.sent":0,"packets.pubrel.missed":0,"messages.qos0.sent":0,"packets.connect.received":13,"packets.puback.missed":0,"packets.subscribe.received":0,"packets.puback.inuse":0,"client.authenticate":13,"messages.publish":0,"packets.pubrec.inuse":0,"packets.publish.error":0,"messages.delayed":0,"session.discarded":0}}],"code":0}

GET /api/v4/nodes/{node}/metrics

类似 GET /api/v4/metrics,返回指定节点下所有监控指标数据。

Path Parameters:

Success Response Body (JSON):

NameTypeDescription
codeInteger0
dataObjects各节点上的统计指标列表,详见 GET /api/v4/metrics

Examples:

  1. $ curl -i --basic -u admin:public -X GET "http://localhost:8081/api/v4/nodes/emqx@127.0.0.1/metrics"
  2. {"data":{"bytes.received":0,"client.connected":0,"packets.pingreq.received":0,"messages.delayed":0,"rules.matched":0,"actions.failure":0,"packets.puback.sent":0,"packets.pingresp.sent":0,"packets.publish.auth_error":0,"client.check_acl":0,"delivery.dropped.queue_full":0,"actions.success":0,"packets.publish.error":0,"packets.pubcomp.received":0,"bytes.sent":0,"packets.pubrec.inuse":0,"packets.pubrec.missed":0,"packets.pubrel.sent":0,"delivery.dropped.too_large":0,"packets.pubcomp.missed":0,"packets.subscribe.error":0,"packets.suback.sent":0,"messages.qos2.sent":0,"messages.qos1.sent":0,"packets.pubrel.missed":0,"messages.publish":0,"messages.forward":0,"packets.auth.received":0,"delivery.dropped":0,"packets.sent":0,"packets.puback.inuse":0,"delivery.dropped.qos0_msg":0,"packets.publish.dropped":0,"packets.disconnect.sent":0,"packets.auth.sent":0,"packets.unsubscribe.received":0,"session.takeovered":0,"messages.delivered":0,"client.auth.anonymous":0,"packets.connack.error":0,"packets.connack.sent":0,"packets.subscribe.auth_error":0,"packets.unsuback.sent":0,"packets.pubcomp.sent":0,"packets.publish.sent":0,"client.connack":0,"packets.publish.received":0,"client.subscribe":0,"session.created":0,"delivery.dropped.expired":0,"client.unsubscribe":0,"packets.received":0,"packets.pubrel.received":0,"packets.unsubscribe.error":0,"messages.qos0.sent":0,"packets.connack.auth_error":0,"session.resumed":0,"delivery.dropped.no_local":0,"packets.puback.missed":0,"packets.pubcomp.inuse":0,"packets.pubrec.sent":0,"messages.dropped.expired":0,"messages.dropped.no_subscribers":0,"session.discarded":0,"messages.sent":0,"messages.received":0,"packets.puback.received":0,"messages.qos0.received":0,"messages.acked":0,"client.connect":0,"packets.disconnect.received":0,"client.disconnected":0,"messages.retained":3,"session.terminated":0,"packets.publish.inuse":0,"packets.pubrec.received":0,"messages.qos2.received":0,"messages.dropped":0,"packets.connect.received":0,"client.authenticate":0,"packets.subscribe.received":0,"messages.qos1.received":0},"code":0}