Usage Metrics API: What's Tracked and What's Not
Pull usage data reliably — /copilot/usage endpoints, GA Feb 2025.
What You Will Learn
- Pull usage data via API.
- Understand what's tracked.
- Build a usage dashboard.
- Alert on anomalies.
- Use data for cost control.
Why This Matters
Usage data drives cost control, capacity planning, and ROI measurement. The Metrics API (GA Feb 2025) gives reliable programmatic access.
Concept Explained
/copilot/usage endpoints return: per-user credit usage, per-feature usage (completions, chat, agent), per-model usage. Historical data available up to 1 year.
How It Works
GET /orgs/{org}/copilot/usage with date range. Returns per-user and aggregate metrics. Build dashboard; alert on over-usage.
Step-by-Step Tutorial
1. Pull usage
GET /orgs/{org}/copilot/usage?since=YYYY-MM-DD&until=YYYY-MM-DD2. Per-user metrics
Returns each user's credit usage, feature breakdown.3. Aggregate
Org-level totals; per-feature, per-model.4. Build dashboard
Visualize usage over time. Per team, per user.5. Alert
When user exceeds threshold, alert manager.Real-World Example
A team built a Copilot usage dashboard. Found one user burning 5x the average — using the coding agent for trivial tasks. Coached the user; saved $200/month. Dashboard became weekly leadership review.
Example Prompts / Commands / Code
import requests
from datetime import datetime, timedelta
ORG = 'your-org'
TOKEN = 'YOUR_GITHUB_TOKEN'
since = (datetime.now() - timedelta(days=30)).strftime('%Y-%m-%d')
until = datetime.now().strftime('%Y-%m-%d')
r = requests.get(
f'https://api.github.com/orgs/{ORG}/copilot/usage',
headers={'Authorization': f'Bearer {TOKEN}'},
params={'since': since, 'until': until}
)
usage = r.json()
# Per-user breakdown:
for user in usage['users']:
print(f'{user["login"]}:')
print(f' Total credits: {user["total_credits"]}')
print(f' Completions: {user["completions_count"]}')
print(f' Chat: {user["chat_count"]}')
print(f' Agent: {user["agent_count"]}')
Track:
- Per user: total credits, feature breakdown, trend over time
- Per team: aggregate usage, top users, anomalies
- Per model: which models used, cost per model
- Per feature: completions vs chat vs agent
- Anomalies: user >2x avg, team >120% of budget
Alert thresholds:
- User >1.5x avg: notify manager
- Team >110% of budget: notify lead
- Org >90% of total credits: notify admin
Common Mistakes
- Not pulling regularly — data only available for 1 year.
- Not alerting on anomalies — surprise at month-end.
- Tracking but not acting — data without action is wasted.
- Forgetting historical data limit — 1 year max.
Best Practices
- Pull weekly; build dashboard.
- Alert on anomalies (>1.5x avg, >110% budget).
- Track per-user, per-team, per-model, per-feature.
- Act on data: coach over-users, right-size plan.
- Remember: historical data only 1 year.
Troubleshooting
| Problem | How to Fix |
|---|---|
| Data seems wrong | Verify date range. Check timezone handling. |
| Endpoint 404 | Verify Business/Enterprise plan. Metrics API requires it. |
Practical Exercise
Your Turn
Pull your org's Copilot usage for the last 30 days. Identify the top 3 users. Build a simple dashboard.
Professional Challenge
Build a real-time Copilot usage dashboard with alerts. Share with leadership. Use data to right-size plans quarterly.
Key Takeaways
- Usage Metrics API: /copilot/usage endpoints (GA Feb 2025).
- Returns per-user, per-feature, per-model data.
- Historical data: 1 year max.
- Build dashboard; alert on anomalies.
- Act on data: coach, right-size, optimize.
Frequently Asked Questions
Does this work on Free/Pro?
Real-time?
Further Reading
Official References
SEO Metadata
SEO title: Usage Metrics API: What's Tracked and What's Not
Meta description: Pull usage data reliably — /copilot/usage endpoints, GA Feb 2025.
Primary keyword: usage metrics api
Secondary keywords: usage metrics api: what's tracked and what's not
Search intent: Informational
URL slug: /copilot-usage-metrics-api-tracked-not-tracked
Categories: AI Tools, GitHub Copilot
Tags: GitHub Copilot, Professional, REST API, Metrics, Usage, IMCSEIAN, Tutorial, IMCSEIAN
Featured image concept: IMCSEIAN lesson card for Usage Metrics API: What's Tracked and What's Not
Comments
Comments
Post a Comment