Search code examples
prometheusgrafanapromql

How to query for queues that have a specific word in it


What I was doing is:

rabbitmq_queue_messages_published{queue="Specific.Queue.String.With.TheWord.Apple"} 

to get the number of messages published in the Specific.Queue.String.With.TheWord.Apple queue.

But I have like... 50 queues that I want to look at, whose commonality is that they have this word in the queue name.

How do I query for the number of messages published in queues with this specific word?


Solution

  • Use regex label filter:

    rabbitmq_queue_messages_published{queue=~".*TheWord.*"}
    

    Note that .* must be added at both sides of TheWord, since Prometheus automatically adds anchors to the regexp. I.e. it converts regexp to ^(?:regexp)$