|
| 1 | +Returns an array of slot usage statistics for slots assigned to the current shard. |
| 2 | +The command is suitable for Valkey Cluster users aiming to assess general slot usage trends, identify hot / cold slots, migrate slots for a balanced cluster workload, and / or re-write application logic to better utilize slots. |
| 3 | + |
| 4 | +The following statistics are supported: |
| 5 | + |
| 6 | +* `key-count` -- Number of keys residing in a given slot. |
| 7 | +* `cpu-usec` -- Amount of CPU time (in microseconds) spent on a given slot. |
| 8 | +* `network-bytes-in` -- Amount of network ingress (in bytes) received for given slot. |
| 9 | +* `network-bytes-out` -- Amount of network egress (in bytes) sent out for given slot. |
| 10 | + |
| 11 | +## Options |
| 12 | + |
| 13 | +* `ORDERBY` -- Returns an ordered slot statistics based on the specified statistic and sub-arguments to identify hot / cold slots across the cluster. Either `ASC` or `DESC` modifiers can be used. In the event of a tie in the stats, ascending slot number is used as a tie breaker. |
| 14 | +* `SLOTSRANGE` -- Returns slot statistics based on the slots range provided for pagination. The range is inclusive. The response is ordered in ascending slot number. |
| 15 | + |
| 16 | +## Examples |
| 17 | + |
| 18 | +### Response in RESP2 |
| 19 | + |
| 20 | +For `ORDERBY`: |
| 21 | +``` |
| 22 | +> CLUSTER SLOT-STATS ORDERBY KEY-COUNT LIMIT 2 DESC |
| 23 | +1) 1) (integer) 12426 |
| 24 | + 2) 1) "key-count" |
| 25 | + 2) (integer) 45 |
| 26 | + 3) "cpu-usec" |
| 27 | + 4) (integer) 0 |
| 28 | + 5) "network-bytes-in" |
| 29 | + 6) (integer) 0 |
| 30 | + 7) "network-bytes-out" |
| 31 | + 8) (integer) 0 |
| 32 | +2) 1) (integer) 13902 |
| 33 | + 2) 1) "key-count" |
| 34 | + 2) (integer) 20 |
| 35 | + 3) "cpu-usec" |
| 36 | + 4) (integer) 0 |
| 37 | + 5) "network-bytes-in" |
| 38 | + 6) (integer) 0 |
| 39 | + 7) "network-bytes-out" |
| 40 | + 8) (integer) 0 |
| 41 | +``` |
| 42 | + |
| 43 | +For `SLOTSRANGE`: |
| 44 | +``` |
| 45 | +> CLUSTER SLOT-STATS SLOTSRANGE 0 1 |
| 46 | +1) 1) (integer) 0 |
| 47 | + 2) 1) "key-count" |
| 48 | + 2) (integer) 0 |
| 49 | + 3) "cpu-usec" |
| 50 | + 4) (integer) 0 |
| 51 | + 5) "network-bytes-in" |
| 52 | + 6) (integer) 0 |
| 53 | + 7) "network-bytes-out" |
| 54 | + 8) (integer) 0 |
| 55 | +2) 1) (integer) 1 |
| 56 | + 2) 1) "key-count" |
| 57 | + 2) (integer) 0 |
| 58 | + 3) "cpu-usec" |
| 59 | + 4) (integer) 0 |
| 60 | + 5) "network-bytes-in" |
| 61 | + 6) (integer) 0 |
| 62 | + 7) "network-bytes-out" |
| 63 | + 8) (integer) 0 |
| 64 | +``` |
| 65 | + |
| 66 | +### Response in RESP3 |
| 67 | + |
| 68 | +For `ORDERBY`: |
| 69 | +``` |
| 70 | +> CLUSTER SLOT-STATS ORDERBY KEY-COUNT LIMIT 2 DESC |
| 71 | +1) 1) (integer) 12426 |
| 72 | + 2) 1# "key-count" => (integer) 45 |
| 73 | + 2# "cpu-usec" => (integer) 0 |
| 74 | + 3# "network-bytes-in" => (integer) 0 |
| 75 | + 4# "network-bytes-out" => (integer) 0 |
| 76 | +2) 1) (integer) 13902 |
| 77 | + 2) 1# "key-count" => (integer) 20 |
| 78 | + 2# "cpu-usec" => (integer) 0 |
| 79 | + 3# "network-bytes-in" => (integer) 0 |
| 80 | + 4# "network-bytes-out" => (integer) 0 |
| 81 | +``` |
| 82 | + |
| 83 | +For `SLOTSRANGE`: |
| 84 | +``` |
| 85 | +> CLUSTER SLOT-STATS SLOTSRANGE 0 1 |
| 86 | +1) 1) (integer) 0 |
| 87 | + 2) 1# "key-count" => (integer) 0 |
| 88 | + 2# "cpu-usec" => (integer) 0 |
| 89 | + 3# "network-bytes-in" => (integer) 0 |
| 90 | + 4# "network-bytes-out" => (integer) 0 |
| 91 | +2) 1) (integer) 1 |
| 92 | + 2) 1# "key-count" => (integer) 0 |
| 93 | + 2# "cpu-usec" => (integer) 0 |
| 94 | + 3# "network-bytes-in" => (integer) 0 |
| 95 | + 4# "network-bytes-out" => (integer) 0 |
| 96 | +``` |
0 commit comments