diff --git a/checks.d/redisdb.py b/checks.d/redisdb.py index c926f52059..c3e7772922 100644 --- a/checks.d/redisdb.py +++ b/checks.d/redisdb.py @@ -177,6 +177,19 @@ def _check_db(self, instance, custom_tags=None): self.rate('redis.net.commands', info['total_commands_processed'], tags=tags) + # Check some key lengths if asked + key_list = instance.get('keys') + if not isinstance(key_list, list) or len(key_list) == 0: + self.warning("keys in redis configuration is either not a list or empty") + else: + l_tags = list(tags) + for key in key_list: + if conn.exists(key): + key_tags = l_tags + ["key:" + key] + self.gauge("redis.key.length", conn.llen(key), tags=key_tags) + else: + self.warning("{0} key not found in redis".format(key)) + def check(self, instance): try: import redis diff --git a/conf.d/redisdb.yaml.example b/conf.d/redisdb.yaml.example index ab6ac3a28a..6f11d7f570 100644 --- a/conf.d/redisdb.yaml.example +++ b/conf.d/redisdb.yaml.example @@ -7,4 +7,7 @@ instances: # password: mypassword # tags: # - optional_tag1 -# - optional_tag2 \ No newline at end of file +# - optional_tag2 +# keys: # check the length of these keys +# - key1 +# - key2 \ No newline at end of file