Skip to content

指标 API

本页 API 文档提供了与查看部署统计指标相关的操作信息。

统计指标

URI

GET /metrics

请求消息

响应消息

名称类型描述
codeInteger0
dataArray of Objects各节点上的统计指标列表
data[].nodeString节点名称
data[].metricsObject监控指标数据,详细说明见下表 metrics:

metrics:

名称类型描述
actions.failureInteger数据集成 action 成功失败次数
actions.successInteger数据集成 action 执行失败次数
bytes.receivedIntegerEMQX 接收的字节数
bytes.sentIntegerEMQX 在此连接上发送的字节数
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.delayedIntegerEMQX 存储的延迟发布的消息数量
messages.deliveredIntegerEMQX 内部转发到订阅进程的消息数量
messages.droppedIntegerEMQX 内部转发到订阅进程前丢弃的消息总数
messages.dropped.expiredInteger接收时由于消息过期而被丢弃的消息数量
messages.dropped.no_subscribersInteger由于没有订阅者而被丢弃的消息数量
messages.forwardInteger向其他节点转发的消息数量
messages.publishInteger除系统消息外发布的消息数量
messages.qos0.receivedInteger接收来自客户端的 QoS 0 消息数量
messages.qos1.receivedInteger接收来自客户端的 QoS 1 消息数量
messages.qos2.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.retainedIntegerEMQX 存储的保留消息数量
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终结的会话数量

请求示例

bash
$ curl -u app_id:app_secret -X GET {api}/metrics

响应示例

JSON
{
  "data": [
    {
      "node": "emqx@10.12.50.91",
      "metrics": {
        "actions.error": 0,
        "messages.qos1.received": 0,
        "client.disconnected": 9,
        "client.subscribe": 15,
        "packets.pingreq.received": 0,
        "packets.publish.dropped": 0,
        "delivery.dropped": 0,
        "packets.pubrel.received": 0,
        "actions.retry": 0,
        "packets.pubcomp.missed": 0,
        "delivery.dropped.qos0_msg": 0,
        "delivery.dropped.queue_full": 0,
        "client.connack": 11,
        "messages.delayed": 0,
        "packets.sent": 311,
        "actions.success": 0,
        "messages.retained": 5,
        "packets.pubcomp.inuse": 0,
        "session.resumed": 0,
        "messages.qos0.sent": 5,
        "session.terminated": 9,
        "bytes.sent": 824,
        "packets.connect.received": 11,
        "packets.pubrec.received": 0,
        "client.authenticate": 11,
        "packets.pubrec.missed": 0,
        "packets.unsuback.sent": 1,
        "packets.pubrel.sent": 0,
        "messages.delivered": 5,
        "messages.qos2.received": 0,
        "messages.received": 4,
        "messages.qos1.sent": 0,
        "packets.subscribe.received": 15,
        "messages.dropped": 0,
        "client.acl.ignore": 17,
        "packets.connack.error": 1,
        "packets.auth.received": 0,
        "session.takeovered": 0,
        "client.auth.anonymous": 0,
        "packets.auth.sent": 0,
        "packets.unsubscribe.received": 1,
        "delivery.dropped.no_local": 0,
        "messages.acked": 0,
        "packets.pingresp.sent": 279,
        "messages.qos0.received": 4,
        "delivery.dropped.too_large": 0,
        "actions.exception": 0,
        "actions.taken": 0,
        "packets.disconnect.sent": 0,
        "packets.disconnect.received": 7,
        "packets.pubrec.inuse": 0,
        "client.connected": 10,
        "client.acl.deny": 0,
        "packets.publish.error": 0,
        "messages.sent": 5,
        "messages.publish": 4,
        "client.unsubscribe": 1,
        "packets.pubrel.missed": 0,
        "packets.received": 38,
        "bytes.received": 1448,
        "packets.subscribe.error": 0,
        "messages.qos2.sent": 0,
        "client.auth.failure": 1,
        "packets.publish.auth_error": 0,
        "client.auth.success": 10,
        "delivery.dropped.expired": 0,
        "rules.matched": 0,
        "client.acl.allow": 0,
        "packets.unsubscribe.error": 0,
        "client.connect": 11,
        "packets.pubcomp.sent": 0,
        "packets.puback.received": 0,
        "packets.pubcomp.received": 0,
        "session.created": 10,
        "packets.connack.sent": 11,
        "packets.puback.missed": 0,
        "messages.dropped.expired": 0,
        "messages.dropped.no_subscribers": 0,
        "packets.publish.sent": 5,
        "packets.suback.sent": 15,
        "packets.pubrec.sent": 0,
        "packets.puback.sent": 0,
        "packets.publish.inuse": 0,
        "packets.connack.auth_error": 0,
        "messages.forward": 2,
        "session.discarded": 0,
        "packets.puback.inuse": 0,
        "packets.publish.received": 4,
        "client.check_acl": 17,
        "client.auth.ignore": 0,
        "packets.subscribe.auth_error": 0
      }
    },
    {
      "node": "emqx@10.12.50.36",
      "metrics": {
        "actions.error": 0,
        "messages.qos1.received": 0,
        "client.disconnected": 3,
        "client.subscribe": 2,
        "packets.pingreq.received": 0,
        "packets.publish.dropped": 0,
        "delivery.dropped": 0,
        "packets.pubrel.received": 0,
        "actions.retry": 0,
        "packets.pubcomp.missed": 0,
        "delivery.dropped.qos0_msg": 0,
        "delivery.dropped.queue_full": 0,
        "client.connack": 3,
        "messages.delayed": 0,
        "packets.sent": 55,
        "actions.success": 0,
        "messages.retained": 5,
        "packets.pubcomp.inuse": 0,
        "session.resumed": 0,
        "messages.qos0.sent": 2,
        "session.terminated": 3,
        "bytes.sent": 188,
        "packets.connect.received": 3,
        "packets.pubrec.received": 0,
        "client.authenticate": 3,
        "packets.pubrec.missed": 0,
        "packets.unsuback.sent": 0,
        "packets.pubrel.sent": 0,
        "messages.delivered": 2,
        "messages.qos2.received": 0,
        "messages.received": 2,
        "messages.qos1.sent": 0,
        "packets.subscribe.received": 2,
        "messages.dropped": 1,
        "client.acl.ignore": 2,
        "packets.connack.error": 0,
        "packets.auth.received": 0,
        "session.takeovered": 0,
        "client.auth.anonymous": 0,
        "packets.auth.sent": 0,
        "packets.unsubscribe.received": 0,
        "delivery.dropped.no_local": 0,
        "messages.acked": 0,
        "packets.pingresp.sent": 48,
        "messages.qos0.received": 2,
        "delivery.dropped.too_large": 0,
        "actions.exception": 0,
        "actions.taken": 0,
        "packets.disconnect.sent": 0,
        "packets.disconnect.received": 2,
        "packets.pubrec.inuse": 0,
        "client.connected": 3,
        "client.acl.deny": 0,
        "packets.publish.error": 0,
        "messages.sent": 2,
        "messages.publish": 2,
        "client.unsubscribe": 0,
        "packets.pubrel.missed": 0,
        "packets.received": 7,
        "bytes.received": 249,
        "packets.subscribe.error": 0,
        "messages.qos2.sent": 0,
        "client.auth.failure": 0,
        "packets.publish.auth_error": 0,
        "client.auth.success": 3,
        "delivery.dropped.expired": 0,
        "rules.matched": 0,
        "client.acl.allow": 0,
        "packets.unsubscribe.error": 0,
        "client.connect": 3,
        "packets.pubcomp.sent": 0,
        "packets.puback.received": 0,
        "packets.pubcomp.received": 0,
        "session.created": 3,
        "packets.connack.sent": 3,
        "packets.puback.missed": 0,
        "messages.dropped.expired": 0,
        "messages.dropped.no_subscribers": 1,
        "packets.publish.sent": 2,
        "packets.suback.sent": 2,
        "packets.pubrec.sent": 0,
        "packets.puback.sent": 0,
        "packets.publish.inuse": 0,
        "packets.connack.auth_error": 0,
        "messages.forward": 1,
        "session.discarded": 0,
        "packets.puback.inuse": 0,
        "packets.publish.received": 0,
        "client.check_acl": 2,
        "client.auth.ignore": 0,
        "packets.subscribe.auth_error": 0
      }
    }
  ],
  "code": 0
}