MATIH Platform is in active MVP development. Documentation reflects current implementation status.
7. Tenant Lifecycle
Resource Management
Cost Dashboard

Cost Dashboard

The CostDashboardController at /api/v1/cost-dashboard provides cost visualization and analytics for both platform administrators and tenant administrators. It includes platform-wide overviews, service breakdowns, tier comparisons, anomaly detection, and per-tenant dashboards.


Endpoints

MethodPathDescriptionAuth
GET/cost-dashboard/platform/overviewPlatform-wide cost overviewPLATFORM_ADMIN
GET/cost-dashboard/platform/servicesCost breakdown by servicePLATFORM_ADMIN
GET/cost-dashboard/platform/tier-comparisonCost comparison by tierPLATFORM_ADMIN
GET/cost-dashboard/platform/anomaliesDetect cost anomaliesPLATFORM_ADMIN
GET/cost-dashboard/tenant/{tenantId}Tenant cost dashboardADMIN or tenant access
GET/cost-dashboard/tenant/{tenantId}/monthly-historyTenant monthly historyADMIN or tenant access

Platform Overview

curl "http://localhost:8082/api/v1/cost-dashboard/platform/overview?date=2026-02-12" \
  -H "Authorization: Bearer $ADMIN_TOKEN"

The date parameter defaults to today. Returns a PlatformCostOverview with total costs, cost per tenant tier, top spenders, and comparison to previous period.


Service Breakdown

curl "http://localhost:8082/api/v1/cost-dashboard/platform/services?startDate=2026-02-01&endDate=2026-02-12" \
  -H "Authorization: Bearer $ADMIN_TOKEN"

Returns a ServiceCostBreakdown showing costs per service (ai-service, query-engine, etc.) over the specified date range.


Tier Cost Comparison

Compare costs across tenant tiers for a specific month:

curl "http://localhost:8082/api/v1/cost-dashboard/platform/tier-comparison?month=2026-02" \
  -H "Authorization: Bearer $ADMIN_TOKEN"

The month parameter uses yyyy-MM format and defaults to the current month. Returns a TierCostComparison with average cost per tenant by tier, total costs, and margin analysis.


Cost Anomaly Detection

curl "http://localhost:8082/api/v1/cost-dashboard/platform/anomalies?date=2026-02-11&threshold=100" \
  -H "Authorization: Bearer $ADMIN_TOKEN"

Parameters:

  • date: Date to analyze (defaults to yesterday)
  • threshold: Cost threshold in USD for anomaly detection (default: 100)

Response:

[
  {
    "tenantId": "e5f6a7b8-...",
    "tenantName": "Acme Corp",
    "date": "2026-02-11",
    "actualCost": 285.50,
    "expectedCost": 125.00,
    "deviation": 128.4,
    "deviationPercent": 128.4,
    "anomalyType": "SPIKE",
    "resourceBreakdown": {
      "compute": 180.30,
      "storage": 55.20,
      "network": 50.00
    }
  }
]

Tenant Cost Dashboard

Individual tenants can view their own cost data:

curl "http://localhost:8082/api/v1/cost-dashboard/tenant/{tenantId}?date=2026-02-12" \
  -H "Authorization: Bearer $TOKEN"

Returns a TenantCostDashboard with current period costs, resource breakdown, trend data, and budget utilization.


Tenant Monthly History

View monthly cost history for a tenant:

curl "http://localhost:8082/api/v1/cost-dashboard/tenant/{tenantId}/monthly-history?months=12" \
  -H "Authorization: Bearer $TOKEN"

Parameters:

  • months: Number of months to return (default: 12)

Returns a list of MonthlyCostPoint objects with month, total cost, and cost breakdown by category.


Source Files

FilePath
Controllercontrol-plane/tenant-service/src/main/java/com/matih/tenant/controller/CostDashboardController.java
Servicecontrol-plane/tenant-service/src/main/java/com/matih/tenant/service/cost/CostDashboardService.java