BuildBuddy Usage Analysis
Overview
Fetch usage + trends data from BuildBuddyService, store responses in a temp dir, analyze for spikes/drops, and recommend cost savings. Prioritize API key safety and small time windows.
Quick start
- •Use
references/requests.mdto setBASE_URL,API_KEY,GROUP_ID, andOUT_DIR. - •Call
GetUsagefor current and prior months. - •Call
GetTrendfor a time window aligned with the usage comparison. - •Use the analyzer script or ad‑hoc math to compare and project.
Preconditions and access
- •Verify API key presence without printing it:
git config --local buildbuddy.api-key | wc -c. - •If
GetUserreturnsNotFound(common with org API keys), useGetGroupwithurlIdentifierto resolveGROUP_ID. - •
GetUsageis admin-only. If you getPermissionDenied, switch to an org admin key or admin user for the group.
Fetch data (usage + trends)
Use the request templates in references/requests.md:
- •
GetUsagefor the current month and the prior month (billing comparisons). - •
GetTrendfor the same window (time-series context and cache hit rates). - •If drilling down:
GetStatHeatmap,GetStatDrilldown, thenSearchInvocationorSearchExecutionfor sample events.
Notes:
- •Keep windows small (days/weeks) to reduce payload size.
- •JSON fields are lowerCamelCase (e.g.,
dailyUsage,actionCacheHits).
Visual URLs (trends + drilldown)
Use the org base URL from GetGroup (field url).
Trends charts:
<ORG_URL>/trends/?start=YYYY-MM-DD&end=YYYY-MM-DD#builds <ORG_URL>/trends/?start=YYYY-MM-DD&end=YYYY-MM-DD#cache <ORG_URL>/trends/?start=YYYY-MM-DD&end=YYYY-MM-DD#cas <ORG_URL>/trends/?start=YYYY-MM-DD&end=YYYY-MM-DD#savings
Drilldown view:
<ORG_URL>/trends/?start=YYYY-MM-DD&end=YYYY-MM-DD#drilldown&ddMetric=i<INVOCATION_METRIC_ENUM>
Common query params: start, end, days, user, repo, branch, commit, host, command, pattern, tag, status, role.
ddMetric format is i<invocationEnum> or e<executionEnum> (use the stat_filter metric enums from your API docs). Drilldown selections can be pinned via ddSelection or ddZoom (heatmap selection encoding: start|end|bucketStart|bucketEnd|eventsSelected).
Example URLs (agent can adapt as-is):
<ORG_URL>/trends/?start=2026-01-01&end=2026-01-31#builds <ORG_URL>/trends/?start=2026-01-01&end=2026-01-31#cache <ORG_URL>/trends/?start=2026-01-01&end=2026-01-31#cas <ORG_URL>/trends/?start=2026-01-01&end=2026-01-31#savings <ORG_URL>/trends/?start=2026-01-01&end=2026-01-31#drilldown&ddMetric=i1 <ORG_URL>/trends/?start=2026-01-01&end=2026-01-31#drilldown&ddMetric=i4 <ORG_URL>/trends/?start=2026-01-01&end=2026-01-31#drilldown&ddMetric=e7 <ORG_URL>/trends/?start=2026-01-01&end=2026-01-31#drilldown&ddMetric=e9
Example ddMetric labels:
- •
i1= invocation duration (total build duration) - •
i4= invocation cache download size (CAS download bytes) - •
e7= execution input download size (RBE cache download bytes) - •
e9= execution wall time (total execution time)
All ddMetric values (agent can use directly):
Invocation metrics (i*)
- •
i1duration (total build duration) - •
i2CAS cache misses - •
i3updated at (timestamp) - •
i4CAS cache download size (bytes) - •
i5CAS cache download speed (bytes/sec) - •
i6CAS cache upload size (bytes) - •
i7CAS cache upload speed (bytes/sec) - •
i8action cache misses - •
i9time saved (cached execution time)
Execution metrics (e*)
- •
e1queue time - •
e2updated at (timestamp) - •
e3input download time - •
e4real execution time - •
e5output upload time - •
e6peak memory - •
e7input download size - •
e8output upload size - •
e9execution wall time - •
e10execution CPU nanos - •
e11execution average millicores
Analyze for anomalies
Use quick ad-hoc analysis (jq / python) or the script:
- •
scripts/analyze_usage_trends.py --usage usage.json --trend trend.json
Look for:
- •Spikes in
totalDownloadSizeBytesortotalUploadSizeBytes. - •Drops in
actionCacheHitsorcasCacheHits. - •Drops in action cache hit rate:
actionCacheHits / (actionCacheHits + actionCacheMisses)from trend stats. - •Large changes in execution time or CPU nanos (
cloudCpuNanos,cloudRbeCpuNanos).
Project month-to-date usage
- •Use
dailyUsageto find the latest reported day (the array may not start on day 1). - •Project full-month totals by scaling
usagetotals byfull_days / last_reported_day. - •Call out the projection method and the last reported date explicitly.
Recommendations
When anomalies are found, prioritize cost-saving advice:
- •Action Cache: reduce non-determinism, align toolchains, enable remote cache for CI.
- •Download egress: avoid downloading large outputs, prefer minimal downloads, limit artifact retention.
- •Drill down: use
GetStatDrilldownto identify top users/repos/targets, then inspect sample invocations. - •For a specific invocation investigation, use
buildbuddy-invocation-troubleshoot.
Resources
- •
references/requests.md: request templates with safe API key handling and UI URLs. - •
scripts/analyze_usage_trends.py: anomaly detector for usage/trends JSON.