Skip to content

feat: Additional streaming support for metrics and events #405

@joshrotenberg

Description

@joshrotenberg

Summary

Follow-up to #70 and PR #404. Now that we have log streaming implemented, we can expand streaming support to other monitoring and operational use cases.

Completed in PR #404

  • ✅ Log streaming with --follow flag
  • ✅ Configurable poll intervals
  • ✅ Graceful Ctrl+C handling
  • ✅ JMESPath filtering on streams

Remaining Opportunities

1. Real-time Metrics Streaming (High Priority)

Endpoints:

  • Enterprise: /v1/cluster/stats
  • Enterprise: /v1/bdbs/{id}/stats
  • Enterprise: /v1/nodes/{id}/stats

Use Cases:

  • Monitor cluster health in real-time
  • Watch database performance metrics
  • Track node resource utilization

Implementation:

# Stream cluster metrics
redisctl enterprise stats get --follow --poll-interval 5

# Stream database metrics
redisctl enterprise database stats get <id> --follow

# With filtering
redisctl enterprise stats get --follow -q 'cpu_usage'

2. Database Lifecycle Event Monitoring (Medium Priority)

Approach:

  • Poll database status changes
  • Detect and report state transitions
  • Useful during migrations, backups, scaling

Implementation:

# Watch database status
redisctl enterprise database watch <id> --follow

# Example output
[10:30:00] Database 1: active
[10:30:15] Database 1: active -> updating
[10:32:30] Database 1: updating -> active

3. Cluster Event Stream (Medium Priority)

Different from logs:

  • Logs = historical events
  • Events = real-time notifications
  • Could combine logs + alerts for comprehensive monitoring

Implementation:

# Stream cluster events (logs + alerts)
redisctl enterprise cluster events --follow

# Filter by severity
redisctl enterprise cluster events --follow --severity warning

4. Task Progress Streaming Enhancement (Low Priority)

Current state:

  • Task waiting already has progress spinner
  • Could add more detailed progress info if API provides it

Possible Enhancement:

# Current (already works)
redisctl cloud database create --wait

# Enhanced (show detailed progress)
redisctl cloud database create --wait --verbose
# Output:
# [0%] Validating configuration...
# [20%] Creating database instance...
# [60%] Configuring networking...
# [100%] Database ready

5. Multi-Resource Monitoring (Future)

Advanced use case:

  • Monitor multiple databases simultaneously
  • Aggregate metrics from multiple sources
  • Dashboard-like experience in terminal

Implementation:

# Watch multiple databases
redisctl enterprise database watch 1,2,3 --follow

# Example output (refreshing display)
DB1: active  | CPU: 45% | Mem: 2.1GB | Ops: 1.2K/s
DB2: active  | CPU: 23% | Mem: 1.5GB | Ops: 800/s
DB3: updating| CPU: 15% | Mem: 3.2GB | Ops: 0/s

Implementation Strategy

Phase 1: Stats Streaming (Recommended First)

  1. Add stream_stats() method to StatsHandler
  2. Add --follow flag to stats commands
  3. Format metrics for terminal display
  4. Support both cluster and database stats

Phase 2: Database Watching

  1. Add watch_database() method
  2. Track status changes
  3. Alert on state transitions
  4. Show relevant metrics during transitions

Phase 3: Event Aggregation

  1. Combine logs and alerts
  2. Filter by severity/type
  3. Unified event stream

Technical Approach

Reuse Streaming Infrastructure

  • Follow pattern from logs_impl.rs
  • Use same async-stream approach
  • Consistent CLI flags (--follow, --poll-interval)
  • Same Ctrl+C handling

Display Considerations

Single Value Streams (like logs):

  • Line-by-line output
  • Scrolling terminal
  • JMESPath filtering

Metrics Streams:

  • Could use refreshing display (like top)
  • Or line-by-line with timestamps
  • Consider terminal size

Multi-Resource:

  • TUI library like ratatui/tui-rs
  • Or simple table with ANSI cursor control

Dependencies

Might need:

  • crossterm - Terminal control (cursor positioning, clear screen)
  • ratatui - Full TUI framework (if doing dashboard-like displays)
  • Or stick with simple line-by-line output

Priority Recommendation

  1. High: Stats streaming - Most valuable for operational monitoring
  2. Medium: Database watching - Useful during operations
  3. Low: Enhanced task progress - Current implementation is good
  4. Future: Multi-resource dashboard - Nice to have, complex

Success Metrics

  • Real-time monitoring without separate tools
  • Reduced time to detect issues
  • Better operational visibility
  • Positive user feedback

Related

Notes

  • All streaming uses polling since APIs don't support SSE/WebSockets
  • Poll intervals should be configurable (balance freshness vs load)
  • Follow established patterns from log streaming
  • Maintain consistency in CLI flags and behavior

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions