Skip to content

Commit

Permalink
Merge pull request #1891 from DataDog/yann/redis-switch-metric-types2
Browse files Browse the repository at this point in the history
[redis] `keyspace_hits` metrics: 'gauge' → 'rate'
  • Loading branch information
remh committed Sep 15, 2015
2 parents e89d000 + 2dc0f62 commit 5144e2c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions checks.d/redisdb.py
Expand Up @@ -48,8 +48,6 @@ class Redis(AgentCheck):
'expired_keys': 'redis.keys.expired',

# stats
'keyspace_hits': 'redis.stats.keyspace_hits',
'keyspace_misses': 'redis.stats.keyspace_misses',
'latest_fork_usec': 'redis.perf.latest_fork_usec',

# pubsub
Expand Down Expand Up @@ -83,6 +81,10 @@ class Redis(AgentCheck):
'used_cpu_sys_children': 'redis.cpu.sys_children',
'used_cpu_user': 'redis.cpu.user',
'used_cpu_user_children': 'redis.cpu.user_children',

# stats
'keyspace_hits': 'redis.stats.keyspace_hits',
'keyspace_misses': 'redis.stats.keyspace_misses',
}

def __init__(self, name, init_config, agentConfig, instances=None):
Expand Down Expand Up @@ -205,10 +207,11 @@ def _check_db(self, instance, custom_tags=None):
self.gauge(metric, val, tags=db_tags)

# Save a subset of db-wide statistics
for k in set(info).intersection(self.GAUGE_KEYS):
self.gauge(self.GAUGE_KEYS[k], info[k], tags=tags)
for k in set(info).intersection(self.RATE_KEYS):
self.rate(self.RATE_KEYS[k], info[k], tags=tags)
for info_name, value in info.iteritems():
if info_name in self.GAUGE_KEYS:
self.gauge(self.GAUGE_KEYS[info_name], info[info_name], tags=tags)
elif info_name in self.RATE_KEYS:
self.rate(self.RATE_KEYS[info_name], info[info_name], tags=tags)

# Save the number of commands.
self.rate('redis.net.commands', info['total_commands_processed'],
Expand Down
2 changes: 1 addition & 1 deletion tests/checks/integration/test_redisdb.py
Expand Up @@ -20,7 +20,7 @@
SLAVE_HEALTHY_PORT = 36379
SLAVE_UNHEALTHY_PORT = 46379
DEFAULT_PORT = 6379
MISSING_KEY_TOLERANCE = 0.5
MISSING_KEY_TOLERANCE = 0.6


@attr(requires='redis')
Expand Down

0 comments on commit 5144e2c

Please sign in to comment.