cluster-slot-stats.3valkey - Man Page

Return an array of slot usage statistics for slots assigned to the current node.

Synopsis

CLUSTER SLOT-STATS SLOTSRANGE start-slot end-slot

CLUSTER SLOT-STATS ORDERBY metric [LIMIT limit] [ASC | DESC]

Description

Returns an array of slot usage statistics for slots assigned to the current shard. 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.

The following statistics are supported:

Options

Reply

valkey-protocol(7) Array reply: nested list of slot usage statistics.

Complexity

O(N) where N is the total number of slots based on arguments. O(N*log(N)) with ORDERBY subcommand.

Acl Categories

@slow

History

Examples

Response in RESP2

For ORDERBY:

> CLUSTER SLOT-STATS ORDERBY KEY-COUNT LIMIT 2 DESC
1) 1) (integer) 12426
   2) 1) "key-count"
      2) (integer) 45
      3) "cpu-usec"
      4) (integer) 0
      5) "network-bytes-in"
      6) (integer) 0
      7) "network-bytes-out"
      8) (integer) 0
2) 1) (integer) 13902
   2) 1) "key-count"
      2) (integer) 20
      3) "cpu-usec"
      4) (integer) 0
      5) "network-bytes-in"
      6) (integer) 0
      7) "network-bytes-out"
      8) (integer) 0

For SLOTSRANGE:

> CLUSTER SLOT-STATS SLOTSRANGE 0 1
1) 1) (integer) 0
   2) 1) "key-count"
      2) (integer) 0
      3) "cpu-usec"
      4) (integer) 0
      5) "network-bytes-in"
      6) (integer) 0
      7) "network-bytes-out"
      8) (integer) 0
2) 1) (integer) 1
   2) 1) "key-count"
      2) (integer) 0
      3) "cpu-usec"
      4) (integer) 0
      5) "network-bytes-in"
      6) (integer) 0
      7) "network-bytes-out"
      8) (integer) 0

Response in RESP3

For ORDERBY:

> CLUSTER SLOT-STATS ORDERBY KEY-COUNT LIMIT 2 DESC
1) 1) (integer) 12426
   2) 1# "key-count" => (integer) 45
      2# "cpu-usec" => (integer) 0
      3# "network-bytes-in" => (integer) 0
      4# "network-bytes-out" => (integer) 0
2) 1) (integer) 13902
   2) 1# "key-count" => (integer) 20
      2# "cpu-usec" => (integer) 0
      3# "network-bytes-in" => (integer) 0
      4# "network-bytes-out" => (integer) 0

For SLOTSRANGE:

> CLUSTER SLOT-STATS SLOTSRANGE 0 1
1) 1) (integer) 0
   2) 1# "key-count" => (integer) 0
      2# "cpu-usec" => (integer) 0
      3# "network-bytes-in" => (integer) 0
      4# "network-bytes-out" => (integer) 0
2) 1) (integer) 1
   2) 1# "key-count" => (integer) 0
      2# "cpu-usec" => (integer) 0
      3# "network-bytes-in" => (integer) 0
      4# "network-bytes-out" => (integer) 0

See Also

asking(3valkey), cluster(3valkey), cluster-addslots(3valkey), cluster-addslotsrange(3valkey), cluster-bumpepoch(3valkey), cluster-count-failure-reports(3valkey), cluster-countkeysinslot(3valkey), cluster-delslots(3valkey), cluster-delslotsrange(3valkey), cluster-failover(3valkey), cluster-flushslots(3valkey), cluster-forget(3valkey), cluster-getkeysinslot(3valkey), cluster-help(3valkey), cluster-info(3valkey), cluster-keyslot(3valkey), cluster-links(3valkey), cluster-meet(3valkey), cluster-myid(3valkey), cluster-myshardid(3valkey), cluster-nodes(3valkey), cluster-replicas(3valkey), cluster-replicate(3valkey), cluster-reset(3valkey), cluster-saveconfig(3valkey), cluster-set-config-epoch(3valkey), cluster-setslot(3valkey), cluster-shards(3valkey), cluster-slots(3valkey), readonly(3valkey), readwrite(3valkey)

Info

2025-01-08 8.0.2 Valkey Command Manual