[WIP] Improve cost management reference documentation#20128
Conversation
… fixes Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates the Cost Management reference docs to better support cost monitoring and improve correctness of trigger cost-avoidance examples.
Changes:
- Added a new “Monitoring Costs with
gh aw logs” section with CLI and JSON export examples. - Fixed
skip-if-match/skip-if-no-matchexamples to be correctly positioned under theon:block. - Refined the existing tip to focus
gh aw auditon single-run deep dives (and removed redundantgh aw logsmention).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
|
||
| # List per-run duration, tokens, and cost across all workflows | ||
| gh aw logs --start-date -30d --json | \ | ||
| jq '.runs[] | {workflow: .workflow_name, duration: .duration, cost: .estimated_cost}' |
There was a problem hiding this comment.
In the JSON export example, the comment says it will list per-run duration, tokens, and cost, but the jq filter only outputs workflow, duration, and cost. Either include token_usage in the jq output or update the surrounding text so it matches the actual fields being shown.
| jq '.runs[] | {workflow: .workflow_name, duration: .duration, cost: .estimated_cost}' | |
| jq '.runs[] | {workflow: .workflow_name, duration: .duration, tokens: .token_usage, cost: .estimated_cost}' |
|
|
||
| # Total cost grouped by workflow over the past 30 days | ||
| gh aw logs --start-date -30d --json | \ | ||
| jq '[.runs[]] | group_by(.workflow_name) | |
There was a problem hiding this comment.
The jq example that uses group_by(.workflow_name) will produce incorrect totals unless the input array is sorted by workflow_name first (jq groups only adjacent equal keys). Consider adding sort_by(.workflow_name) before group_by, or use a reduce-based aggregation.
| jq '[.runs[]] | group_by(.workflow_name) | | |
| jq '[.runs[]] | sort_by(.workflow_name) | group_by(.workflow_name) | |
| ## Monitoring Costs with `gh aw logs` | ||
|
|
||
| The `gh aw logs` command downloads workflow run data and surfaces per-run metrics including elapsed duration, token usage, and estimated inference cost. Use it to see exactly what your workflows are consuming before deciding what to optimize. |
There was a problem hiding this comment.
The PR description checklist mentions adding a concrete meta-agent workflow snippet to the “Agentic Cost Optimization” section, but this file still contains only narrative text in that section (no snippet/example workflow). Either add the promised snippet or update the PR description to match the actual changes.
skip-if-matchsnippet: move to correct position insideon:blockskip-if-no-matchsnippet: move to correct position insideon:blockgh aw logs" section showing how to inspect Actions minutes consumption💡 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.