Skip to main content

RabbitMQ Monitor

Project description

jetblack-rabbitmqmon

This is an asyncio RabbitMQ monitor API.

It wraps the RabbitMQ management plugin REST api. This allows retrieving metrics and peeking into the queues.

Status

This is work in progress, but is functional.

Installation

This can be installed with pip.

Multiple clients a supported and one must be selected. Choose one of:

pip install jetblack-rabbitmqmon[bareclient]

Or alternatively:

pip install jetblack-rabbitmqmon[aiohttp]

Usage

The following gets an overview using the bareclient.

import asyncio
from jetblack_rabbitmqmon.monitor import Monitor
from jetblack_rabbitmqmon.clients.bareclient_requester import BareRequester

async def main_async():
    mon = Monitor(
        BareRequester(
            'http://mq.example.com:15672',
            'admin',
            'admins password'
        )
    )

    overview = await mon.overview()
    print(overview)

if __name__ == '__main__':
    asyncio.run(main_async())

The follow explores a vhost.

import asyncio
from jetblack_rabbitmqmon.monitor import Monitor
from jetblack_rabbitmqmon.clients.aiohttp_requester import AioHttpRequester

async def main_async():
    mon = Monitor(
        AioHttpRequester(
            'http://mq.example.com:15672',
            'admin',
            'admins password'
        )
    )

    vhosts = await mon.vhosts()
    for vhost in vhosts.values(): # vhost is a dict
      exchanges = await vhost.exchanges()
      for exchange in exchanges.values(): # exchanges is a dict
          print(exchange)
          # Objects can be refreshed to gather new metrics.
          await exchange.refresh()
          print(exchange)
          bindings = await exchange.bindings()
          for binding in bindings:
              print(binding)

if __name__ == '__main__':
    asyncio.run(main_async())

The following gets some messages from an exchange:

import asyncio
from jetblack_rabbitmqmon.monitor import Monitor
from jetblack_rabbitmqmon.clients.bareclient_requester import BareRequester

async def main_async():
    mon = Monitor(
        BareRequester(
            'http://mq.example.com:15672',
            'admin',
            'admins password'
        )
    )

    vhosts = await mon.vhosts()
    vhost = vhosts['/some-vhost']
    queues = await vhost.queues()
    queue = queues['some.queue']
    messages = await queue.get_messages()
    print(messages)

if __name__ == '__main__':
    asyncio.run(main_async())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jetblack-rabbitmqmon-2.0.0.tar.gz (15.0 kB view hashes)

Uploaded Source

Built Distribution

jetblack_rabbitmqmon-2.0.0-py3-none-any.whl (20.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page