RabbitMQ消息队列监控API

gh_1af05e953554_258.jpg

RabbitMQ消息队列监控API

请求地址 http://ip:端口号/接口名称

建议监控数据收集间隔为60秒一次
HTTP API URLHTTP请求类型接口含义
/api/connectionsGET获取当前RabbitMQ集群下所有打开的连接
/api/nodesGET获取当前RabbitMQ集群下所有节点实例的状态信息
/api/vhosts/{vhost}/connectionsGET获取某一个虚拟机主机下的所有打开的connection连接
/api/connections/{name}/channelsGET获取某一个连接下所有的管道信息
/api/vhosts/{vhost}/channelsGET获取某一个虚拟机主机下的管道信息
/api/consumers/{vhost}GET获取某一个虚拟机主机下的所有消费者信息
/api/exchanges/{vhost}GET获取某一个虚拟机主机下面的所有交换器信息
/api/queues/{vhost}GET获取某一个虚拟机主机下的所有队列信息
/api/usersGET获取集群中所有的用户信息
/api/users/{name}GET/PUT/DELETE获取/更新/删除指定用户信息
/api/users/{user}/permissionsGET获取当前指定用户的所有权限信息
/api/permissions/{vhost}/{user}GET/PUT/DELETE获取/更新/删除指定虚拟主机下特定用户的权限
/api/exchanges/{vhost}/{name}/publishPOST在指定的虚拟机主机和交换器上发布一个消息
/api/queues/{vhost}/{name}/getPOST测在指定虚拟机主机和队列名中获取消息,同时该动作会修改队列状态试
/api/healthchecks/node/{node}GET获取指定节点的健康检查状态
/api/nodes/{node}/memoryGET获取指定节点的内存使用信息

部分API实例

/api/overview 返回集群度量标准

字段名称意义
cluster_name集群名称
management_version版本
message_stats消息速率
object_totals.connections连接总数
object_totals.channels频道总数
object_totals.queues队列总数
object_totals.consumers消费者总数
queue_totals.messages准备好与未确认的消息总数
queue_totals.messages_ready准备发送的消息数
queue_totals.messages_unacknowledged未确认消息的数量
message_stats.publish`最近发布的消息
message_stats.publish_details.rate消息发布率
message_stats.deliver_get最近发送给消费者的消息
message_stats.deliver_get.rate邮件传递率
message_stats其他消息统计
    {
        "management_version": "3.7.14",
        "rates_mode": "basic",
        "sample_retention_policies": {
            "global": [
                600,
                3600,
                28800,
                86400
            ],
            "basic": [
                600,
                3600
            ],
            "detailed": [
                600
            ]
        },
        "exchange_types": [
            {
                "name": "fanout",
                "description": "AMQP fanout exchange, as per the AMQP specification",
                "enabled": true
            },
            {
                "name": "headers",
                "description": "AMQP headers exchange, as per the AMQP specification",
                "enabled": true
            },
            {
                "name": "x-delayed-message",
                "description": "Delayed Message Exchange.",
                "enabled": true
            },
            {
                "name": "direct",
                "description": "AMQP direct exchange, as per the AMQP specification",
                "enabled": true
            },
            {
                "name": "topic",
                "description": "AMQP topic exchange, as per the AMQP specification",
                "enabled": true
            }
        ],
        "rabbitmq_version": "3.7.14",
        "cluster_name": "rabbit@wangtaodeMacBook-Pro",
        "erlang_version": "21.3.2",
        "erlang_full_version": "Erlang/OTP 21 [erts-10.3.1] [source]
        [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:192]
         [hipe] [dtrace]",
        "message_stats": {
            "disk_reads": 2,
            "disk_reads_details": {
                "rate": 0
            },
            "disk_writes": 0,
            "disk_writes_details": {
                "rate": 0
            }
        },
        "churn_rates": {
            "channel_closed": 0,
            "channel_closed_details": {
                "rate": 0
            },
            "channel_created": 0,
            "channel_created_details": {
                "rate": 0
            },
            "connection_closed": 0,
            "connection_closed_details": {
                "rate": 0
            },
            "connection_created": 0,
            "connection_created_details": {
                "rate": 0
            },
            "queue_created": 0,
            "queue_created_details": {
                "rate": 0
            },
            "queue_declared": 0,
            "queue_declared_details": {
                "rate": 0
            },
            "queue_deleted": 0,
            "queue_deleted_details": {
                "rate": 0
            }
        },
        "queue_totals": {
            "messages": 2,
            "messages_details": {
                "rate": 0
            },
            "messages_ready": 2,
            "messages_ready_details": {
                "rate": 0
            },
            "messages_unacknowledged": 0,
            "messages_unacknowledged_details": {
                "rate": 0
            }
        },
        "object_totals": {
            "channels": 0,
            "connections": 0,
            "consumers": 0,
            "exchanges": 16,
            "queues": 10
        },
        "statistics_db_event_queue": 0,
        "node": "rabbit@localhost",
        "listeners": [
            {
                "node": "rabbit@localhost",
                "protocol": "amqp",
                "ip_address": "127.0.0.1",
                "port": 5672,
                "socket_opts": {
                    "backlog": 128,
                    "nodelay": true,
                    "linger": [
                        true,
                        0
                    ],
                    "exit_on_close": false
                }
            },
            {
                "node": "rabbit@localhost",
                "protocol": "clustering",
                "ip_address": "::",
                "port": 25672,
                "socket_opts": []
            },
            {
                "node": "rabbit@localhost",
                "protocol": "http",
                "ip_address": "::",
                "port": 15672,
                "socket_opts": {
                    "port": 15672
                }
            },
            {
                "node": "rabbit@localhost",
                "protocol": "mqtt",
                "ip_address": "::",
                "port": 1883,
                "socket_opts": {
                    "backlog": 128,
                    "nodelay": true
                }
            },
            {
                "node": "rabbit@localhost",
                "protocol": "stomp",
                "ip_address": "::",
                "port": 61613,
                "socket_opts": {
                    "backlog": 128,
                    "nodelay": true
                }
            }
        ],
        "contexts": [
            {
                "ssl_opts": [],
                "node": "rabbit@localhost",
                "description": "RabbitMQ Management",
                "path": "/",
                "port": "15672"
            }
        ]
    }

/api/nodes 返回所有集群成员统计消息

字段名称意义
mem_used使用的内存总量
mem_limit内存使用率
mem_alarm内存警报开关
disk_free_limit磁盘空间限制大小
disk_free_alarm磁盘空间大小限制开关
fd_total文件描述符限制
fd_used文件描述符是否开始
io_file_handle_open_attempt_countio文件句柄打开尝试计数
sockets_totalsocket数量
sockets_used正在使用的socket数量
message_stats.disk_reads磁盘读取的消息数
message_stats.disk_writes写入磁盘的消息数
cluster_links节点间通信链路
gc_numGC次数
gc_bytes_reclaimedGC回收的字节数
proc_totalErlang进程限制数量
proc_usedErlang进行使用数量
run_queue运行时队列数量
[
    {
        "partitions": [],
        "os_pid": "4470",
        "fd_total": 256,
        "sockets_total": 138,
        "mem_limit": 6871947673,
        "mem_alarm": false,
        "disk_free_limit": 50000000,
        "disk_free_alarm": false,
        "proc_total": 1048576,
        "rates_mode": "basic",
        "uptime": 4176419,
        "run_queue": 1,
        "processors": 12,
        "exchange_types": [
            {
                "name": "fanout",
                "description": "AMQP fanout exchange, as per the AMQP specification",
                "enabled": true
            },
            {
                "name": "headers",
                "description": "AMQP headers exchange, as per the AMQP specification",
                "enabled": true
            },
            {
                "name": "x-delayed-message",
                "description": "Delayed Message Exchange.",
                "enabled": true
            },
            {
                "name": "direct",
                "description": "AMQP direct exchange, as per the AMQP specification",
                "enabled": true
            },
            {
                "name": "topic",
                "description": "AMQP topic exchange, as per the AMQP specification",
                "enabled": true
            }
        ],
        "auth_mechanisms": [
            {
                "name": "RABBIT-CR-DEMO",
                "description": "RabbitMQ Demo challenge-response authentication mechanism",
                "enabled": false
            },
            {
                "name": "AMQPLAIN",
                "description": "QPid AMQPLAIN mechanism",
                "enabled": true
            },
            {
                "name": "PLAIN",
                "description": "SASL PLAIN authentication mechanism",
                "enabled": true
            }
        ],
        "applications": [
            {
                "name": "amqp10_common",
                "description": "Modules shared by rabbitmq-amqp1.0 
                and rabbitmq-amqp1.0-client",
                "version": "3.7.14"
            },
            {
                "name": "amqp_client",
                "description": "RabbitMQ AMQP Client",
                "version": "3.7.14"
            },
            {
                "name": "asn1",
                "description": "The Erlang ASN1 compiler version 5.0.8",
                "version": "5.0.8"
            },
            {
                "name": "compiler",
                "description": "ERTS  CXC 138 10",
                "version": "7.3.2"
            },
            {
                "name": "cowboy",
                "description": "Small, fast, modern HTTP server.",
                "version": "2.6.1"
            },
            {
                "name": "cowlib",
                "description": "Support library for manipulating Web protocols.",
                "version": "2.7.0"
            },
            {
                "name": "crypto",
                "description": "CRYPTO",
                "version": "4.4.1"
            },
            {
                "name": "goldrush",
                "description": "Erlang event stream processor",
                "version": "0.1.9"
            },
            {
                "name": "inets",
                "description": "INETS  CXC 138 49",
                "version": "7.0.6"
            },
            {
                "name": "jsx",
                "description": "a streaming, evented json parsing toolkit",
                "version": "2.9.0"
            },
            {
                "name": "kernel",
                "description": "ERTS  CXC 138 10",
                "version": "6.3"
            },
            {
                "name": "lager",
                "description": "Erlang logging framework",
                "version": "3.6.9"
            },
            {
                "name": "mnesia",
                "description": "MNESIA  CXC 138 12",
                "version": "4.15.6"
            },
            {
                "name": "os_mon",
                "description": "CPO  CXC 138 46",
                "version": "2.4.7"
            },
            {
                "name": "public_key",
                "description": "Public key infrastructure",
                "version": "1.6.5"
            },
            {
                "name": "rabbit",
                "description": "RabbitMQ",
                "version": "3.7.14"
            },
            {
                "name": "rabbit_common",
                "description": "Modules shared by rabbitmq-server 
                and rabbitmq-erlang-client",
                "version": "3.7.14"
            },
            {
                "name": "rabbitmq_amqp1_0",
                "description": "AMQP 1.0 support for RabbitMQ",
                "version": "3.7.14"
            },
            {
                "name": "rabbitmq_delayed_message_exchange",
                "description": "RabbitMQ Delayed Message Exchange",
                "version": "20171201-3.7.x"
            },
            {
                "name": "rabbitmq_management",
                "description": "RabbitMQ Management Console",
                "version": "3.7.14"
            },
            {
                "name": "rabbitmq_management_agent",
                "description": "RabbitMQ Management Agent",
                "version": "3.7.14"
            },
            {
                "name": "rabbitmq_mqtt",
                "description": "RabbitMQ MQTT Adapter",
                "version": "3.7.14"
            },
            {
                "name": "rabbitmq_stomp",
                "description": "RabbitMQ STOMP plugin",
                "version": "3.7.14"
            },
            {
                "name": "rabbitmq_web_dispatch",
                "description": "RabbitMQ Web Dispatcher",
                "version": "3.7.14"
            },
            {
                "name": "ranch",
                "description": "Socket acceptor pool for TCP protocols.",
                "version": "1.7.1"
            },
            {
                "name": "recon",
                "description": "Diagnostic tools for production use",
                "version": "2.4.0"
            },
            {
                "name": "sasl",
                "description": "SASL  CXC 138 11",
                "version": "3.3"
            },
            {
                "name": "ssl",
                "description": "Erlang/OTP SSL application",
                "version": "9.2.1"
            },
            {
                "name": "stdlib",
                "description": "ERTS  CXC 138 10",
                "version": "3.8"
            },
            {
                "name": "syntax_tools",
                "description": "Syntax tools",
                "version": "2.1.7"
            },
            {
                "name": "sysmon_handler",
                "description": "Rate-limiting system_monitor event handler",
                "version": "1.1.0"
            },
            {
                "name": "xmerl",
                "description": "XML parser",
                "version": "1.3.20"
            }
        ],
        "contexts": [
            {
                "description": "RabbitMQ Management",
                "path": "/",
                "port": "15672"
            }
        ],
        "log_files": [
            "/usr/local/var/log/rabbitmq/rabbit@localhost.log",
            "/usr/local/var/log/rabbitmq/rabbit@localhost_upgrade.log"
        ],
        "db_dir": "/usr/local/var/lib/rabbitmq/mnesia/rabbit@localhost",
        "config_files": [],
        "net_ticktime": 60,
        "enabled_plugins": [
            "rabbitmq_amqp1_0",
            "rabbitmq_delayed_message_exchange",
            "rabbitmq_management",
            "rabbitmq_mqtt",
            "rabbitmq_stomp"
        ],
        "mem_calculation_strategy": "rss",
        "name": "rabbit@localhost",
        "type": "disc",
        "running": true,
        "mem_used": 86556672,
        "mem_used_details": {
            "rate": 4096
        },
        "fd_used": 72,
        "fd_used_details": {
            "rate": -0.4
        },
        "sockets_used": 0,
        "sockets_used_details": {
            "rate": 0
        },
        "proc_used": 457,
        "proc_used_details": {
            "rate": 0
        },
        "disk_free": 172579655680,
        "disk_free_details": {
            "rate": -15564.8
        },
        "gc_num": 22686,
        "gc_num_details": {
            "rate": 4.6
        },
        "gc_bytes_reclaimed": 1060411720,
        "gc_bytes_reclaimed_details": {
            "rate": 158604.8
        },
        "context_switches": 307064,
        "context_switches_details": {
            "rate": 37.4
        },
        "io_read_count": 22,
        "io_read_count_details": {
            "rate": 0
        },
        "io_read_bytes": 2083,
        "io_read_bytes_details": {
            "rate": 0
        },
        "io_read_avg_time": 0.02909090909090909,
        "io_read_avg_time_details": {
            "rate": 0
        },
        "io_write_count": 0,
        "io_write_count_details": {
            "rate": 0
        },
        "io_write_bytes": 0,
        "io_write_bytes_details": {
            "rate": 0
        },
        "io_write_avg_time": 0,
        "io_write_avg_time_details": {
            "rate": 0
        },
        "io_sync_count": 0,
        "io_sync_count_details": {
            "rate": 0
        },
        "io_sync_avg_time": 0,
        "io_sync_avg_time_details": {
            "rate": 0
        },
        "io_seek_count": 0,
        "io_seek_count_details": {
            "rate": 0
        },
        "io_seek_avg_time": 0,
        "io_seek_avg_time_details": {
            "rate": 0
        },
        "io_reopen_count": 0,
        "io_reopen_count_details": {
            "rate": 0
        },
        "mnesia_ram_tx_count": 60,
        "mnesia_ram_tx_count_details": {
            "rate": 0
        },
        "mnesia_disk_tx_count": 10,
        "mnesia_disk_tx_count_details": {
            "rate": 0
        },
        "msg_store_read_count": 0,
        "msg_store_read_count_details": {
            "rate": 0
        },
        "msg_store_write_count": 0,
        "msg_store_write_count_details": {
            "rate": 0
        },
        "queue_index_journal_write_count": 0,
        "queue_index_journal_write_count_details": {
            "rate": 0
        },
        "queue_index_write_count": 0,
        "queue_index_write_count_details": {
            "rate": 0
        },
        "queue_index_read_count": 3,
        "queue_index_read_count_details": {
            "rate": 0
        },
        "io_file_handle_open_attempt_count": 73,
        "io_file_handle_open_attempt_count_details": {
            "rate": 0
        },
        "io_file_handle_open_attempt_avg_time": 0.031643835616438354,
        "io_file_handle_open_attempt_avg_time_details": {
            "rate": 0
        },
        "connection_created": 0,
        "connection_created_details": {
            "rate": 0
        },
        "connection_closed": 0,
        "connection_closed_details": {
            "rate": 0
        },
        "channel_created": 0,
        "channel_created_details": {
            "rate": 0
        },
        "channel_closed": 0,
        "channel_closed_details": {
            "rate": 0
        },
        "queue_declared": 0,
        "queue_declared_details": {
            "rate": 0
        },
        "queue_created": 0,
        "queue_created_details": {
            "rate": 0
        },
        "queue_deleted": 0,
        "queue_deleted_details": {
            "rate": 0
        },
        "cluster_links": [],
        "metrics_gc_queue_length": {
            "connection_closed": 0,
            "channel_closed": 0,
            "consumer_deleted": 0,
            "exchange_deleted": 0,
            "queue_deleted": 0,
            "vhost_deleted": 0,
            "node_node_deleted": 0,
            "channel_consumer_deleted": 0
        }
    }
]

/api/nodes/{node名称} 返回单个节点的统计信息

{
    "partitions": [],
    "os_pid": "4470",
    "fd_total": 256,
    "sockets_total": 138,
    "mem_limit": 6871947673,
    "mem_alarm": false,
    "disk_free_limit": 50000000,
    "disk_free_alarm": false,
    "proc_total": 1048576,
    "rates_mode": "basic",
    "uptime": 11728280,
    "run_queue": 1,
    "processors": 12,
    "exchange_types": [
        {
            "name": "fanout",
            "description": "AMQP fanout exchange, as per the AMQP specification",
            "enabled": true
        },
        {
            "name": "headers",
            "description": "AMQP headers exchange, as per the AMQP specification",
            "enabled": true
        },
        {
            "name": "x-delayed-message",
            "description": "Delayed Message Exchange.",
            "enabled": true
        },
        {
            "name": "direct",
            "description": "AMQP direct exchange, as per the AMQP specification",
            "enabled": true
        },
        {
            "name": "topic",
            "description": "AMQP topic exchange, as per the AMQP specification",
            "enabled": true
        }
    ],
    "auth_mechanisms": [
        {
            "name": "RABBIT-CR-DEMO",
            "description": "RabbitMQ Demo challenge-response authentication mechanism",
            "enabled": false
        },
        {
            "name": "AMQPLAIN",
            "description": "QPid AMQPLAIN mechanism",
            "enabled": true
        },
        {
            "name": "PLAIN",
            "description": "SASL PLAIN authentication mechanism",
            "enabled": true
        }
    ],
    "applications": [
        {
            "name": "amqp10_common",
            "description": "Modules shared by rabbitmq-amqp1.0 and rabbitmq-amqp1.0-client",
            "version": "3.7.14"
        },
        {
            "name": "amqp_client",
            "description": "RabbitMQ AMQP Client",
            "version": "3.7.14"
        },
        {
            "name": "asn1",
            "description": "The Erlang ASN1 compiler version 5.0.8",
            "version": "5.0.8"
        },
        {
            "name": "compiler",
            "description": "ERTS  CXC 138 10",
            "version": "7.3.2"
        },
        {
            "name": "cowboy",
            "description": "Small, fast, modern HTTP server.",
            "version": "2.6.1"
        },
        {
            "name": "cowlib",
            "description": "Support library for manipulating Web protocols.",
            "version": "2.7.0"
        },
        {
            "name": "crypto",
            "description": "CRYPTO",
            "version": "4.4.1"
        },
        {
            "name": "goldrush",
            "description": "Erlang event stream processor",
            "version": "0.1.9"
        },
        {
            "name": "inets",
            "description": "INETS  CXC 138 49",
            "version": "7.0.6"
        },
        {
            "name": "jsx",
            "description": "a streaming, evented json parsing toolkit",
            "version": "2.9.0"
        },
        {
            "name": "kernel",
            "description": "ERTS  CXC 138 10",
            "version": "6.3"
        },
        {
            "name": "lager",
            "description": "Erlang logging framework",
            "version": "3.6.9"
        },
        {
            "name": "mnesia",
            "description": "MNESIA  CXC 138 12",
            "version": "4.15.6"
        },
        {
            "name": "os_mon",
            "description": "CPO  CXC 138 46",
            "version": "2.4.7"
        },
        {
            "name": "public_key",
            "description": "Public key infrastructure",
            "version": "1.6.5"
        },
        {
            "name": "rabbit",
            "description": "RabbitMQ",
            "version": "3.7.14"
        },
        {
            "name": "rabbit_common",
            "description": "Modules shared by rabbitmq-server and rabbitmq-erlang-client",
            "version": "3.7.14"
        },
        {
            "name": "rabbitmq_amqp1_0",
            "description": "AMQP 1.0 support for RabbitMQ",
            "version": "3.7.14"
        },
        {
            "name": "rabbitmq_delayed_message_exchange",
            "description": "RabbitMQ Delayed Message Exchange",
            "version": "20171201-3.7.x"
        },
        {
            "name": "rabbitmq_management",
            "description": "RabbitMQ Management Console",
            "version": "3.7.14"
        },
        {
            "name": "rabbitmq_management_agent",
            "description": "RabbitMQ Management Agent",
            "version": "3.7.14"
        },
        {
            "name": "rabbitmq_mqtt",
            "description": "RabbitMQ MQTT Adapter",
            "version": "3.7.14"
        },
        {
            "name": "rabbitmq_stomp",
            "description": "RabbitMQ STOMP plugin",
            "version": "3.7.14"
        },
        {
            "name": "rabbitmq_web_dispatch",
            "description": "RabbitMQ Web Dispatcher",
            "version": "3.7.14"
        },
        {
            "name": "ranch",
            "description": "Socket acceptor pool for TCP protocols.",
            "version": "1.7.1"
        },
        {
            "name": "recon",
            "description": "Diagnostic tools for production use",
            "version": "2.4.0"
        },
        {
            "name": "sasl",
            "description": "SASL  CXC 138 11",
            "version": "3.3"
        },
        {
            "name": "ssl",
            "description": "Erlang/OTP SSL application",
            "version": "9.2.1"
        },
        {
            "name": "stdlib",
            "description": "ERTS  CXC 138 10",
            "version": "3.8"
        },
        {
            "name": "syntax_tools",
            "description": "Syntax tools",
            "version": "2.1.7"
        },
        {
            "name": "sysmon_handler",
            "description": "Rate-limiting system_monitor event handler",
            "version": "1.1.0"
        },
        {
            "name": "xmerl",
            "description": "XML parser",
            "version": "1.3.20"
        }
    ],
    "contexts": [
        {
            "description": "RabbitMQ Management",
            "path": "/",
            "port": "15672"
        }
    ],
    "log_files": [
        "/usr/local/var/log/rabbitmq/rabbit@localhost.log",
        "/usr/local/var/log/rabbitmq/rabbit@localhost_upgrade.log"
    ],
    "db_dir": "/usr/local/var/lib/rabbitmq/mnesia/rabbit@localhost",
    "config_files": [],
    "net_ticktime": 60,
    "enabled_plugins": [
        "rabbitmq_amqp1_0",
        "rabbitmq_delayed_message_exchange",
        "rabbitmq_management",
        "rabbitmq_mqtt",
        "rabbitmq_stomp"
    ],
    "mem_calculation_strategy": "rss",
    "name": "rabbit@localhost",
    "running": true,
    "type": "disc",
    "mem_used": 86814720,
    "mem_used_details": {
        "rate": -117964.8
    },
    "fd_used": 72,
    "fd_used_details": {
        "rate": 0
    },
    "sockets_used": 0,
    "sockets_used_details": {
        "rate": 0
    },
    "proc_used": 457,
    "proc_used_details": {
        "rate": 0
    },
    "disk_free": 172549808128,
    "disk_free_details": {
        "rate": -31129.6
    },
    "gc_num": 38308,
    "gc_num_details": {
        "rate": 3.4
    },
    "gc_bytes_reclaimed": 1616503320,
    "gc_bytes_reclaimed_details": {
        "rate": 152201.6
    },
    "context_switches": 423307,
    "context_switches_details": {
        "rate": 37.6
    },
    "io_read_count": 22,
    "io_read_count_details": {
        "rate": 0
    },
    "io_read_bytes": 2083,
    "io_read_bytes_details": {
        "rate": 0
    },
    "io_read_avg_time": 0.02909090909090909,
    "io_read_avg_time_details": {
        "rate": 0
    },
    "io_write_count": 0,
    "io_write_count_details": {
        "rate": 0
    },
    "io_write_bytes": 0,
    "io_write_bytes_details": {
        "rate": 0
    },
    "io_write_avg_time": 0,
    "io_write_avg_time_details": {
        "rate": 0
    },
    "io_sync_count": 0,
    "io_sync_count_details": {
        "rate": 0
    },
    "io_sync_avg_time": 0,
    "io_sync_avg_time_details": {
        "rate": 0
    },
    "io_seek_count": 0,
    "io_seek_count_details": {
        "rate": 0
    },
    "io_seek_avg_time": 0,
    "io_seek_avg_time_details": {
        "rate": 0
    },
    "io_reopen_count": 0,
    "io_reopen_count_details": {
        "rate": 0
    },
    "mnesia_ram_tx_count": 60,
    "mnesia_ram_tx_count_details": {
        "rate": 0
    },
    "mnesia_disk_tx_count": 10,
    "mnesia_disk_tx_count_details": {
        "rate": 0
    },
    "msg_store_read_count": 0,
    "msg_store_read_count_details": {
        "rate": 0
    },
    "msg_store_write_count": 0,
    "msg_store_write_count_details": {
        "rate": 0
    },
    "queue_index_journal_write_count": 0,
    "queue_index_journal_write_count_details": {
        "rate": 0
    },
    "queue_index_write_count": 0,
    "queue_index_write_count_details": {
        "rate": 0
    },
    "queue_index_read_count": 3,
    "queue_index_read_count_details": {
        "rate": 0
    },
    "io_file_handle_open_attempt_count": 73,
    "io_file_handle_open_attempt_count_details": {
        "rate": 0
    },
    "io_file_handle_open_attempt_avg_time": 0.031643835616438354,
    "io_file_handle_open_attempt_avg_time_details": {
        "rate": 0
    },
    "connection_created": 0,
    "connection_created_details": {
        "rate": 0
    },
    "connection_closed": 0,
    "connection_closed_details": {
        "rate": 0
    },
    "channel_created": 0,
    "channel_created_details": {
        "rate": 0
    },
    "channel_closed": 0,
    "channel_closed_details": {
        "rate": 0
    },
    "queue_declared": 0,
    "queue_declared_details": {
        "rate": 0
    },
    "queue_created": 0,
    "queue_created_details": {
        "rate": 0
    },
    "queue_deleted": 0,
    "queue_deleted_details": {
        "rate": 0
    },
    "cluster_links": [],
    "metrics_gc_queue_length": {
        "connection_closed": 0,
        "channel_closed": 0,
        "consumer_deleted": 0,
        "exchange_deleted": 0,
        "queue_deleted": 0,
        "vhost_deleted": 0,
        "node_node_deleted": 0,
        "channel_consumer_deleted": 0
    }
}
  • 3
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
在 Golang 中调用 RabbitMQ消息队列监控 API 可以使用标准的 `net/http` 包来发送 HTTP 请求并处理响应。以下是一个简单的示例代码,用于获取 RabbitMQ队列信息: ```go package main import ( "encoding/json" "fmt" "io/ioutil" "net/http" ) type QueueInfo struct { Name string `json:"name"` Messages int `json:"messages"` Consumers int `json:"consumers"` } func main() { // RabbitMQ API URL url := "http://localhost:15672/api/queues" // 创建 HTTP 客户端 client := &http.Client{} // 创建 HTTP 请求 req, err := http.NewRequest("GET", url, nil) if err != nil { fmt.Println("创建请求失败:", err) return } // 设置 Basic Auth 认证(如果需要) req.SetBasicAuth("username", "password") // 发送请求并获取响应 resp, err := client.Do(req) if err != nil { fmt.Println("发送请求失败:", err) return } defer resp.Body.Close() // 读取响应内容 body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println("读取响应失败:", err) return } // 解析 JSON 响应 var queues []QueueInfo err = json.Unmarshal(body, &queues) if err != nil { fmt.Println("解析响应失败:", err) return } // 输出队列信息 for _, queue := range queues { fmt.Printf("队列名称: %s\n", queue.Name) fmt.Printf("消息数量: %d\n", queue.Messages) fmt.Printf("消费者数量: %d\n", queue.Consumers) fmt.Println("----------------------") } } ``` 请注意,上述代码中的 `url` 变量需要根据你的 RabbitMQ 配置进行相应调整。如果 RabbitMQ 设置了用户名和密码的认证,你需要使用 `SetBasicAuth` 方法设置 Basic Auth 认证信息。 该示例代码发送一个 HTTP GET 请求到 RabbitMQ 的 `/api/queues` 接口,获取所有队列的信息,并将其解析为 `QueueInfo` 结构体。然后,你可以根据需要处理和使用这些队列信息。 希望这个示例能帮助到你。如果有任何其他问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值