joeferner / redis-commander

Redis management tool written in node.js
http://joeferner.github.io/redis-commander/
MIT License
3.61k stars 467 forks source link

Feature request: Auto discovery for for multiple dbIndex in the same redis cluster #555

Open devopsmash opened 8 months ago

devopsmash commented 8 months ago

It would be great to have the ability to auto-discover all dbIndexes in use within the same Redis cluster, rather than having to manually specify them multiple times in the configuration (like here).

in redis cli it can be detected with the command redis-cli INFO or INFO keyspace, in order to get the relevant db indexes that are in use (more info here).

sseide commented 8 months ago

Auto discovery is already available for a long time via menu -> add server. What else do you need or is not working?

And redis CLUSTER does not support multiple databases, therefor no use of auto-detection there. From Redis docs:

Redis Cluster does not support multiple databases like the standalone version of Redis. We only support database 0; the SELECT command is not allowed.

https://redis.io/docs/reference/cluster-spec/ section "Implemented subset"

devopsmash commented 8 months ago

Thank you @sseide for your reply.

Usually I'm using the the default_json to config my connections with something like this

  "connections": [
    {
      "label": "redis-first-db",
      "dbIndex": 0,
      "username": "myuser",
      "password": "mypass",
      "connectionName": "redis-commander",
      "optional": false,
      "clusterNoTlsValidation": false,
      "host": "redis-replication-group-stg-001.redis-replication-group-stg...",
      "port": 6379,
      "isCluster": false,
      "sentinelUsername": null,
      "sentinelPassword": "",
      "tls": {}
    },
    {
      "label": "redis-second-db",
      "dbIndex": 1,
      "username": "myuser",
      "password": "mypass",
      "connectionName": "redis-commander",
      "optional": false,
      "clusterNoTlsValidation": false,
      "host": "redis-replication-group-stg-001.redis-replication-group-stg...",
      "port": 6379,
      "isCluster": false,
      "sentinelUsername": null,
      "sentinelPassword": "",
      "tls": {}
    },

As you can see in the above configuration, I have the same redis host endpoint (in this cache AWS Elasticache), but with different dbIndex.

It will be great, if I can add 1 connection for the same redis host endpoint without mention dbIndex, and the redis-commander will be able to auto discover the existing db dbIndexes (in this case dbIndex 0 & dbIndex 1).

maybe something like this:

  "connections": [
    {
      "label": "redis-first-db",
      "dbIndex": "auto-discovery",
      "username": "myuser",
      "password": "mypass",
      "connectionName": "redis-commander",
      "optional": false,
      "clusterNoTlsValidation": false,
      "host": "redis-replication-group-stg-001.redis-replication-group-stg...",
      "port": 6379,
      "isCluster": false,
      "sentinelUsername": null,
      "sentinelPassword": "",
      "tls": {}
    },
sseide commented 8 months ago

mmmh - but this kind of auto-detection would only work in the very start of Redis-Commander. Every dataabse used later for the first time is not found.

What about databases used but not holding any keys at the moment of RC startup (e.g. no temp session stored there or similar - might be the case for DEV/STG environments. Or, on system recovery where everything is setup new and RC started before other components use Redis. Using auto-Discovery here for automated setups might lead to unsuspected outcomes or a false feeling of "i see everything used"... I would go the way to state databases used explicit on production systems.

So - if someone is going to implement the feature i will have a look at it. But no time myself for implementation.