Closed mobilego closed 4 years ago
Hi,
By namespace you mean the Queue.redis_queue_namespace_prefix
and Worker.redis_worker_namespace_prefix
class variables right? Are you using a custom Queue
and Worker
classes? And what about the Job
class are you using a custom namespace too?
You cannot specify this namespace using the Redis URL.
The reason these metrics are empty because we're using the default Queue
and Worker
classes to fetch the data so we're using the default namespace prefix.
I'll start working on this, if you have any suggestions please let me know.
I have added support for specifying custom RQ Worker
and Queue
classes which solves your problem if you're using custom namespace prefixes, these changes were released under a new version 1.3.0
, feel free to re-open this issue if it doesn't solve your problem.
Appreciate you quick response. I have workers under 127.0.0.1:6379> keys "prod:worker:" and multiple queues under 127.0.0.1:6379> keys "prod:queue1:" 127.0.0.1:6379> keys "prod:queue2:*" . How should i specify RQ_WORKER_CLASS and RQ_QUEUE_CLASS ? Could you please help ?
I've assumed that you're using custom Worker
and Queue
classes where you can change the namespace prefixes, for example:
from rq import Worker, Queue
from rq.job import Job
class CustomJob(Job):
redis_job_namespace_prefix = 'rq:custom:job:'
class CustomQueue(Queue):
redis_queue_namespace_prefix = 'rq:custom:queue:'
job_class = CustomJob
class CustomWorker(Worker):
redis_worker_namespace_prefix = 'rq:custom:worker:'
queue_class = CustomQueue
job_class = CustomJob
So you can configure rq-exporter
to use these classes instead of the default rq.Queue
and rq.Worker
classes using these configuration options:
CLI Argument | Env Variable | Default Value | Description |
---|---|---|---|
--worker-class |
RQ_WORKER_CLASS |
rq.Worker |
RQ worker class |
--queue-class |
RQ_QUEUE_CLASS |
rq.Queue |
RQ queue class |
For example I've added a docker-compose.custom.yml
file that contains an example on how to do this:
rq_exporter:
image: mdawar/rq-exporter:latest
# You can also configure the exporter using command line options
# command: |
# --redis-host redis
# --redis-pass-file /run/secrets/redis_pass
# --worker-class 'custom.CustomWorker'
# --queue-class 'custom.CustomQueue'
ports:
- target: 9726
published: 9726
protocol: tcp
mode: host
environment:
# Redis configuration
RQ_REDIS_HOST: "redis"
RQ_REDIS_PASS_FILE: /run/secrets/redis_pass
RQ_REDIS_DB: "0"
# Add the project's path to be able to import the classes
# Escaping the $ sign is only needed only in the `docker-compose.yml` file
PYTHONPATH: "$${PYTHONPATH}:/home/project"
RQ_WORKER_CLASS: "custom.CustomWorker"
RQ_QUEUE_CLASS: "custom.CustomQueue"
volumes:
# Mount your project where you define the custom classes
- type: bind
source: ./docker-compose/project
target: /home/project
Of course you don't have to be using Docker nor docker-compose to do this but this gives you an idea on how to configure the exporter.
rq_workers and rq_jobs metrics are empty when checked in Prometheus. I could see the output for rq_request_processing_seconds_count this metric. All the jobs and workers are under a specific namespace under database 0. Should we specify the namespace in the url RQ_REDIS_URL ? Could you please let me know what could be the reason for workers and jobs metrics are empty ?