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
The following section will provide a brief overview of the libraries and practices used in the implementation of this service.
Implemented by using @bull-board and secured using passport.
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
- the duration between the start of the processing and the end of the job
- 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.
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 |
- Install the dependencies
npm install
- Default environment is
local
. This can be set using theNODE_ENV
variable.
export NODE_ENV=production
- Make sure that the required config file is present:
./configs/config-${NODE_ENV}.json
(see local). - Start the server
npm run dev
- Access the resources
http://localhost:8080/bullmq/ui/login
orhttp://localhost:8080/prometheus/metrics
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
In Kubernetes this may be done using Secrets.