Skip to content

Service that can be used to monitor BullMQ by providing Prometheus metrics and a Bullmq dashboard secured behind a login wall.

License

Notifications You must be signed in to change notification settings

ron96G/bullmq-exporter

Repository files navigation

Docker

Service that acts as a central component to monitor BullMQ:

  • Exposes a BullMQ dashboard which is per default behind a login page
  • Acts as a Prometheus-Exporter to collect metrics about queues in BullMQ

Implementation

The following section will provide a brief overview of the libraries and practices used in the implementation of this service.

BullMQ Dashboard

Implemented by using @bull-board and secured using passport.

Prometheus Exporter

Strongly influenced by bull_exporter. Which uses the old bull library.

Implemented by using the bullmq library (specifically the QueueEvents class) and prom-client.

For each queue a class extending the QueueEvents class is created. This class listens for the following events: completed. Whenever an eventListener is triggered, a histogram is updated with

  1. the duration between the start of the processing and the end of the job
  2. the duration between the creation of the job and the end of its processing.

Furthermore, a cron job is executed every n seconds which collects the current status of the queues (completed, active, delayed, failed, waiting jobs) and writes them to a gauge.

Thus, the following metrics are collected:

Metric Type Description
bullmq_processed_duration histogram Processing time for completed jobs
bullmq_completed_duration histogram Completion time for jobs
bullmq_completed gauge Total number of completed jobs
bullmq_active gauge Total number of active jobs (currently being processed)
bullmq_delayed gauge Total number of jobs that will run in the future
bullmq_failed gauge Total number of failed jobs
bullmq_waiting gauge Total number of jobs waiting to be processed

Each metric also has the attribute queue which indicated which queue the metric is associated with.

How to use

Variables

These environment variables may be set to overwrite the values in the config file. Note that not all values are supported.

Name Description
REDIS_HOST Redis host, e. g. "localhost:6379/"
REDIS_USERNAME Redis username
REDIS_PASSWORD Redis password
REDIS_SSL Whether to use ssl

Local

  1. Install the dependencies
npm install
  1. Default environment is local. This can be set using the NODE_ENV variable.
export NODE_ENV=production
  1. Make sure that the required config file is present: ./configs/config-${NODE_ENV}.json (see local).
  2. Start the server
npm run dev
  1. Access the resources http://localhost:8080/bullmq/ui/login or http://localhost:8080/prometheus/metrics

Docker

The Dockerimage is published using the local configuration. In most cases that will not be sufficient and should be overwritten. This can be done using environment variables (see here) or by mounting a separate file.

# This needs a config file under ./configs/config-dev.json
docker run \
    -it \
    --mount type=bind,source=$(pwd)/configs,target=/app/configs \
    --env=NODE_ENV=dev \
    --env=REDIS_HOST=some-host:6379/ \
    rgummich/bullmq-exporter

Kubernetes

In Kubernetes this may be done using Secrets.

About

Service that can be used to monitor BullMQ by providing Prometheus metrics and a Bullmq dashboard secured behind a login wall.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published