Skip to content

Conversation

vertti
Copy link
Owner

@vertti vertti commented Oct 3, 2025

Implements CloudWatch metrics viewing for ECS services, showing CPU and Memory utilization statistics. Users can now view current, average, peak, and low values for the last hour directly from the service menu.

Changes

  • Metrics fetching: New get_service_metrics() function queries CloudWatch for CPU/Memory utilization
  • Compact display: Single-line format for CPU and Memory with all statistics visible at a glance
  • UI integration: Added "📊 Show metrics" menu item to service actions
  • Error handling: Graceful fallback when metrics unavailable (new services, no running tasks)
  • Type safety: Full type annotations with ServiceMetrics and MetricStatistics TypedDicts

Technical Details

  • Added CloudWatch client initialization with optimized connection pooling
  • Queries 5-minute period metrics over last hour
  • Calculates current (most recent), average, maximum, and minimum values
  • Added boto3-stubs[cloudwatch] for type safety
  • 100% test coverage for metrics module with moto CloudWatch mocking

Example Output

Metrics for service 'web-api' (last hour):

CPU: Current: 0.5% | Avg: 0.5% | Peak: 3.2% | Low: 0.1%
Memory: Current: 15.4% | Avg: 15.4% | Peak: 15.4% | Low: 15.3%

vertti added 8 commits October 3, 2025 09:43
  - Add ServiceMetrics and MetricStatistics types to core/types.py
  - Implement get_service_metrics() to fetch CPU/Memory utilization
  - Query CloudWatch for last N hours with 5-minute periods
  - Calculate current, average, maximum, minimum for each metric
  - Return None when no data available
  - Implement format_metrics_display() for human-readable output
  - Format CPU and Memory utilization with current/average/peak/low stats
  - Display percentages with 1 decimal place precision
  - Add comprehensive tests for formatting function
  - Verify all statistics are included in output
@vertti vertti merged commit c53c158 into main Oct 3, 2025
3 checks passed
@vertti vertti deleted the cloudwatch-metrics branch October 3, 2025 07:30
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.

1 participant