Pub/Sub viewer

functional

Subscribe to channels, patterns, or every key event on a database and watch messages arrive live.

The Pub/Sub viewer subscribes to channels and patterns and shows every message as it arrives: one row per message with the time SQLly received it, the channel, the pattern it matched (for pattern subscriptions), the event and key when the message is a keyspace notification, and the payload. It lives in the Activity Monitor as the Pub/Sub tab on Redis and Redis-compatible connections (Valkey, KeyDB, Dragonfly, Amazon ElastiCache, Amazon MemoryDB). The command palette's Redis Pub/Sub Viewer… and Pub/Sub… on a Redis database's right-click menu open the monitor straight onto it.

Subscribing

Type one or more names, comma-separated, and press Subscribe. A plain name (orders) subscribes with SUBSCRIBE; a name with glob characters (alerts.*, metrics.[ab], job?) subscribes with PSUBSCRIBE. To subscribe to a channel whose name itself contains glob characters, start it with =: =orders[eu] subscribes to the channel literally named orders[eu] (write ==x for a channel named =x). Names cannot contain commas, since the comma separates them. Like the Profiler, the viewer opens a dedicated connection for this, the editor still refuses SUBSCRIBE, because a subscribed connection can no longer run ordinary commands. A subscription has no time box: Stop, switching tabs, closing the monitor (docked or popped out), disconnecting the connection, or deleting it closes that connection at once. To watch a sharded channel, start its name with #: #orders subscribes with SSUBSCRIBE, on a standalone Redis 7 server directly and on a cluster at the master that owns the channel's slot. On a cluster every row also names the node it came from.

Because the viewer dials the server itself, it needs a direct connection. On a connection routed through a relay bridge the tab explains that and Subscribe stays disabled.

Key events

Redis can publish a notification every time a key changes - set, deleted, expired, evicted, renamed, and so on, as ordinary Pub/Sub messages on two channel families: __keyevent@<db>__:<event> carries the key as its payload, and __keyspace@<db>__:<key> carries the event. The Key events button subscribes to every key event on the connection's logical database (__keyevent@3__:* on database 3) and fills the channel box with that pattern so you can see and edit what was subscribed. Type a key pattern first - user:* - and the preset also watches those keys by name (__keyspace@3__:user:*), which is the way to follow one key or one prefix instead of the whole database. You can also type either channel family by hand.

Whichever family delivered it, a notification fills the event and key columns - an expired user:42 shows expired and user:42 - while ordinary messages leave them empty. The channel, pattern, and payload columns stay as they are, so a mixed subscription reads the same way as before.

Notifications are off on a stock Redis server, so the tab reads notify-keyspace-events when it opens and says what it found. When the setting is empty, or lacks the key-event class that the preset relies on, the tab offers Enable Key Events (KEA)…: it stages CONFIG SET notify-keyspace-events KEA in the same review strip as the slow-log threshold, you see the exact statement, then press Run or Cancel - and re-reads the setting afterwards. KEA turns on both channel families for every event class, which costs a little CPU on a busy server. The change applies to the running server only; Persist (CONFIG REWRITE)… on the Expensive tab writes it to the config file. On a production connection with writes locked the button is disabled and the strip says why, and an ACL user needs +config|get to read the setting and +config|set to change it.

Reading messages

Messages list newest first. Pause stops recording without dropping the subscription (messages keep arriving and are counted), and Clear empties the list. The list is capped - 1,000 messages by default, adjustable up to 100,000 - and when it is full the oldest messages are dropped; the status line counts how many. The table shows at most the newest 2,000 of them, and the status line says so when the list holds more. The table keeps your place while messages arrive: the selected message stays selected (until it is dropped from the list), and if you scroll down the rows you are reading stay put, so you can select a row on a busy channel and Preview Payload opens that message in the value viewer, where the format picker can show it as text, pretty JSON, hex, or decoded MessagePack. Binary payloads are kept byte-exact and shown as hex rather than mangled into text, and a channel or pattern name that is not valid UTF-8 shows its bytes as \xHH escapes.

A message can be up to 512 MB, so the viewer keeps at most the first 64 KiB of each payload (and the first 1 KiB of a channel or pattern name). A cut payload says so in the table, as … (truncated, N bytes) with its full size, and Preview Payload opens the part that was kept with a notice giving both sizes. The whole list is also held to 64 MB: past that the oldest messages are dropped, and counted, the same way as when the message cap is reached.

SQLly
Redis Pub/Sub viewer: channel and pattern subscriptions, live messages newest first, and the message cap in the status line.Redis Pub/Sub viewer: channel and pattern subscriptions, live messages newest first, and the message cap in the status line.
Redis Pub/Sub viewer: channel and pattern subscriptions, live messages newest first, and the message cap in the status line.

Pub/Sub messages are fire-and-forget: the viewer only sees what is published while it is subscribed, and nothing is replayed. An ACL user needs the +subscribe / +psubscribe permissions and access to the channels (&pattern).