Add workflow health monitoring command with cost metrics (gh aw health)#12662
Merged
Add workflow health monitoring command with cost metrics (gh aw health)#12662
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add gh aw health command for workflow health monitoring
Add workflow health monitoring command (gh aw health)
Jan 30, 2026
Contributor
|
@copilot show cost |
- Add TokenUsage and EstimatedCost fields to WorkflowHealth struct - Calculate average tokens and cost in CalculateWorkflowHealth - Display cost metrics in summary and detailed views - Add formatTokens and formatCost helper functions - Add tests for new formatting functions - Show average cost per run and total cost in detailed view Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Contributor
Author
Added cost metrics to the health command in commit bb9b233. The health command now displays: Summary view includes two new columns:
Detailed view shows three cost metrics:
Example output: All metrics are included in JSON output for programmatic consumption. |
Copilot
AI
changed the title
Add workflow health monitoring command (gh aw health)
Add workflow health monitoring command with cost metrics (gh aw health)
Jan 30, 2026
Contributor
|
@copilot use console package helpers to build table |
- Remove manual separator lines (━━━━━) - Remove redundant icons (console.Format* functions add them automatically) - Simplify output formatting to rely on console helpers - Consistent with other CLI commands (list, status, audit) Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Contributor
Author
Updated in commit 4eed7b3 to use console package helpers consistently:
The health command now uses console helpers exclusively for all output formatting. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Workflow Health Dashboard Command Implementation ✅
This PR implements the
gh aw healthcommand for workflow health monitoring as described in issue #12540.✅ All Implementation Tasks Completed
health_command.gowith command structure and flagshealth_metrics.gowith health calculation logicChanges Made
pkg/cli/health_command.go (300 lines)
NewHealthCommand(): Command structure with flagsRunHealth(): Main execution logic with config validationfetchWorkflowRuns(): GitHub API integration with paginationdisplayHealthSummary(): Summary view for all workflowsdisplayDetailedHealth(): Detailed view with cost metricsoutputHealthJSON(),outputHealthTable(): Output formatting using console helperspkg/cli/health_metrics.go (320 lines)
WorkflowHealth: Struct with health + cost metricsHealthSummary: Struct for aggregated metricsTrendDirection: Enum with visual indicators (↑→↓)CalculateWorkflowHealth(): Main health + cost calculationcalculateTrend(): Trend detection algorithmformatDuration(): Duration formattingformatTokens(): Token count formatting (K/M notation)formatCost(): Cost formatting with precisionpkg/cli/health_metrics_test.go (420 lines)
TestCalculateWorkflowHealth: Health calculation testsTestCalculateTrend: Trend detection testsTestFormatDuration: Duration formatting testsTestFormatTokens: Token formatting testsTestFormatCost: Cost formatting testsTestGroupRunsByWorkflow: Data grouping testsTestFilterWorkflowsByName: Data filtering testsTestCalculateHealthSummary: Summary calculation testspkg/cli/health_command_test.go (90 lines)
TestHealthConfigValidation: Config validation testsTestHealthCommand: Command structure testscmd/gh-aw/main.go
Features Delivered
✅ Summary View: All workflows with success rates sorted by health
✅ Detailed View: Individual workflow metrics
✅ Historical Analysis: 7/30/90 days configurable
✅ Trend Detection: ↑ improving, → stable, ↓ degrading
✅ Threshold Alerting: Default 80%, configurable
✅ JSON Output: For programmatic consumption
✅ Console Rendering: Uses console.RenderStruct() helpers
✅ Error Handling: Clear error messages
✅ GitHub API Integration: Paginated workflow run fetching
✅ Cost Metrics: Token usage and estimated cost per workflow
✅ Test Coverage: 9 test functions, 30+ test cases
Command Examples
Example Output
Summary View:
Detailed View:
Testing
Code Quality
console.RenderStruct()for table rendering (consistent with list, status, audit commands)console.Format*Message()helpers for all user-facing messagesPriority & Impact
Priority: High
Impact: Provides proactive workflow health monitoring with cost visibility, prevents user-reported issues, enables early detection of degrading workflows
Related
Closes #12540
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.