Search code examples
djangostatisticsdjango-rqrq

Django-RQ API_TOKEN configuration to access to stats endpoint


I'm trying to retrieve some statistics from the django-rq queues and I'm having some difficulties to access to the provided URL from the Django-Rq documentation

These statistics are also available in JSON format via /django-rq/stats.json, which is accessible to staff members. If you need to access this view via other HTTP clients (for monitoring purposes), you can define RQ_API_TOKEN and access it via /django-rq/stats.json/<API_TOKEN>.

Well, I have defined a simple RQ_API_TOKEN just for testing purposes in my settings.py

RQ_API_TOKEN = "AAABBBCCC"

And I'm trying to access it via Postman but I keep receiving the following response:

{"error": true, "description": "Please configure API_TOKEN in settings.py before accessing this view."}

I've tried to send the token in the headers o even a query param, but it still doesn't work as is intended to work.

Example URLS that I've tried with query params:

  • django-rq/stats.json/?token=AAABBBCCC
  • django-rq/stats.json/?api_token=AAABBBCCC
  • django-rq/stats.json/?API-TOKEN=AAABBBCCC
  • django-rq/stats.json/?API_TOKEN=AAABBBCCC

The same I've tried, but leaving no query param and inserting the token as a header with the same keys. Nothing works.


Solution

  • Well, it turns out that the correct URL to hit was:

    django-rq/stats.json/AAABBBCCC/

    Without any query param or header. Sometimes the simplest thing is the right thing to do.