Skip to content

Instantly share code, notes, and snippets.

Last active Dec 21, 2021
What would you like to do?
Fetches the Celery queue length
from checks import AgentCheck
class CeleryQueue(AgentCheck):
def check(self, instance):
import redis
except ImportError:
raise Exception('Python Redis Module can not be imported. Please check the installation instruction on the Datadog Website')
keys = instance.get('queue_keys', [])
if not keys:
raise Exception('No queue keys were found in the yaml configuration file')
list_params = ['host', 'port', 'db', 'password']
connection_params = dict((k, instance[k]) for k in list_params if k in instance)
db = redis.Redis(**connection_params)
for key in keys:
self.gauge("celery.queue.length", db.llen(key), tags=["queue:%s" % key])
- host: localhost
port: 6379
db: 14
# password: mypassword
queue_keys: # A list of keys associated with the Celery queues
- key1
- key2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment