redis-lister
v1.1.3
Published
Command-line tool to monitor Redis keys in realtime
Downloads
4
Maintainers
Readme
redis-lister
Command-line tool to monitor Redis keys in realtime. Useful when you are using Redis as a queue job to monitor your keys, for example. Or for debugging.
Demo (full size):
Features
- Specify hostname and update interval
- Specify monitored keys and their types
- Automatically reconnecting Redis if disconnecting
- Handling errors correctly (e.g. when the wrong key type is specified)
- Friendly user-interface (thanks to blessed and blessed-contrib!)
Installation and running
npm install -g redis-lister
redis-lister path/to/config.json
Configuration
The second argument to redis-lister
should be an absolute or a relative path to JSON configuration file. Check out the example config.
The fields that are used:
- host - A connection string to connect to Redis. Example:
redis://localhost:6379/0
- keys - List of monitored keys. An object.
- commands List of custom commands (see below). Not necessary.
- updateInterval - A number that specifies an interval (in millisecons - 1000 === 1s) of keys refreshing. Example:
100
.
The keys
object contains a list of monitored keys, where key name is a Redis key name, and the key value is a Redis command keyword (see the already defined keywords below).
Each field of the keys
object can be either a string or an array of strings. Using the array can be useful when you want to monitor the same object with 2 different commands (e.g. display a list and its content).
The command names are case-insensitive (both zcount
and ZCOUNT
are the same), however the keys names are case-sensitive (the list
and LIST
are two different objects).
Example:
"keys": {
"key1": "zcount",
"key2": "llen",
"key3": ["hget", "hkeys"],
"key4": "get"
"key5": "scard",
},
This config will display 6 entries (the key3
entry will be displayed twice with hget
and hkeys
commands).
If the config is wrong, an error will be thrown.
How does it work?
This tool sends a batch
query to a Redis server each updateInterval
milliseconds. After that, it uses blessed
and blessed-contrib
to display the result.
The prefedined commands keywords are :
- get -
GET name
- hlen -
HLEN name
- llen -
LLEN name
- scard -
SCARD name
- zrange -
ZRANGE name -inf +inf
If the key contains a value of the wrong type, the error message will be dislayed instead of the result.
Note that the LIST name
command returns null
if the key is not set, while other commands return 0
.
You can define your own commands by setting the commands
field, where the key is the command keyword and the value is a command (%NAME%
is replaced by key name). Example:
"commands": {
"listitems": "lrange %name% 0 -1"
},
"keys": {
"list": "listitems"
}
Dependencies
blessed
andblessed-contrib
- for the fancy UIredis
- for Redis connection and fetching data.moment
- for displaying timestampscolors
- for fancy colored log outputdeep-assign
- for loading user settings