valkey-io / valkey

A new project to resume development on the formerly open-source Redis project. We're calling it Valkey, since it's a twist on the key-value datastore.
https://valkey.io
Other
14.6k stars 520 forks source link

Extended Valkey client introspection functionality #668

Open madolson opened 2 weeks ago

madolson commented 2 weeks ago

We want to standardize the way that admin users can describe and interact with the client commands. We are proposing to generalize the filters introduced in CLIENT KILL so that it also works to count and list clients as well.

In the end, we will support the following 4 commands.

CLIENT COUNT <filters>
CLIENT KILL <filters>
CLIENT LIST <filters>

The supported filters will be:

TYPE [NORMAL|MASTER|PRIMARY|SLAVE|REPLICA|PUBSUB]
USER username
ADDR ip:port
LADDR ip:port
SKIPME [yes|no]
ID client-id
ID client-id [client-id ...], for compatibility reasons with client list, client-id must be specified last.
PATTERN pattern the client must subscribe to
CHANNEL channel the client must subscribe to
SHARD-CHANNEL `<shard channel the client must subscribe to>`
FLAGS Client must include this flag, this option can be repeated
NAME client name
MIN-IDLE minimum idle time of the client
CLIENT DESCRIBE will allow you specify what fields you want from the client. The supported selectors will be the same as the above mentioned filters, in addition to the fields currently supported from https://redis.io/commands/client-list/.

In Redis we also discussed adding a new command, CLIENT DESCRIBE, will also introduce the notion of selectors. Selectors allow you to scope down the fields you are interested in.

CLIENT DESCRIBE SELECT ID ADDR FILTER MIN-AGE 100 
madolson commented 2 weeks ago

Originally reference from https://github.com/redis/redis/issues/12311.

hpatro commented 1 week ago

Nit Title: Extended Client Introspection functionality

The default behavior for CLIENT LIST API is all filters, and with that the response payload can be pretty huge. I think valkey-cli kind of gets stuck. With CLIENT DESCRIBE we can look to move away from the text format and have RESP format and get paginated response or adding a default COUNT value to restrict the payload size. I had tried that here https://github.com/redis/redis/pull/11907.

The downside of introducing the new API is maintaining two set of API(s) and no guarantee of administrator(s) of moving to this.

madolson commented 1 week ago

Nit Title: Extended Client Introspection functionality

Old habits die hard.

The default behavior for CLIENT LIST API is all filters, and with that the response payload can be pretty huge. I think valkey-cli kind of gets stuck. With CLIENT DESCRIBE we can look to move away from the text format and have RESP format and get paginated response or adding a default COUNT value to restrict the payload size. I had tried that here https://github.com/redis/redis/pull/11907.

I think you raise a really good point. We could add a pagination functionality by doing client-list based off of ID, and add that to client list. I think we have seen that people generally don't migrate to new commands, so it probably makes more sense to enhanced the ones we have.