diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-02-07 11:45:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-02-07 11:45:55 +0000 |
commit | a8220ab2d293bb7f4b014b79d16b2fb05090fa93 (patch) | |
tree | 77f0a30f016c0925cf7ee9292e644bba183c2774 /collectors/python.d.plugin/redis | |
parent | Adding upstream version 1.19.0. (diff) | |
download | netdata-a8220ab2d293bb7f4b014b79d16b2fb05090fa93.tar.xz netdata-a8220ab2d293bb7f4b014b79d16b2fb05090fa93.zip |
Adding upstream version 1.29.0.upstream/1.29.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collectors/python.d.plugin/redis')
-rw-r--r-- | collectors/python.d.plugin/redis/README.md | 20 | ||||
-rw-r--r-- | collectors/python.d.plugin/redis/redis.chart.py | 46 |
2 files changed, 45 insertions, 21 deletions
diff --git a/collectors/python.d.plugin/redis/README.md b/collectors/python.d.plugin/redis/README.md index e7ddd382c..9fab56c33 100644 --- a/collectors/python.d.plugin/redis/README.md +++ b/collectors/python.d.plugin/redis/README.md @@ -1,6 +1,12 @@ -# redis +<!-- +title: "Redis monitoring with Netdata" +custom_edit_url: https://github.com/netdata/netdata/edit/master/collectors/python.d.plugin/redis/README.md +sidebar_label: "Redis" +--> -Get INFO data from redis instance. +# Redis monitoring with Netdata + +Monitors database status. It reads server response to `INFO` command. Following charts are drawn: @@ -30,7 +36,15 @@ Following charts are drawn: - connected -## configuration +## Configuration + +Edit the `python.d/redis.conf` configuration file using `edit-config` from the Netdata [config +directory](/docs/configure/nodes.md), which is typically at `/etc/netdata`. + +```bash +cd /etc/netdata # Replace this path with your Netdata config directory, if different +sudo ./edit-config python.d/redis.conf +``` ```yaml socket: diff --git a/collectors/python.d.plugin/redis/redis.chart.py b/collectors/python.d.plugin/redis/redis.chart.py index 40ccb5274..e09916d86 100644 --- a/collectors/python.d.plugin/redis/redis.chart.py +++ b/collectors/python.d.plugin/redis/redis.chart.py @@ -5,7 +5,6 @@ # SPDX-License-Identifier: GPL-3.0-or-later import re - from copy import deepcopy from bases.FrameworkServices.SocketService import SocketService @@ -37,7 +36,6 @@ PIKA_ORDER = [ 'uptime', ] - CHARTS = { 'operations': { 'options': [None, 'Operations', 'operations/s', 'operations', 'redis.operations', 'line'], @@ -53,8 +51,9 @@ CHARTS = { ] }, 'memory': { - 'options': [None, 'Memory utilization', 'KiB', 'memory', 'redis.memory', 'line'], + 'options': [None, 'Memory utilization', 'KiB', 'memory', 'redis.memory', 'area'], 'lines': [ + ['maxmemory', 'max', 'absolute', 1, 1024], ['used_memory', 'total', 'absolute', 1, 1024], ['used_memory_lua', 'lua', 'absolute', 1, 1024] ] @@ -156,6 +155,7 @@ class Service(SocketService): self.auth_request = 'AUTH {0} \r\n'.format(p).encode() if p else None self.request = 'INFO\r\n'.encode() self.bgsave_time = 0 + self.keyspace_dbs = set() def do_auth(self): resp = self._get_raw_data(request=self.auth_request) @@ -189,23 +189,38 @@ class Service(SocketService): :return: dict """ data = self.get_raw_and_parse() - if not data: return None + self.calc_hit_rate(data) + self.calc_redis_keys(data) + self.calc_redis_rdb_save_operations(data) + return data + + @staticmethod + def calc_hit_rate(data): try: - data['hit_rate'] = ( - (int(data['keyspace_hits']) * 100) / (int(data['keyspace_hits']) + int(data['keyspace_misses'])) - ) + hits = int(data['keyspace_hits']) + misses = int(data['keyspace_misses']) + data['hit_rate'] = hits * 100 / (hits + misses) except (KeyError, ZeroDivisionError): data['hit_rate'] = 0 - if data.get('redis_version') and data.get('rdb_bgsave_in_progress'): - self.get_data_redis_specific(data) - - return data - - def get_data_redis_specific(self, data): + def calc_redis_keys(self, data): + if not data.get('redis_version'): + return + # db0:keys=2,expires=0,avg_ttl=0 + new_keyspace_dbs = [k for k in data if k.startswith('db') and k not in self.keyspace_dbs] + for db in new_keyspace_dbs: + self.keyspace_dbs.add(db) + self.charts['keys_redis'].add_dimension([db, None, 'absolute']) + for db in self.keyspace_dbs: + if db not in data: + data[db] = 0 + + def calc_redis_rdb_save_operations(self, data): + if not (data.get('redis_version') and data.get('rdb_bgsave_in_progress')): + return if data['rdb_bgsave_in_progress'] != '0': self.bgsave_time += self.update_every else: @@ -229,11 +244,6 @@ class Service(SocketService): for n in self.order: self.definitions.update(copy_chart(n)) - if data.get('redis_version'): - for k in data: - if k.startswith('db'): - self.definitions['keys_redis']['lines'].append([k, None, 'absolute']) - return True def _check_raw_data(self, data): |