Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements #945: monitor Redis key lengths #962

Merged
merged 2 commits into from
Jun 6, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions checks.d/redisdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@ 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
if instance.get('keys') is not None:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you check that it's actually a list ? and maybe raise a warning (using self.warning) if it's not and skip the key length collection ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

l_tags = list(tags)
for key in instance.get('keys'):
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
Expand Down
5 changes: 4 additions & 1 deletion conf.d/redisdb.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ instances:
# password: mypassword
# tags:
# - optional_tag1
# - optional_tag2
# - optional_tag2
# keys: # check the length of these keys
# - key1
# - key2