Skip to content
Snippets Groups Projects
Commit 9a564252 authored by Andrey Kuzmin's avatar Andrey Kuzmin Committed by Oliver
Browse files

Streams metrics support. (#237)

* Streams metrics support.

There are new key type in Redis 5 - Streams.
So, we get ability to monitor them.

* Test for stream.
parent ab77af43
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -149,7 +149,7 @@ REDIS_FILE | Path to file containing Redis node(s)
Most items from the INFO command are exported,
see https://redis.io/commands/info for details.\
In addition, for every database there are metrics for total keys, expiring keys and the average TTL for keys in the database.\
You can also export values of keys if they're in numeric format by using the `-check-keys` flag. The exporter will also export the size (or, depending on the data type, the length) of the key. This can be used to export the number of elements in (sorted) sets, hashes, lists, etc.
You can also export values of keys if they're in numeric format by using the `-check-keys` flag. The exporter will also export the size (or, depending on the data type, the length) of the key. This can be used to export the number of elements in (sorted) sets, hashes, lists, streams, etc.
 
If you require custom metric collection, you can provide a [Redis Lua script](https://redis.io/commands/eval) using the `-script` flag. An example can be found [in the contrib folder](./contrib/sample_collect_script.lua).
 
Loading
Loading
Loading
Loading
@@ -796,6 +796,10 @@ func getKeyInfo(c redis.Conn, key string) (info keyInfo, err error) {
if size, err := redis.Int64(c.Do("HLEN", key)); err == nil {
info.size = float64(size)
}
case "stream":
if size, err := redis.Int64(c.Do("XLEN", key)); err == nil {
info.size = float64(size)
}
default:
err = fmt.Errorf("Unknown type: %v for key: %v", info.keyType, key)
}
Loading
Loading
Loading
Loading
@@ -839,6 +839,7 @@ func TestGetKeyInfo(t *testing.T) {
"4", "zsetval4",
"5", "zsetval5",
}},
keyFixture{"XADD", "key_info_test_stream", []interface{}{"*", "field1", "str1"}},
}
 
createKeyFixtures(t, c, fixtures)
Loading
Loading
@@ -855,6 +856,7 @@ func TestGetKeyInfo(t *testing.T) {
"key_info_test_list": 3,
"key_info_test_set": 4,
"key_info_test_zset": 5,
"key_info_test_stream": 1,
}
 
// Test all known types
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment