Skip to content
Get started
Get started
Workers, Stats and Metrics from the Queue
guide · queue

Who is connected, and how it is going.

Which workers are registered, what the queue has processed, and the time-windowed counters behind a dashboard.

const workers = await queue.getWorkers(); // Active workers on this queue
const count = await queue.getWorkersCount();
const completedMetrics = await queue.getMetrics('completed', 0, 100);
const failedMetrics = await queue.getMetrics('failed', 0, 100);
const removed = await queue.trimEvents(1000); // Keep the newest 1,000 events

Worker and stats helpers are not yet exposed in Rust and Elixir; scrape the server’s HTTP /metrics endpoint instead. trimEvents() and windowed getMetrics(state, start, end) exist in the Bun bunqueue package only.

getMetrics(type, start = 0, end = -1) is queue-scoped in both embedded and TCP mode. It returns:

interface QueueMetrics {
meta: {
count: number; // Cumulative terminal jobs for this queue and type
prevTS: number; // Timestamp of the most recent terminal job
prevCount: number; // Count in its one-minute bucket
};
data: number[]; // One-minute buckets, newest first
count: number; // Available buckets before pagination
}

start and end are inclusive bucket indexes, not timestamps. Index 0 is the newest minute and end: -1 means through the oldest retained minute. Empty minutes between observed buckets are returned as zero. Unlike BullMQ’s Redis collector, bunqueue includes the current partial minute immediately, so one finished job produces a visible data point without waiting for the minute to close. The broker retains at most 20,160 points (two weeks) per queue and state; meta.count remains cumulative when older points age out.

trimEvents(maxLength) operates on the separate lifecycle-event journal. It returns the number of deleted entries, affects only this queue, and is idempotent: calling it again with the same length returns 0. The journal is SQLite-persistent, automatically bounded to 10,000 entries per queue, and is deleted together with queue metrics by obliterateAsync().

Queue APICreate a queue in embedded or TCP mode
Adding Jobsadd, addBulk, priorities, delays, durability
Deduplication and Idempotent Job AddsIdempotent adds, dedup keys, custom job ids
Querying JobsFetch jobs, states, counts and results
Queue Control and MaintenancePause, drain, obliterate, clean and repair
Progress, Job Logs and DependenciesProgress, per-job logs and dependencies
Queue Rate Limiting and Global ConcurrencyRate limits and global concurrency caps
Job Schedulers from the QueueNamed repeatable schedules from the queue
DLQ Operations from the Queue ObjectFailed-job operations from the Queue object
Namespaces, Auto-Batching and Store-and-ForwardNamespaces, auto-batching, store-and-forward
JobOptions ReferenceEvery JobOptions field, with defaults