Skip to content
On this page
  1. Module options
  2. Queue configuration
  3. Async registration
  4. Custom processors and caches
  5. Multiple Redis instances

NestJS integration

Configure queues, Redis instances, endpoint capabilities, and async registration with @queuebert/nest.

Module options#

Import QueuebertModule from @queuebert/nest. Register once in the application that owns access to your queues.

OptionDefaultPurpose
queuesRequiredQueues to expose, each with a BullMQ name.
pathadmin/queueController base path, without a leading slash.
authNoneApplication-owned guards and controller class decorators.
endpoints['metrics']Optional capabilities. stats is always enabled.
includeRedisStatstrueInclude Redis memory and connection statistics.
redisInferred from the first queueNamed Redis instances for multi-Redis monitoring and migration.
jobTypeDiscoveryEnabled, sample size 100, threshold 1000Discover job names and counts; large queues use sampling.
includeJobDataInMigrationPreviewfalseInclude raw payloads in migration previews. Treat as sensitive.
integrationsAutomatic Nest package registrationAdditional integration package metadata in stats.

An explicit endpoints: [] exposes statistics only. Adding 'pause', 'resume', 'clean', 'drain', or 'migrations' enables that capability. Disabled capabilities return HTTP 404.

Queue configuration#

Each entry's name must match the BullMQ queue name. By default, Queuebert resolves queues registered through Nest's BullModule.

  • processor: optional class implementing QueuebertProcessor, registered as a Nest provider. Use BaseQueueProcessor for the built-in implementation.
  • statsKey: a unique response and operation key, defaulting to name. Give same-named queues on different Redis instances distinct keys.
  • redis: the ID of an entry in the module's redis array.
  • queue: a direct BullMQ Queue instance instead of a DI-resolved queue. The application owns its lifecycle.

Monitoring-only queues can omit processor. They still report queue counts but cannot provide in-process processor measurements.

Async registration#

Use forRootAsync() when configuration comes from injected services. Put path and auth on the outer options: Nest constructs controller metadata before the async factory resolves.

This example assumes @nestjs/config is installed and your app provides AdminGuard:

typescript
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { QueuebertModule } from '@queuebert/nest';
import { AdminGuard } from './admin.guard';

@Module({
  imports: [
    QueuebertModule.forRootAsync({
      path: 'admin/queue',
      auth: { guards: [AdminGuard] },
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (injected: unknown) => {
        const config = injected as ConfigService;
        return {
          queues: [{ name: config.getOrThrow<string>('EMAIL_QUEUE_NAME') }],
          endpoints: ['metrics'],
        };
      },
    }),
  ],
})
export class MonitoringModule {}

The corresponding BullMQ queue must already be registered in the application. Imported auth/config providers must be visible to the modules that consume them.

Custom processors and caches#

Implement QueuebertProcessor.getProcessorStats() to supply your own statistics. QueuebertProcessorStats includes duration percentiles in milliseconds, job totals, rates expressed as fractions from 0 to 1, and a rolling throughput window. The base processor also allows custom statistics through getCustomStats().

Processors can expose managed caches through getCacheConfigs(): QueuebertCacheConfig[]. A cache entry identifies its id, label, keyPrefix, and compatible cache instance. Queuebert uses this metadata for cache statistics and the migration endpoints; arbitrary Redis keys are not automatically treated as managed caches.

Multiple Redis instances#

Use a named redis array and associate each queue with an ID. Supply a direct queue instance when monitoring the same name on another Redis deployment, and use a distinct statsKey. See migrations for a registration example and operational restrictions.

Queuebert

© 2026 Queuebert