Skip to content

feat(redis): add slowlog panel and integrate with backend APIs#1484

Open
dal1wg wants to merge 3 commits into
t8y2:mainfrom
dal1wg:feature/redis-slowlog
Open

feat(redis): add slowlog panel and integrate with backend APIs#1484
dal1wg wants to merge 3 commits into
t8y2:mainfrom
dal1wg:feature/redis-slowlog

Conversation

@dal1wg

@dal1wg dal1wg commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Purpose

Add a Slow Log panel for Redis connections, enabling users to retrieve and display SLOWLOG entries from the
current Redis server. The panel is integrated as the 4th tab in the existing Redis sidebar (Key Detail /
Command Line / PubSub / Slow Log), maintaining consistent UI styling.

Changes

Rust Backend (6 files)

  • crates/dbx-core/src/db/redis_driver.rs

    • Added RedisSlowlogEntry struct with fields: id, timestamp, duration_micros, command, client_addr,
      client_name
    • Added get_slowlog() function to execute SLOWLOG GET <count> and parse the nested array response
    • Added helper functions redis_raw_value_to_optional_string() and redis_value_to_u64()
    • Changed connect_cluster_node() visibility to pub for direct node connections in cluster mode
  • crates/dbx-core/src/redis_ops.rs

    • Added redis_slowlog_get_core(): supports standalone direct query, cluster+node direct query, and
      cluster without node (returns empty); skips select_db as SLOWLOG is a server-level command
    • Added redis_cluster_master_nodes_core(): returns cluster master node list (empty for sentinel)
  • src-tauri/src/commands/redis_cmd.rs

    • Added redis_slowlog_get and redis_cluster_master_nodes Tauri commands
  • src-tauri/src/lib.rs

    • Registered both commands in the invoke_handler
  • crates/dbx-web/src/main.rs

    • Added routes POST /redis/slowlog-get and POST /redis/cluster-master-nodes
  • crates/dbx-web/src/routes/redis.rs

    • Added SlowlogGetRequest and ClusterNodesRequest request structs
    • Added slowlog_get and cluster_master_nodes handler functions

Frontend (5 files)

  • apps/desktop/src/lib/tauri.ts

    • Added RedisSlowlogEntry and RedisNodeEndpoint type definitions
    • Added redisSlowlogGet() and redisClusterMasterNodes() function implementations
  • apps/desktop/src/lib/http.ts

    • Added HTTP client implementations and type imports
  • apps/desktop/src/lib/api.ts

    • Added forward exports and type exports
  • apps/desktop/src/components/redis/RedisSlowlogPanel.vue (new)

    • Count input (1~10000)
    • Node dropdown selector in cluster mode
    • Query button
    • 6-column sortable table (ID / Timestamp / Duration / Command / Client Address / Client Name), all left-
      aligned
    • Virtual scrolling via RecycleScroller for large result sets
    • Click a row to open a Dialog showing the full details of that slow log entry
    • Timestamp formatted as YYYY-MM-DD HH:mm:ss, null values displayed as NIL
    • Sentinel connections use the direct query path (no node selector needed)
  • apps/desktop/src/components/redis/RedisKeyBrowser.vue

    • Extended RedisSidePanel type to include "slowlog"
    • Added TabTrigger (Clock icon + "Slow Log") and TabContent

Internationalization (2 files)

  • apps/desktop/src/i18n/locales/en.ts — Added 15 slowlog translation keys
  • apps/desktop/src/i18n/locales/zh-CN.ts — Added 15 slowlog translation keys

Related Issue

Close #1481

@dal1wg

dal1wg commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

Preview

  • Cluster Mode
dbx_redis-add slowlog1 dbx_redis-add slowlog
  • Standalone Mode
dbx_redis-add slowlog2

@t8y2 t8y2 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #1484: feat(redis): add slowlog panel and integrate with backend APIs

+541/-4, 13 files | CI: pass | Mergeable: MERGEABLE

🔴 Must Fix

  • crates/dbx-core/src/db/redis_driver.rs:1280: get_slowlog() skips entries with fewer than 5 fields, but SLOWLOG GET only added client address/name fields in Redis 4.0. Redis 2.2.12-3.x, and some Redis Software/Cloud responses, can return the older 4-field entry shape. On those servers this panel will show an empty slow log even when entries exist. Please accept fields.len() >= 4 and treat client_addr / client_name as optional.

🟡 Suggestions

  • apps/desktop/src/components/redis/RedisSlowlogPanel.vue:46: cluster node values are encoded as "host:port" and later split on ":", which breaks IPv6 hosts. Prefer storing the selected endpoint object or using a stable serialized value like JSON.

  • crates/dbx-core/src/db/redis_driver.rs:1336: empty bulk-string arguments are converted to None, so a slowlog command like SET key "" displays as SET key. Binary/non-UTF-8 args are also dropped. Reusing the existing Redis display conversion would make command rendering more faithful.

✅ Well Done

The backend routes, Tauri commands, HTTP client, and API forwarding are wired consistently. Cluster mode also correctly queries a selected node rather than pretending slowlog is cluster-global.

Verdict

Request changes for the Redis slowlog parser compatibility issue. CI is green, but the 4-field slowlog shape is a real behavior regression for older or non-OSS-compatible Redis deployments.

@dal1wg

dal1wg commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

Understood. I will fix it.

@dal1wg dal1wg requested a review from t8y2 June 20, 2026 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[💡 Feature] Redis新增slowlog功能面板

2 participants