filter data of queues using REST API "/api/queue/

2,174 views
Skip to first unread message

neha agarwal

unread,
Oct 24, 2018, 12:14:17 AM10/24/18
to rabbitmq-users

Hi All,
I am very new to RabbitMQ.

I am trying to use RabbitMQ REST API 

which is giving me proper result . Now If I want to filter data based on queue name , I read somewhere we can use regex to do that . Can some one share a example/documentation of same .It is not working for me .

I tried like this (pagination works but not regex)

http://localhost:15672/api/queues/%2F/?page=1&page_size=100&name=<regex here >&use_regex=true&pagination=true&columns=messages_unacknowledged,messages_ready,message_bytes_unacknowledged,message_bytes_ready,name,policy,idle_since,consumers,state,consumer_details.consumer_tag,consumer_details.channel_details.connection_name,consumer_details.channel_details.name,consumers


__________________________

I also tried using the Java client "client.getQueues("/")" but again I get the whole list which in my case would be too huge , so I was looking for a api to get all the queue details (attached to a exchange) in one rest api call .
I am sure that exchange name would be present in the queue name .

Any help is appreciated

Regards
Neha

Luke Bakken

unread,
Oct 24, 2018, 12:46:53 PM10/24/18
to rabbitmq-users
Hi Neha,

There are a couple examples of use_regex in these tests: https://github.com/rabbitmq/rabbitmq-management/blob/master/test/rabbit_mgmt_http_SUITE.erl

Notice that the regex must be URL-encoded - &name=%5E(?=%5Ereg)&use_regex=true

Could you give an example of the regex you are trying? You have edited it out of the URL you gave - please give the full URL so I can try it out as well.

Thanks,
Luke

neha agarwal

unread,
Nov 2, 2018, 5:56:47 AM11/2/18
to rabbitm...@googlegroups.com
Hi Luke,
Thanks for your help . 

But the REST API still doesn't work , Adding more details , please let me know if u see any issues 


I will have a output something like
{ "messages_unacknowledged": 0, "messages_ready": 0, "name": "ibus-d-s-1501DEP-MDI238_1501DEPM-PUBLISH.LabDataDevice.outcome.*", "message_bytes_unacknowledged": 0, "message_bytes_ready": 0, "state": "running", "consumers": 0, "policy": "d-s", "idle_since": "2018-11-02 8:25:24" },

I want to filter messages based on tenantName , e.g. in above output the name field will have the tenantName (e.g in this case 1501DEP)

Regards
Neha


--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Luke Bakken

unread,
Nov 2, 2018, 11:35:28 AM11/2/18
to rabbitmq-users
Hi Neha,

If I decode the regular expression in that URL, I get this value:

^.*-DWXENG2-.*$

There's no need to explicitly match the start and end of the string in this case.

If you want to list queues whose name contains the string 1501DEP, try this URL:

http://localhost:15672/api/queues/%2F/?name=-1501DEP-&use_regex=true

If that does not work, please provide examples of the output in a file.

Thanks,
Luke

neha agarwal

unread,
Dec 10, 2018, 3:44:39 PM12/10/18
to rabbitm...@googlegroups.com
Hi Luke,
I think I found the issue , 

RabbitMQ Rest URL doesnt work if the pagination parameter has not been passed , so only when pagination is set to true the regex works 

Regards
Neha


--

Luke Bakken

unread,
Dec 10, 2018, 3:59:20 PM12/10/18
to rabbitmq-users
Hi Neha,

Thanks for reporting back. I'm surprised by what you have found but, sure enough, pagination is required by this code:


Basically, the page/1 function is what does regex filtering, and you can see that it is only called when Pagination is true.

Thanks again -
Luke


On Monday, December 10, 2018 at 12:44:39 PM UTC-8, neha agarwal wrote:
Hi Luke,
I think I found the issue , 

RabbitMQ Rest URL doesnt work if the pagination parameter has not been passed , so only when pagination is set to true the regex works 

Regards
Neha

neha agarwal

unread,
Dec 10, 2018, 4:11:48 PM12/10/18
to rabbitm...@googlegroups.com
Hi Luke ,
So what I feel (please correct if I am wrong) 

If I have "page" and "page_size" parameter set , I do not need to set "use_regex" and "pagination" parameter . My name parameter still has a regular expression as you can see below and the filteration works perfectly
http://<Rabbit server>:15672/api/queues/%2F/?page=1&page_size=500&name=%2DDWXENG%2D&columns=messages_unacknowledged,messages_ready,message_bytes_unacknowledged,message_bytes_ready,name,policy,total_count  

So is my assumption right ?

Regards
Neha



On Tue, Dec 11, 2018 at 2:29 AM Luke Bakken <lba...@pivotal.io> wrote:
Hi Neha,

Thanks for reporting back. I'm surprised by what you have found but, sure enough, pagination is required by this code:


Basically, the page/1 function is what does regex filtering, and you can see that it is only called when Pagination is true.

Thanks again -
Luke

On Monday, December 10, 2018 at 12:44:39 PM UTC-8, neha agarwal wrote:
Hi Luke,
I think I found the issue , 

RabbitMQ Rest URL doesnt work if the pagination parameter has not been passed , so only when pagination is set to true the regex works 

Regards
Neha


On Fri, Nov 2, 2018 at 9:05 PM Luke Bakken <lba...@pivotal.io> wrote:
Hi Neha,

If I decode the regular expression in that URL, I get this value:

^.*-DWXENG2-.*$

There's no need to explicitly match the start and end of the string in this case.

If you want to list queues whose name contains the string 1501DEP, try this URL:

http://localhost:15672/api/queues/%2F/?name=-1501DEP-&use_regex=true

If that does not work, please provide examples of the output in a file.

--

Luke Bakken

unread,
Dec 10, 2018, 5:06:08 PM12/10/18
to rabbitmq-users
Hi Neha,

Your query works because, when use_regex is omitted or false, the string search that is done is for a lowercased substring that matches the name parameter. Here is the code that does it:


Your search string -DWXENG- is being matched as a substring, not as a regular expression in this case. If your search string contained regex metacharacters like [A-Z]+ then it would not match unless use_regex=true is passed.

And finally, even though the management UI sends pagination=true to RabbitMQ that parameter is ignored. The presence of page and page_size are used to determine pagination (and filtering).

Thanks,
Luke
Reply all
Reply to author
Forward
0 new messages