Unit Cost Analysis
Unit Cost Analysis answers the question: how much does each unit of usage cost, and is that ratio improving or degrading over time? The view has two modes — Summary and Time-Series — toggled via a tab in the page header.
Formula
Efficiency Ratio = CLAMP(−10, 10, Δcost% ÷ Δusage%)
An efficiency ratio above 1 means cost is growing faster than usage — a sign of declining efficiency.
Summary View
The Summary view presents a ranked table of groupings with period-over-period comparison. Each row represents one combination of the selected dimension.
| Column | Description |
|---|---|
| Dimension Value | The group label (e.g., service name, region, resource ID) |
| Current Unit Cost | Unit cost for the selected current period ($/unit) |
| Previous Unit Cost | Unit cost for the prior comparison period |
| % Change | Period-over-period change in unit cost. Red if cost increased, green if decreased. |
| Efficiency Ratio | Cost growth ÷ usage growth, clamped to ±10. Values above 1 indicate cost growing faster than usage. |
Dimension Selector
The dimension selector lets users pivot the table by different grouping keys. Available dimensions:
Tag dimensions are dynamically populated from the available AWS cost allocation tags in the tenant's CID data. Any tag key present in the data appears in the selector.
Time-Series View
The Time-Series view renders a dual-axis Recharts line chart:
- Primary line: Daily unit cost over the selected date range
- Secondary line: Day-over-day growth rate (%) derived from a SQL
LAG()window function
Both series are computed in a single Redshift query using a window function to calculate daily deltas without requiring a self-join:
| Query Component | SQL Pattern |
|---|---|
| Daily unit cost | SUM(effective_cost) / NULLIF(SUM(usage_quantity), 0) |
| Previous day's unit cost | LAG(unit_cost, 1) OVER (ORDER BY usage_date) |
| Day-over-day change (%) | (unit_cost - prev_unit_cost) / NULLIF(prev_unit_cost, 0) * 100 |
Date Range Controls
Both views support a date range picker with presets: Last 7 days, Last 30 days, Last 90 days, and custom date range. The comparison period is automatically set to the same length immediately preceding the selected range (e.g., selecting "Last 30 days" compares against the prior 30 days).