Monitoring and Metrics

To ensure your JoobQ-based job processing system runs smoothly and efficiently, monitoring and metrics are key. This section explains how you can track job performance, monitor queues, and use JoobQ's built-in dashboard for real-time insights.

Metrics Overview

JoobQ offers a range of metrics that help you understand the state and performance of your job queues and workers. Metrics give you visibility into job completion rates, retry attempts, failures, and more.

Key Metrics

  • Queue Length: The number of jobs waiting to be processed in each queue (current_size).

  • Job Processing Time: The average time it takes to execute a job (job_execution_time).

  • Retry Count: The number of retries for each job, helping you spot jobs that may need investigation (retried).

  • Worker Utilization: Information on how busy each worker is, indicating if you need to scale workers up or down (worker_utilization).

  • Dead Letter Count: The number of jobs that have been moved to the dead letter queue due to failure (dead).

  • Jobs Completed Per Second: The rate at which jobs are being completed (jobs_completed_per_second).

  • Queue Reduction Rate: The rate at which jobs are being removed from the queue (queue_reduction_rate).

  • Errors Per Second: The number of errors encountered per second (errors_per_second).

  • Job Wait Time: The average time a job spends waiting in the queue before being executed (job_wait_time).

  • Error Rate Trend: The trend of errors over time, indicating any increase or decrease in error occurrences (error_rate_trend).

  • Failed Job Rate: The rate of jobs that have failed during execution (failed_job_rate).

  • Average Jobs in Flight: The average number of jobs currently being processed (average_jobs_in_flight).

  • Completion Percentages: Metrics such as percentage of jobs completed (percent_completed), retried (percent_retried), dead (percent_dead), and busy workers (percent_busy).

These metrics are essential for keeping your system responsive and ensuring that jobs are processed without delay.

For those who prefer automation or need to integrate metrics into an existing monitoring stack, JoobQ also exposes a Metrics API. This allows you to programmatically retrieve metrics and integrate them with tools like Prometheus, Grafana, or your own custom monitoring system.

Example Metrics API Usage

To get the current metrics for the entire system, you can send a request like this:

curl http://localhost:8080/joobq/metrics

The Metrics API provides the following endpoints:

  • Global Metrics: /joobq/metrics - Retrieves comprehensive metrics for the entire system, including queue sizes, worker status, and job statistics.

  • Queue Metrics: /joobq/queues - Retrieves metrics for all queues, such as queue length and processing statistics.

  • Job Registry: /joobq/jobs/registry - Retrieves details of all jobs currently in the registry.

  • Overtime Series Metrics: /joobq/metrics - Retrieves metrics over time, including enqueued and completed job statistics.

These endpoints allow you to gather critical information about the state of your system, which can be used to trigger alerts or create detailed dashboards.

Alerts and Notifications

To stay informed about potential issues, you can set up alerts based on metrics thresholds. For example:

  • High Retry Rates: Trigger an alert if a particular job has been retried more than a specified number of times.

  • Long Queue Lengths: Set an alert if a queue length exceeds a critical threshold, indicating that workers may need scaling.

  • High Error Rate: Set alerts if the error rate trend shows consistent increases, which could indicate deeper issues.

You can use tools like Grafana to create visual dashboards and integrate alerts based on the metrics provided by JoobQ's API.


Monitoring and metrics are crucial for maintaining a healthy job processing system. Use the JoobQ Metrics API to keep track of job statuses, identify bottlenecks, and ensure that your background processing is efficient and reliable. Next, let's explore Using JoobQ with Docker for streamlined deployment and setup!

Last updated