> ## Documentation Index
> Fetch the complete documentation index at: https://cache-pot.thatdevguy.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Observability commands: MONITOR, SLOWLOG, CLIENT, CONFIG

> Reference for Cache-Pot observability commands: MONITOR, SLOWLOG, CLIENT LIST/KILL, CONFIG GET/SET, and MEMORY USAGE.

Cache-Pot provides built-in observability commands for monitoring performance, inspecting connections, and configuring the slow query log. You can stream every command passing through the server with `MONITOR`, dig into slow queries with `SLOWLOG`, list or terminate active connections with `CLIENT`, and tune thresholds at runtime with `CONFIG GET`/`SET` — all without restarting the server.

***

### MONITOR

Streams every command dispatched by the server to your current connection. Each line includes a timestamp, the source database index and client address, and the full command with arguments. `AUTH` passwords are automatically redacted.

**Syntax:** `MONITOR`

Send `RESET` or close the connection to stop the stream. The **Profiler** page in the Cache-Pot dashboard (`http://localhost:8080`) shows the same real-time data in your browser.

```
MONITOR
# OK
# 1700000000.123456 [0 127.0.0.1:54321] "SET" "foo" "bar"
# 1700000000.124012 [0 127.0.0.1:54321] "GET" "foo"
# 1700000000.125301 [0 127.0.0.1:54322] "INCR" "counter"
```

**Returns:** `OK` then an unbounded stream of bulk strings, one per dispatched command.

<Warning>
  `MONITOR` generates one response line for every command the server executes. Under high load this can itself become a bottleneck. Use it for debugging in low-traffic environments or against a staging instance.
</Warning>

***

### SLOWLOG GET

Returns the most recent entries from the slow query log — commands that exceeded the configured `slowlog-log-slower-than` threshold.

**Syntax:** `SLOWLOG GET [count]`

Each entry contains the command ID, the Unix timestamp when it was run, the duration in microseconds, the full argument list, the client address, and the client name.

```redis theme={null}
SLOWLOG GET
# (up to 10 most recent slow entries)

SLOWLOG GET 5
# (last 5 slow entries)
```

**Returns:** Array of slow log entries. Each entry is a 6-element array: `[id, timestamp_unix, duration_us, [cmd, arg, ...], client_addr, client_name]`.

***

### SLOWLOG LEN

Returns the number of entries currently in the slow query log.

**Syntax:** `SLOWLOG LEN`

```redis theme={null}
SLOWLOG LEN
# (integer) 3
```

**Returns:** Integer — the current entry count.

***

### SLOWLOG RESET

Clears all entries from the slow query log.

**Syntax:** `SLOWLOG RESET`

```redis theme={null}
SLOWLOG RESET
# OK
```

**Returns:** `OK`.

<Note>
  The default slow query threshold is **10,000 µs (10 ms)**. Set it to `0` to log every command, or `-1` to disable slow logging entirely. The default maximum number of retained entries is **128**.
</Note>

***

### CLIENT LIST

Returns a bulk string with one connected client per line. Each line contains space-separated fields: `id`, `addr`, `name`, `age` (seconds since connection opened), `idle` (seconds since last command), and `cmd` (last command issued).

**Syntax:** `CLIENT LIST`

```redis theme={null}
CLIENT LIST
# id=3 addr=127.0.0.1:54321 name= age=12 idle=0 cmd=client|list
# id=4 addr=127.0.0.1:54322 name=worker age=305 idle=2 cmd=get
```

**Returns:** Bulk string with newline-separated client info lines.

***

### CLIENT ID

Returns the integer ID of the current connection. Useful for targeting a specific connection with `CLIENT KILL`.

**Syntax:** `CLIENT ID`

```redis theme={null}
CLIENT ID
# (integer) 3
```

**Returns:** Integer — the connection's ID.

***

### CLIENT SETNAME / GETNAME

Assigns or retrieves a human-readable name for the current connection. Named connections are easier to identify in `CLIENT LIST` output and in `MONITOR` traces.

**Syntax:** `CLIENT SETNAME name` / `CLIENT GETNAME`

```redis theme={null}
CLIENT SETNAME background-worker
# OK

CLIENT GETNAME
# "background-worker"
```

**Returns:** `CLIENT SETNAME` returns `OK`. `CLIENT GETNAME` returns the name as a bulk string, or an empty bulk string if no name has been set.

***

### CLIENT KILL

Closes a specific connection by its ID. The target connection receives an error on its next read.

**Syntax:** `CLIENT KILL ID id`

```redis theme={null}
CLIENT KILL ID 4
# (integer) 1  (one connection closed)
```

**Returns:** Integer — the number of connections killed (typically `0` or `1`).

***

### CONFIG GET

Reads the current value of a runtime configuration parameter. Supports glob patterns to match multiple parameters at once.

**Syntax:** `CONFIG GET parameter`

```redis theme={null}
CONFIG GET slowlog-log-slower-than
# 1) "slowlog-log-slower-than"
# 2) "10000"

CONFIG GET slowlog-*
# 1) "slowlog-log-slower-than"
# 2) "10000"
# 3) "slowlog-max-len"
# 4) "128"
```

**Returns:** Flat array alternating parameter name and value. Returns an empty array if no parameter matches.

***

### CONFIG SET

Updates a runtime configuration parameter without restarting the server.

**Syntax:** `CONFIG SET parameter value`

Supported parameters:

| Parameter                 | Description                                                    | Default |
| ------------------------- | -------------------------------------------------------------- | ------- |
| `slowlog-log-slower-than` | Threshold in microseconds. `0` logs everything; `-1` disables. | `10000` |
| `slowlog-max-len`         | Maximum number of slow log entries to retain.                  | `128`   |

```redis theme={null}
# Lower the threshold to catch queries slower than 5 ms
CONFIG SET slowlog-log-slower-than 5000
# OK

# Keep up to 256 slow log entries
CONFIG SET slowlog-max-len 256
# OK

# Disable slow logging entirely
CONFIG SET slowlog-log-slower-than -1
# OK
```

**Returns:** `OK` on success, or an error if the parameter name is unknown or the value is invalid.

***

### RESET

Exits `MONITOR` mode and drops all pub/sub subscriptions on the current connection. Call this to return a connection to normal command mode without closing it.

**Syntax:** `RESET`

```redis theme={null}
RESET
# RESET
```

**Returns:** Simple string `RESET`.

<Tip>
  When a long-running background connection accumulates stale subscriptions or gets stuck in `MONITOR` mode, send `RESET` to restore it to a clean state without reconnecting.
</Tip>
