Skip to content

Conversation

@joshrotenberg
Copy link
Collaborator

Summary

Implements Phase 2 of issue #405 - Database Lifecycle Event Monitoring

Adds a subcommand for monitoring Redis Enterprise database status changes in real-time.

Changes

Library ()

  • Added method to that streams database status updates
  • Returns an async stream that polls database info at configurable intervals
  • Detects status transitions and includes previous status for comparison
  • Uses type alias to reduce complexity

CLI ()

  • Added command
  • Supports flag (default: 5 seconds)
  • Ctrl+C handling for graceful shutdown
  • Timestamped output with status transitions highlighted
  • Shows key metrics (memory, ops/sec, connections)
  • Supports JMESPath filtering via flag

Example Usage

# Watch database with default 5-second interval
redisctl enterprise database watch 1

# Custom poll interval
redisctl enterprise database watch 1 --poll-interval 10

# Filter with JMESPath
redisctl enterprise database watch 1 --query 'status'

Output Format

Watching database 1 (Ctrl+C to stop)...

[10:30:15] Database 1: active | Memory: 5.2MB / 10.0MB | Ops: 120/sec | Conns: 5
[10:30:20] Database 1: active -> pending (TRANSITION)
[10:30:25] Database 1: pending | Memory: 5.2MB / 10.0MB

Testing

  • Tested against Docker Redis Enterprise cluster
  • All unit tests pass
  • Verified Ctrl+C handling works correctly
  • Confirmed status transition detection

Closes #405

…itoring

Implements Phase 2 of issue #405 - Database Lifecycle Event Monitoring

## Library Changes (redis-enterprise)
- Add watch_database() method to DatabaseHandler/BdbHandler
- Polls database endpoint and tracks status changes
- Returns stream of (DatabaseInfo, Option<String>) tuples
- Second element is Some(old_status) when status changes occur

## CLI Changes (redisctl)
- New command: redisctl enterprise database watch <id>
- Displays timestamped status updates with key metrics
- Highlights status transitions prominently
- Supports JMESPath filtering via -q flag
- Ctrl+C for graceful shutdown
- Configurable poll interval (default: 5 seconds)

## Use Cases
- Monitor database during upgrades/migrations
- Watch backup/restore operations
- Track scaling operations
- Detect and alert on status changes

## Example Usage
```bash
# Watch database with default 5-second polling
redisctl enterprise database watch 1

# Faster polling for critical operations
redisctl enterprise database watch 1 --poll-interval 2

# Filter output with JMESPath
redisctl enterprise database watch 1 -q '{name: name, status: status}'
```

## Example Output
```
Watching database 1 (Ctrl+C to stop)...

[10:30:00] Database 1: active | mem: 2.10GB | shards: 1
[10:30:15] Database 1: active -> updating (TRANSITION)
  Memory: 2.10GB / 5.00GB (42.0%)
  Shards: 1
[10:32:30] Database 1: updating -> active (TRANSITION)
  Memory: 2.15GB / 5.00GB (43.0%)
  Shards: 1
```

Addresses #405 (Phase 2)
@joshrotenberg joshrotenberg merged commit be4e063 into main Nov 25, 2025
16 checks passed
@joshrotenberg joshrotenberg deleted the feat/database-watch branch November 25, 2025 23:33
@joshrotenberg joshrotenberg mentioned this pull request Nov 25, 2025
This was referenced Dec 9, 2025
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.

feat: Additional streaming support for metrics and events

2 participants