Skip to content

Commit

Permalink
Merge pull request #1015 from Shopify/redis_expired_percent
Browse files Browse the repository at this point in the history
Additional derived Redis metrics
  • Loading branch information
Remi Hakim committed Jul 7, 2014
2 parents fb0ee4d + 5a900aa commit fdb21bb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions checks.d/redisdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,15 @@ def _check_db(self, instance, custom_tags=None):
for key in info.keys():
if self.db_key_pattern.match(key):
db_tags = list(tags) + ["redis_db:" + key]
# allows tracking percentage of expired keys as DD does not
# currently allow arithmetic on metric for monitoring
expires_keys = info[key]["expires"]
total_keys = info[key]["keys"]
persist_keys = total_keys - expires_keys
self.gauge("redis.persist", persist_keys, tags=db_tags)
self.gauge("redis.persist.percent", 100.0 * persist_keys / total_keys, tags=db_tags)
self.gauge("redis.expires.percent", 100.0 * expires_keys / total_keys, tags=db_tags)

for subkey in self.subkeys:
# Old redis module on ubuntu 10.04 (python-redis 0.6.1) does not
# returns a dict for those key but a string: keys=3,expires=0
Expand Down

0 comments on commit fdb21bb

Please sign in to comment.