Documentation
¶
Overview ¶
Package cost correlates Fleetsweeper findings and per-cluster scores with a user-provided cost CSV. The CSV is the "bring your own billing export" pattern: Fleetsweeper does not call cloud billing APIs (no SDK deps, no credentials), but it can read whatever export the operator already has.
Expected CSV shape:
cluster,period,cost_usd prod-us-east-1,2026-05,2400.50 prod-eu-west-1,2026-05,1980.00 store-nyc-42,2026-05,180.25
Headers are case-insensitive. Extra columns are ignored. Periods can be any string; the correlator does not interpret them but surfaces the most recent period per cluster (lexicographic order, which matches ISO month strings like "2026-05" for the common case).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Analysis ¶
type Analysis struct {
// Currency is the cost currency. Always "USD" today.
Currency string `json:"currency"`
// Period is the most-recent period seen across the input rows.
Period string `json:"period,omitempty"`
// TotalFleetUSD is the sum of cost entries for clusters in the report.
TotalFleetUSD float64 `json:"total_fleet_usd"`
// TotalDriftUSD is the sum of (cluster cost) * (1 - score/100) across
// clusters with a cost entry. Interpreted as "the share of fleet spend
// associated with cluster health below perfect".
TotalDriftUSD float64 `json:"total_drift_usd"`
// ByCluster ranks per-cluster correlations from worst to best.
ByCluster []ClusterCost `json:"by_cluster"`
// MissingCost lists clusters in the report that had no entry in the CSV
// so operators see what their billing export is missing.
MissingCost []string `json:"missing_cost,omitempty"`
}
Analysis is the per-cluster correlation between cost and cluster score plus a fleet-wide rollup. Designed to slot into a dashboard panel: total drift cost is the hero number, by-cluster list ranks where the dollars go.
type ClusterCost ¶
type ClusterCost struct {
// Cluster is the kubeconfig context name.
Cluster string `json:"cluster"`
// Score is the cluster's most recent Fleet/cluster score.
Score int `json:"score"`
// CostUSD is the cluster's cost figure for Period.
CostUSD float64 `json:"cost_usd"`
// DriftUSD is CostUSD * (1 - Score/100), rounded to the nearest cent.
DriftUSD float64 `json:"drift_usd"`
// Period is the period label for the cost figure.
Period string `json:"period,omitempty"`
}
ClusterCost is one row of the by-cluster analysis.
type Entry ¶
type Entry struct {
// Cluster is the kubeconfig context name.
Cluster string `json:"cluster"`
// Period is a free-form label such as "2026-05" or "2026-W19".
Period string `json:"period"`
// USD is the cost figure in US dollars for the period.
USD float64 `json:"usd"`
}
Entry is one row of the cost CSV after normalization.
type Map ¶
Map maps cluster name to its most-recent cost entry. Loaders return this so downstream code does not have to filter the raw rows itself.