Search code examples
redisamazon-elasticache

Does `info memory` return the status of one node in a redis cluster?


My Elasticache cluster has the following settings/parameters

Node type: cache.r5.xlarge
Shards: 15
Number of nodes: 30
reserved-memory-percent: 25

cache.r5.xlarge has memory of 26.32 GiB. So the total memory should be 26.32 * 30 * 0.75 = 592.2 GiB

And running info memory in RedisInsight-v2 got maxmemory_human:19.74G. And 19.74 * 30 = 592.2 GiB

Does info memory return the status of one node? I will need to monitor the usage of the whole cluster (Comparing used_memory_human with maxmemory_human). How can I get the status of all nodes? BTW, how to run RedisInsight-v2 as a command line too so I can automate the comparison?


Solution

  • All of the information you get out of the info Redis command is about the specific node you're connected to, other than the Replication section, which obviously has information on master/replicas depending on the node's role. There's no Redis command built-in that will retrieve these metrics for an entire cluster, but you can loop through your nodes to collect it.

    As to how to do this on the command line, I'd recommend the basic redis-cli tool, which does work with an ElastiCache node as long as security groups allow you to access it (either directly on 6379 or via ssh, etc.):

    redis-cli -h your.elasticache.cluster.endpoint.example.com --user myuser --askpass --tls
    

    The --user, --askpass, and --tls options assume you're using Redis version > 6.0.

    You can also get similar data (though not exactly what you're looking for) in AWS CloudWatch:

    1. Open the CloudWatch service
    2. In the hamburger menu, expand Metrics, then select Explorer. This will open an empty Explorer template
    3. Click the dropdown where it says "Empty Explorer", then under "Service Templates" select ElastiCache. This template adds 14 CloudWatch metrics to Explorer, but only includes the "Freeable Memory" metric
    4. Click the search bar under the "Metrics" section and either add just DatabaseMemoryUsagePercentage, or you can add all other available metrics by selecting All ElastiCache CacheCluster Metrics
    5. These metrics default to an average over the Period value at the bottom.
    6. In the "From" section, select the applicable resource and the metrics should show up in the graph.

    Here's the graph for a test cluster I have: enter image description here

    Once you have the metrics graphed, you can add them to a dashboard so you don't have to go through the steps above.