pkg: add reusable opencost + prom modules for FinOps v2#492
Draft
nadaverell wants to merge 1 commit intomainfrom
Draft
pkg: add reusable opencost + prom modules for FinOps v2#492nadaverell wants to merge 1 commit intomainfrom
nadaverell wants to merge 1 commit intomainfrom
Conversation
Extracts the OpenCost REST + Prometheus discovery paths from radar's internal code into reusable packages that koala-backend and skyhook-connector consume for the FinOps v2 Costs Explorer. pkg/opencost: - ComputeCostSummary (REST-primary) + ComputeCostSummaryFromProm (fallback) - ComputeCostTrend with coarse default steps (24h->6h, 7d->1d, 30d->2d) to fit CAC's 30s proxy deadline - Window-to-hourly normalization: OpenCost's /allocation.totalCost is summed over the window, not hourly; we divide by windowHours() so callers can project monthly by multiplying by 730 regardless of the window selected - Pod/controller aggregation via SummaryOptions.Aggregate - Client-side namespace post-filter (NamespaceFilter) for OpenCost versions that silently ignore the REST filter param - Drops synthetic __unallocated__ rows in controller/pod drills so child totals don't exceed the parent namespace - Surfaces NetworkCost per row + TotalNetworkCost in the summary pkg/prom: - Shared Prometheus client + Discover() used by finops capability probe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pkg/opencostandpkg/promso koala-backend and skyhook-connector can share the cost mathComputeCostSummary(REST-primary) +ComputeCostSummaryFromProm(PromQL fallback)ComputeCostTrendwith coarse default steps (24h→6h, 7d→1d, 30d→2d) to fit CAC's 30s proxy deadlinefilterparam)NetworkCostper row andTotalNetworkCostin the summary__unallocated__controller row so child totals don't exceed the parent namespace/allocation.totalCostis summed over the window; we divide bywindowHours()so callers can project monthly by multiplying hourly × 730 regardless of the window selected. Regression test pins this.Tag published:
pkg/v1.4.4. Consumed by:Test plan
go test ./opencost/...(includes window-normalization regression)