Repository navigation
feat: ocost-splitter plugin - written split methods for the shared/unattributed pool - #87
Open
rahmankhanjohn wants to merge 1 commit into
Open
rahmankhanjohn wants to merge 1 commit into
rahmankhanjohn wants to merge 1 commit into
Conversation
…attributed pool Signed-off-by: Rahman Khan <[email protected]>
rahmankhanjohn
force-pushed
the
feat/ocost-splitter
branch
from
November 5, 2026 17:18
4d16416 to
4e7e023
Compare
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.
What this adds
A new plugin,
ocost-splitter, that addresses the shared/unattributed pool from issue #2890: the cost that no tag splits (control plane, ingress, monitoring, cross-namespace transfer - commonly near 30 percent of a cluster bill).The plugin reads the allocation data OpenCost already produces (via the OpenCost allocation API, aggregated by namespace), identifies the shared pool from a configurable namespace list, and applies one of four written, auditable split methods:
The output is one FOCUS CustomCost row per attributed namespace per window, with the method and the shared sources in labels, and deterministic IDs so re-runs are idempotent.
Why a plugin and not a pipeline change
The shared pool is a policy question, not a data question: which method is defensible is a decision finance signs off on, and it varies per tenant. A plugin keeps the split rule external, written, and versioned - while OpenCost's own allocation data stays untouched. If the maintainers later want the methods in the core allocation pipeline, the logic is small and self-contained.
Structure
Follows the Datadog plugin reference exactly:
cmd/main/main.go- OcostSplitterSource implementing CustomCostSource (GetCustomCosts with GetWindows splitting)ocostsplitterplugin/- config struct (JSON config file), the four split methods, OpenCost allocation API client, FOCUS row buildertests/- deterministic tests for each method: proportional (100/66.67/33.33 on a 600/200/100 estate), equal, weighted (5/3/2), none baseline, negative-pool rejection, zero-weight rejection, unknown-method rejection, empty-targets rejectionConfig example
{ "opencost_api_address": "http://opencost.opencost:9003", "split_method": "proportional", "shared_namespaces": ["kube-system", "monitoring", "ingress-nginx"], "weights_file": "/config/weights.csv", "currency": "USD" }Testing
just build-all-pluginsCloses the tooling half of #2890 (the EKS CUR ingestion as an allocation source is a separate, larger PR I can follow with if the maintainers want it).