Redis is an open-source, networked, in-memory, key-value data store. It’s being heavily used every where from Web stack to Monitoring to Message queues. Monitoring tools like Sensu already has some good scripts to Monitor Redis. Last Month during PyCon 2014 @Plivo, opensourced a new rate limited queue called SHARQ which is based on Redis. So apart from just Monitoring checks, we decided to have a tsdb of what’s happening in our Redis Cluster. Since we are heavily using ELK stack to visualize our infrastructure, we decided to go ahead with the same.
CollectD Redis Plugin
There is a cool CollectD plugin for Redis. It pulls a verity of Data from Redis which includes, Memory used, Commands Processed, No. of Connected Clients and slaves, No. of blocked Clients, No. of Keys stored/db, uptime and challenges since last save. The installation is pretty simple and straight forward.
$ apt-get update && apt-get install collectd $ git clone https://github.com/powdahound/redis-collectd-plugin.git /tmp/redis-collectd-plugin
Now place the
redis_info.py file onto the collectd folder and enable the Python Plugins so that collectd can use this python file. Below is our collectd conf
Hostname "<redis-server-fqdn>" Interval 10 Timeout 4 Include "/etc/collectd/filters.conf" Include "/etc/collectd/thresholds.conf" LoadPlugin network ReportStats true LogLevel info Include "/etc/collectd/redis.conf" # This is the configuration for the Redis plugin <Plugin network> Server "<logstash-fqdn>" "<logstash-collectd-port>" </Plugin>
Now copy the redis python plugin and the conf file to collectd folder.
$ mkdir /etc/collectd/plugin # This is where we are going to place our custom plugins $ cp /tmp/redis-collectd-plugin/redis_info.py /etc/collectd/plugin/ $ cp /tmp/redis-collectd-plugin/redis.conf /etc/collectd/
By default, the plugin folder in the
redis.conf is defined as ‘/opt/collectd/lib/collectd/plugins/python’. Make sure to replace this with the location where we are copying the plugin file, in our case “/etc/collectd/plugin”. Now lets restart the collectd daemon to enable the redis plugin.
$ /etc/init.d/collectd stop $ /etc/init.d/collectd start
In my previous Blog, i’ve mentioned how to enable and use the ColectD input plugin in Logstash and to use Kibana to plot the data coming from the collectd. Below are the Data’s that we are receiving from the CollectD on Logstash,
1) type_instance: blocked_clients 2) type_instance: evicted_keys 3) type_instance: connected_slaves 4) type_instance: commands_processed 5) type_instance: connected_clients 6) type_instance: used_memory 7) type_instance: <dbname>-keys 8) type_instance: changes_since_last_save 9) type_instance: uptime_in_seconds 10) type_instance: connections_received
Now we need to Visualize these via Kibana. Lets create some ElasticSearch queries so that visualize them directly. Below are some sample queries created in Kibana UI.
1) type_instance: "commands_processed" AND host: "<redis-host-fqdn>" 2) type_instance: "used_memory" AND host: "<redis-host-fqdn>" 3) type_instance: "connections_received" AND host: "<redis-host-fqdn>" 4) type_instance: "<dbname>-keys" AND host: "<redis-host-fqdn>"
Now We have some sample queries, lets visualize them.
Now create histograms in the same procedure by changing the Selected Queries.