-
Notifications
You must be signed in to change notification settings - Fork 6
Know Your Redis Server Information Status Simply via HTTP API
Redis CLI provides a nice command "INFO" to allow users to understand the information and statistics about the server. The information it provides include
- general information about the Redis server
- client connections
- memory consumption
- CPU consumption
- etc.
Now with Rediseen
(as from version 2.1.0), you can expose & read these information much more conveniently, simply via HTTP API.
brew install XD-DENG/rediseen/rediseen
export REDISEEN_REDIS_URI="redis://:@localhost:6379"
export REDISEEN_DB_EXPOSED=0
export REDISEEN_KEY_PATTERN_EXPOSED="key pattern you would like to expose"
rediseen start
(REDISEEN_KEY_PATTERN_EXPOSED
is intended to help you specify the Redis keys you expose to clients (that's what Rediseen is mainly designed for). If you prefer to run Rediseen ONLY for exposing results of INFO
command, simply put a value which doesn't match with any of your keys in Redis.)
Now you're ready to go!
curl -s http://localhost:8000/info
You can also specify which exact section you want, so the network I/O will be much smaller. For example, if you are only interested in CPU consumption, you can specify "cpu" in the URL.
curl -s http://localhost:8000/info/cpu
Rediseen
also supports API Key authentication. Simply run the line below before your start Rediseen
service.
export REDISEEN_API_KEY="demo_key"
Once it is set, client will have to add the API key as X-API-KEY in their HTTP header in order to access the service, otherwise 401 error (Unauthorized
) will be returned.
# REJECTED: No X-API-KEY is given in HTTP header
curl -s http://localhost:8000/info
{
"error": "unauthorized"
}
# REJECTED: Wrong X-API-KEY is given in HTTP header
curl -s -H "X-API-KEY: wrong_key" http://localhost:8000/info
{
"error": "unauthorized"
}
# ACCEPTED: Correct X-API-KEY is given in HTTP header
curl -s -H "X-API-KEY: demo_key" http://localhost:8000/info/server
{
"Server": {
"arch_bits": "64",
"atomicvar_api": "atomic-builtin",
"configured_hz": "10",
"gcc_version": "4.2.1",
... ...
}
}