Curl to get Rabbitmq queue size

前端 未结 5 1959
花落未央
花落未央 2021-02-05 09:47

Is there a way to get the size (remaining messages) of a queue in rabbitmq with a simple Curl?

Something like curl -xget http://host:1234/api/queue/test/stats

相关标签:
5条回答
  • 2021-02-05 10:16

    I appreciate this is an old post & that the question specifically states using "curl" but thought it might be useful to add that the "rabbitmqctl list_queues" command provides the message count for each queue

    0 讨论(0)
  • 2021-02-05 10:18

    As much as I love hacky sed one-liners this is probably the cleanest solution:

    curl -s -u <user>:<password> http://<host>:<port>/api/queues/<virtual-host>/<queue> | jq .messages
    
    0 讨论(0)
  • 2021-02-05 10:20

    Finally I did the trick with the following:

    curl -s -i -u guest:guest http://host:port/api/queues/vhost/queue_name | sed 's/,/\n/g' | grep '"messages"' | sed 's/"messages"://g'
    
    0 讨论(0)
  • 2021-02-05 10:28

    Use HTTP API from Management Plugin.

    It looks you may benefit from /api/queues/(vhost)/(name) one. The output is in plain json, so you won't miss messages field (and related).

    0 讨论(0)
  • 2021-02-05 10:36

    curl -u login:password http://localhost:15672/api/queues | sed 's/,/\n/g' | grep '"messages"\:'

    Rabbitmq v3.3.4 PHP library based on HTTP api.

    REQRequest

    0 讨论(0)
提交回复
热议问题