Skip to main content

Analytics API

Table of Contents

Top

upsquad/analytics/v1/analytics.proto

ActivityFeedEntry

ActivityFeedEntry is one row from the clearance-projected activity feed. Added by LLD #855.

FieldTypeLabelDescription
action_idstringaction_id is the agent_audit_log row id.
agent_idstringagent_id is the agent that produced the action.
agent_namestringagent_name is the display name of the agent (joined from agents/members).
action_typestringaction_type is the audit_action_type enum rendered as string.
summarystringsummary is a short human-readable derived from the detail JSONB.
created_atgoogle.protobuf.Timestampcreated_at is the wall-clock of the audit_log row.
team_idstringteam_id of the acting agent at the time of the action.
pillar_idstringpillar_id of the acting agent at the time of the action.

AgentUtilizationEntry

AgentUtilizationEntry describes one agent's recent activity.

FieldTypeLabelDescription
agent_idstringagent_id is the UUID of the agent.
agent_namestringagent_name is the human-readable agent name.
events_24hint64events_24h is the number of context events in the last 24 hours.
last_activegoogle.protobuf.Timestamplast_active is the timestamp of the most recent event.
statusstringstatus is the derived health status: healthy, degraded, or idle.

Anomaly

Anomaly describes a detected operational anomaly.

FieldTypeLabelDescription
typestringtype is the anomaly category: error_spike, cost_overrun, stalled_workflow, unusual_consumption.
severitystringseverity is the anomaly severity: warning, critical.
titlestringtitle is a short human-readable summary.
descriptionstringdescription is a detailed explanation.
entity_idstringentity_id is the UUID of the affected entity (agent, workflow, etc.).
detected_atgoogle.protobuf.Timestampdetected_at is when the anomaly was detected.

CostBreakdownEntry

CostBreakdownEntry is one grouped cost entry.

FieldTypeLabelDescription
entity_namestringentity_name is the human-readable name (agent name or model ID).
entity_idstringentity_id is the UUID (agent_id) or model string.
tokensint64tokens is the total tokens consumed by this entity.
costdoublecost is the estimated cost in USD.
percentagedoublepercentage is this entity's share of total cost (0-100).

GenerateBriefingRequest

GenerateBriefingRequest specifies the briefing window.

FieldTypeLabelDescription
sincegoogle.protobuf.Timestampsince is the start of the briefing window (default: midnight UTC).

GenerateBriefingResponse

GenerateBriefingResponse contains the executive briefing.

FieldTypeLabelDescription
overnight_summarystringovernight_summary is a text summary of overnight activity.
pending_actionsPendingActionrepeatedpending_actions is the list of items requiring attention.
agent_health_summarystringagent_health_summary is a text summary of agent health status.
cost_trend_summarystringcost_trend_summary is a text summary of cost trends.

GetAgentUtilizationRequest

GetAgentUtilizationRequest filters agent utilization data.

FieldTypeLabelDescription
pillar_idstringpillar_id optionally filters agents by pillar.
team_idstringteam_id optionally filters agents by team.

GetAgentUtilizationResponse

GetAgentUtilizationResponse contains agent utilization data.

FieldTypeLabelDescription
agentsAgentUtilizationEntryrepeatedagents is the list of agent utilization entries.

GetAnomaliesRequest

GetAnomaliesRequest specifies the lookback window for anomaly detection.

FieldTypeLabelDescription
lookback_hoursint32lookback_hours is how far back to check (default 24).

GetAnomaliesResponse

GetAnomaliesResponse contains detected anomalies.

FieldTypeLabelDescription
anomaliesAnomalyrepeatedanomalies is the list of detected anomalies.

GetCostBreakdownRequest

GetCostBreakdownRequest filters cost breakdown data.

FieldTypeLabelDescription
group_byGroupBygroup_by controls whether costs are grouped by agent or model.
start_dategoogle.protobuf.Timestampstart_date is the inclusive start of the query range.
end_dategoogle.protobuf.Timestampend_date is the inclusive end of the query range.

GetCostBreakdownResponse

GetCostBreakdownResponse contains the grouped cost entries.

FieldTypeLabelDescription
entriesCostBreakdownEntryrepeatedentries is the list of cost breakdown items.

GetDashboardKPIsRequest

GetDashboardKPIsRequest filters the KPI aggregation window. Added by LLD #855.

FieldTypeLabelDescription
window_hoursint32window_hours is the KPI aggregation window. Default 24, max 168 (7d).

GetDashboardKPIsResponse

GetDashboardKPIsResponse returns the L1 dashboard KPI summary. Added by LLD #855.

FieldTypeLabelDescription
active_agentsint64active_agents is the distinct count of agents active in the window.
workflows_runningint64workflows_running is the count of workflow runs currently in-flight.
pending_approvalsint64pending_approvals is the count of actions awaiting approval.
tokens_consumedint64tokens_consumed is the sum of LLM tokens consumed in the window.
cost_usddoublecost_usd is the sum of cost in USD for the window.
context_eventsint64context_events is the count of context_events produced in the window.
generated_atgoogle.protobuf.Timestampgenerated_at is the server wall-clock at aggregation time.

GetTeamSpendRequest

GetTeamSpendRequest specifies the period for team-level spend rollup.

FieldTypeLabelDescription
periodGetTeamSpendRequest.Periodperiod selects the aggregation window. Defaults to MONTH_TO_DATE.

GetTeamSpendResponse

GetTeamSpendResponse contains the per-team spend rollups.

FieldTypeLabelDescription
teamsTeamSpendrepeatedteams is the list of per-team spend entries, ordered by spent DESC so the budget-burn widget shows the heaviest spenders first.

GetTokenUsageTimeSeriesRequest

GetTokenUsageTimeSeriesRequest filters token usage data.

FieldTypeLabelDescription
scope_levelScopescope_level filters by hierarchical scope (org, pillar, team, agent).
scope_idstringscope_id is the UUID of the entity at the selected scope level.
granularityGranularitygranularity controls hour, day or week bucketing. HOUR (GAP-4 #1073) is capped server-side at 168 buckets / 7 days; wider ranges with HOUR are rejected as InvalidArgument.
start_dategoogle.protobuf.Timestampstart_date is the inclusive start of the query range.
end_dategoogle.protobuf.Timestampend_date is the inclusive end of the query range.

GetTokenUsageTimeSeriesResponse

GetTokenUsageTimeSeriesResponse contains the time-series data.

FieldTypeLabelDescription
data_pointsTokenUsageDataPointrepeateddata_points is the ordered list of time-series entries.

GetWorkflowMetricsRequest

GetWorkflowMetricsRequest filters workflow metrics.

FieldTypeLabelDescription
start_dategoogle.protobuf.Timestampstart_date is the inclusive start of the query range.
end_dategoogle.protobuf.Timestampend_date is the inclusive end of the query range.

GetWorkflowMetricsResponse

GetWorkflowMetricsResponse contains aggregate workflow statistics.

FieldTypeLabelDescription
total_runsint64total_runs is the number of workflow runs in the period.
completedint64completed is the number of successfully completed runs.
failedint64failed is the number of failed runs.
avg_duration_secondsdoubleavg_duration_seconds is the average run duration.
completion_ratedoublecompletion_rate is completed/total_runs as a percentage (0-100).
pending_approvalsint64pending_approvals is the number of actions awaiting approval.

ListActivityFeedRequest

ListActivityFeedRequest bounds and paginates the activity feed query. Added by LLD #855.

FieldTypeLabelDescription
page_sizeint32page_size is the max entries returned per page. Default 20, max 100.
cursorstringcursor is an opaque base64 token from a prior response's next_cursor. Empty string means the caller wants the first page.
sincegoogle.protobuf.Timestampsince optionally bounds the oldest entry in the result (inclusive).

ListActivityFeedResponse

ListActivityFeedResponse is a paginated activity-feed page. Added by LLD #855.

FieldTypeLabelDescription
entriesActivityFeedEntryrepeatedentries is the list of activity-feed rows for this page, newest first.
next_cursorstringnext_cursor is the token to pass as cursor on the next call. Empty when this is the last page.

PendingAction

PendingAction describes an action that requires attention.

FieldTypeLabelDescription
action_idstringaction_id is the UUID of the pending item.
action_typestringaction_type describes the kind of action (approval, review, etc.).
descriptionstringdescription is a human-readable summary of what needs to be done.
entity_idstringentity_id is the UUID of the related entity.
created_atgoogle.protobuf.Timestampcreated_at is when the action was created.

TeamSpend

TeamSpend is one team's spend rollup for the requested period.

Note: amounts are reported as USD double to remain consistent with the existing CostBreakdownEntry.cost field on this same service. The upstream issue (#1036) suggested google.type.Money but the proto module does not currently depend on the googleapis BSR module and adding it solely for this RPC would dilute the dependency surface for one widget. The deviation is documented in the PR body so the next pass that legitimately needs Money (e.g. multi-currency billing readouts) can introduce the dep without coupling to GAP-3.

FieldTypeLabelDescription
team_idstringteam_id is the org_units.id of the team (unit_type='team').
team_namestringteam_name is the display name of the team.
spentdoublespent is the total spend in USD across the requested period.
capdoublecap is the team's monthly spend cap in USD. Computed as the sum of agent_budgets.monthly_cost_cap for every active agent currently attached to the team (so a team with no caps reports 0). Cap is always reported as the monthly figure regardless of period to match the dashboard widget's "Burned X of Y/mo" semantics.
forecastdoubleforecast is the projected end-of-period spend in USD using a linear extrapolation from period-to-date. Forecast == spent for the PERIOD_LAST_30_DAYS period because the window is already a full 30-day rolling sum (no extrapolation needed).
spent_pctdoublespent_pct is spent / cap * 100, in [0, +inf). Reported as 0 when cap == 0 to avoid div-by-zero spikes on uncapped teams.
over_capboolover_cap is true when spent > cap and cap > 0.

TokenUsageDataPoint

TokenUsageDataPoint is one time-series data point.

FieldTypeLabelDescription
dategoogle.protobuf.Timestampdate is the start of the time bucket.
input_tokensint64input_tokens is the total input tokens in this bucket.
output_tokensint64output_tokens is the total output tokens in this bucket.
total_tokensint64total_tokens is input_tokens + output_tokens.
costdoublecost is the estimated cost in USD for this bucket.

GetTeamSpendRequest.Period

Period selects the aggregation window for the spend rollup.

NameNumberDescription
PERIOD_UNSPECIFIED0PERIOD_UNSPECIFIED defaults to PERIOD_MONTH_TO_DATE.
PERIOD_MONTH_TO_DATE1PERIOD_MONTH_TO_DATE aggregates from the first of the current calendar month (UTC, midnight) through the moment of the request.
PERIOD_LAST_30_DAYS2PERIOD_LAST_30_DAYS aggregates from now-30d through the moment of the request. Used for stable rolling-window comparisons that do not reset on the first of the month.

Granularity

Granularity defines the time bucketing for time-series data.

NameNumberDescription
GRANULARITY_UNSPECIFIED0GRANULARITY_UNSPECIFIED defaults to daily.
GRANULARITY_DAY1GRANULARITY_DAY groups data by calendar day.
GRANULARITY_WEEK2GRANULARITY_WEEK groups data by ISO week.
GRANULARITY_HOUR3GRANULARITY_HOUR groups data by hour. Range is capped at 168 buckets (7 days) server-side per GAP-4 (#1073) — over-cap requests are rejected with InvalidArgument so the dashboard sparkline can never pull an unbounded series.

GroupBy

GroupBy defines the grouping dimension for cost breakdowns.

NameNumberDescription
GROUP_BY_UNSPECIFIED0GROUP_BY_UNSPECIFIED defaults to agent.
GROUP_BY_AGENT1GROUP_BY_AGENT groups costs by agent.
GROUP_BY_MODEL2GROUP_BY_MODEL groups costs by LLM model.

Scope

Scope defines the hierarchical filter level for analytics queries.

NameNumberDescription
SCOPE_UNSPECIFIED0SCOPE_UNSPECIFIED defaults to org-level.
SCOPE_ORG1SCOPE_ORG queries across the entire organisation.
SCOPE_PILLAR2SCOPE_PILLAR queries within a single pillar.
SCOPE_TEAM3SCOPE_TEAM queries within a single team.
SCOPE_AGENT4SCOPE_AGENT queries for a single agent.

AnalyticsService

AnalyticsService exposes aggregated analytics for the UpsQuad dashboard. All RPCs are scoped to the caller's tenant organisation via JWT-derived scope claims injected by the scope middleware.

Method NameRequest TypeResponse TypeDescription
GetTokenUsageTimeSeriesGetTokenUsageTimeSeriesRequestGetTokenUsageTimeSeriesResponseGetTokenUsageTimeSeries returns token usage grouped by day or week.
GetCostBreakdownGetCostBreakdownRequestGetCostBreakdownResponseGetCostBreakdown returns cost data grouped by agent or model.
GetTeamSpendGetTeamSpendRequestGetTeamSpendResponseGetTeamSpend returns per-team current spend, monthly cap, and a linear forecast for the requested period. Powers the dashboard "Budget burn by team" widget and the per-team rows on the org page. See GAP-3 / issue #1036.
GetAgentUtilizationGetAgentUtilizationRequestGetAgentUtilizationResponseGetAgentUtilization returns recent activity metrics for each agent.
GetWorkflowMetricsGetWorkflowMetricsRequestGetWorkflowMetricsResponseGetWorkflowMetrics returns aggregate workflow run statistics.
GetAnomaliesGetAnomaliesRequestGetAnomaliesResponseGetAnomalies detects operational anomalies from recent data.
GenerateBriefingGenerateBriefingRequestGenerateBriefingResponseGenerateBriefing produces an executive summary from overnight data.
GetDashboardKPIsGetDashboardKPIsRequestGetDashboardKPIsResponseGetDashboardKPIs returns the L1 KPI-bar summary for the caller's scope. Added by LLD #855 (HLD #831, PRD #824). Uncached for MVP.
ListActivityFeedListActivityFeedRequestListActivityFeedResponseListActivityFeed returns a clearance-projected slice of agent_audit_log. Projection is driven by the caller's session-local app.clearance GUC (see ADR #853); callers cannot forge a higher projection level. Added by LLD #855 (HLD #831, PRD #824).

Scalar Value Types

.proto TypeNotesC++JavaPythonGoC#PHPRuby
doubledoubledoublefloatfloat64doublefloatFloat
floatfloatfloatfloatfloat32floatfloatFloat
int32Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead.int32intintint32intintegerBignum or Fixnum (as required)
int64Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead.int64longint/longint64longinteger/stringBignum
uint32Uses variable-length encoding.uint32intint/longuint32uintintegerBignum or Fixnum (as required)
uint64Uses variable-length encoding.uint64longint/longuint64ulonginteger/stringBignum or Fixnum (as required)
sint32Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s.int32intintint32intintegerBignum or Fixnum (as required)
sint64Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s.int64longint/longint64longinteger/stringBignum
fixed32Always four bytes. More efficient than uint32 if values are often greater than 2^28.uint32intintuint32uintintegerBignum or Fixnum (as required)
fixed64Always eight bytes. More efficient than uint64 if values are often greater than 2^56.uint64longint/longuint64ulonginteger/stringBignum
sfixed32Always four bytes.int32intintint32intintegerBignum or Fixnum (as required)
sfixed64Always eight bytes.int64longint/longint64longinteger/stringBignum
boolboolbooleanbooleanboolboolbooleanTrueClass/FalseClass
stringA string must always contain UTF-8 encoded or 7-bit ASCII text.stringStringstr/unicodestringstringstringString (UTF-8)
bytesMay contain any arbitrary sequence of bytes.stringByteStringstr[]byteByteStringstringString (ASCII-8BIT)