What is Redis CLI?

External programs talk to Redis using a TCP socket and a Redis-specific protocol. However, to make hacking with Redis simpler, Redis provides a command-line utility that sends commands to Redis. This program is called redis-cli.

Mikhail Volkov

--

What is Redis CLI?

Is it the simplest way to interact with the Redis database, and what are the alternatives?

Redis-cli is a simple program that allows sending commands to Redis and reading the server's replies directly from the terminal. To connect to the Redis database, you will need to provide a host, port, and password:

$ redis-cli -u redis://passw0rd@redis-16379.hosted.com:16379/0 ping PONG

It’s not that simple to simultaneously connect to multiple databases and use SSL/TLS with a client-side certificate. When I am hacking with Redis, I like to observe database statistics, performance and avoid context switching.

Redis Insight is the GUI for streamlined Redis application development

RedisInsight provides an intuitive and efficient GUI for Redis, allowing you to interact with your databases and manage your data — with built-in support for the most popular Redis modules.

Included CLI has syntax highlighting, auto-complete, and employs integrated help to deliver intuitive, in-the-moment assistance. Databases can be added manually or automatically connecting to Redis Enterprise Cloud and Software.

Are there any other options?

At our session, “Real-time observability with Redis and Grafana” at #ObservabilityCON, we introduced the Redis Application plugin for Grafana, which includes a Redis CLI panel.

Redis CLI panel
Redis CLI panel.

Since then, we have implemented multiple updates:

  • auto-sizing
  • CLI/Raw mode switch
  • Updated help to support all upcoming Redis 6.2 commands (HRANDFIELD, FAILOVER, COPY, etc.)
  • Additional panels.

Redis Application plugin for Grafana

Redis Application plugin is officially registered in the Grafana repository and can be installed using grafana-cli or Docker.

docker run -d -p 3000:3000 --name=grafana -e "GF_INSTALL_PLUGINS=redis-app" grafana/grafana

If you are interested in trying the latest features, you are welcome to run a nightly build. It may be unstable, but it’s the best way to experience new features and panels before they are released.

docker run -p 3000:3000 --name=redis-app ghcr.io/redisgrafana/redis-app:latest

Redis Data Source for Grafana

Redis CLI and other panels require configuring Redis Data Sources for all databases to communicate with. You can do this by clicking on the Redis icon in the left side menu and the “Add Redis Data Source” button:

Redis Application plug-in
Redis Application plugin Home page.

To learn more about the data source and how to use it, please take a look at series of blog posts:

Grafana dashboards

A dashboard in Grafana is a set of one or more panels organized and arranged into one or more rows. They are customizable to suit your needs. Redis Application plugin provides three dashboards:

  • Redis CLI
  • Redis Overview
  • RedisGears
Redis Application plug-in menu
Redis Application plugin menu.

Redis CLI dashboard includes Redis CLI and Redis information panels with streaming capabilities:

Redis CLI dashboard includes Redis CLI and Redis information panels with streaming capabilities
Redis CLI dashboard includes Redis CLI and Redis information panels.

When you interact with the Redis database, you can observe real-time memory and latency changes, keys statistics, and other data. If you need additional information, you are welcome to place it on the dashboard and save it.

Did you notice the Latency and “Keys consuming a lot of memory” panels? Stay tuned for more articles.

Working with multiple Redis databases

I like to see and interact with multiple databases at the same time. Creating and organizing CLI and Ops/Sec panels on a dashboard, I can work with four Redis databases simultaneously:

Dashboard to work with four databases the same time
Dashboard to work with four databases at the same time.

Do you use Redis Streams, RedisTimeSeries, RediSearch, or RedisGraph modules? You can display the Redis data next to the Redis database information and metrics.

What’s next?

It is the first article in the series for the Redis Application plugin, which provides four panels:

  • Command-line interface (CLI)
  • Command Latency (graph and table)
  • Keys consuming a lot of memory
  • RedisGears

Please ask a question, request a new feature, and file a bug with GitHub issues. Star the repository to show your support.

Volkov Labs is an agency founded by long-time Grafana contributor Mikhail Volkov. We find elegant solutions for non-standard tasks.

Check out the latest plugins and projects at https://volkovlabs.io

--

--