kubecost

package
v1.95.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilterClusterID      FilterField = "clusterid"
	FilterNode                       = "node"
	FilterNamespace                  = "namespace"
	FilterControllerKind             = "controllerkind"
	FilterControllerName             = "controllername"
	FilterPod                        = "pod"
	FilterContainer                  = "container"

	FilterLabel      = "label"
	FilterAnnotation = "annotation"

	FilterServices = "services"
)

If you add a FilterField, MAKE SURE TO UPDATE ALL FILTER IMPLEMENTATIONS! Go does not enforce exhaustive pattern matching on "enum" types.

View Source
const (
	// FilterEquals is the equality operator
	// "kube-system" FilterEquals "kube-system" = true
	// "kube-syste" FilterEquals "kube-system" = false
	FilterEquals FilterOp = "equals"

	// FilterNotEquals is the inequality operator
	FilterNotEquals = "notequals"

	// FilterContains is an array/slice membership operator
	// ["a", "b", "c"] FilterContains "a" = true
	FilterContains = "contains"

	// FilterNotContains is an array/slice non-membership operator
	// ["a", "b", "c"] FilterNotContains "d" = true
	FilterNotContains = "notcontains"

	// FilterStartsWith matches strings with the given prefix.
	// "kube-system" StartsWith "kube" = true
	//
	// When comparing with a field represented by an array/slice, this is like
	// applying FilterContains to every element of the slice.
	FilterStartsWith = "startswith"

	// FilterContainsPrefix is like FilterContains, but using StartsWith instead
	// of Equals.
	// ["kube-system", "abc123"] ContainsPrefix ["kube"] = true
	FilterContainsPrefix = "containsprefix"
)

If you add a FilterOp, MAKE SURE TO UPDATE ALL FILTER IMPLEMENTATIONS! Go does not enforce exhaustive pattern matching on "enum" types.

View Source
const (
	AllocationNilProp            string = ""
	AllocationClusterProp        string = "cluster"
	AllocationNodeProp           string = "node"
	AllocationContainerProp      string = "container"
	AllocationControllerProp     string = "controller"
	AllocationControllerKindProp string = "controllerKind"
	AllocationNamespaceProp      string = "namespace"
	AllocationPodProp            string = "pod"
	AllocationProviderIDProp     string = "providerID"
	AllocationServiceProp        string = "service"
	AllocationLabelProp          string = "label"
	AllocationAnnotationProp     string = "annotation"
	AllocationDeploymentProp     string = "deployment"
	AllocationStatefulSetProp    string = "statefulset"
	AllocationDaemonSetProp      string = "daemonset"
	AllocationJobProp            string = "job"
	AllocationDepartmentProp     string = "department"
	AllocationEnvironmentProp    string = "environment"
	AllocationOwnerProp          string = "owner"
	AllocationProductProp        string = "product"
	AllocationTeamProp           string = "team"
)
View Source
const (
	FailedStatus  AuditStatus = "Failed"
	WarningStatus             = "Warning"
	PassedStatus              = "Passed"
)
View Source
const (
	// DefaultCodecVersion is used for any resources listed in the Default version set
	DefaultCodecVersion uint8 = 15

	// AssetsCodecVersion is used for any resources listed in the Assets version set
	AssetsCodecVersion uint8 = 16

	// AllocationCodecVersion is used for any resources listed in the Allocation version set
	AllocationCodecVersion uint8 = 15

	// AuditCodecVersion is used for any resources listed in the Audit version set
	AuditCodecVersion uint8 = 1
)
View Source
const AWSProvider = "AWS"

AWSProvider describes the provider AWS

View Source
const AzureProvider = "Azure"

AzureProvider describes the provider Azure

View Source
const (
	// BinaryTagStringTable is written and/or read prior to the existence of a string
	// table (where each index is encoded as a string entry in the resource
	BinaryTagStringTable string = "BGST"
)

BinaryTags represent the formatting tag used for specific optimization features

View Source
const CSVProvider = "CSV"

CSVProvider describes the provider a CSV

View Source
const ComputeCategory = "Compute"

ComputeCategory signifies the Compute Category

View Source
const ExternalSuffix = "__external__"

ExternalSuffix indicates an external allocation

View Source
const GCPProvider = "GCP"

GCPProvider describes the provider GCP

View Source
const (
	// GeneratorPackageName is the package the generator is targetting
	GeneratorPackageName string = "kubecost"
)
View Source
const IdleSuffix = "__idle__"

IdleSuffix indicates an idle allocation property

View Source
const KubernetesService = "Kubernetes"
View Source
const ManagementCategory = "Management"

ManagementCategory signifies the Management Category

View Source
const NetworkCategory = "Network"

NetworkCategory signifies the Network Category

View Source
const NilProvider = "-"

NilProvider describes unknown provider

View Source
const OtherCategory = "Other"

OtherCategory signifies an unassigned Category

View Source
const ShareEven = "__even__"

ShareEven indicates that a shared resource should be shared evenly across all remaining allocations.

View Source
const ShareNone = "__none__"

ShareNone indicates that a shareable resource should not be shared

View Source
const ShareWeighted = "__weighted__"

ShareWeighted indicates that a shared resource should be shared as a proportion of the cost of the remaining allocations.

View Source
const SharedCategory = "Shared"

SharedCategory signifies an unassigned Category

View Source
const SharedSuffix = "__shared__"

SharedSuffix indicates an shared allocation property

View Source
const StorageCategory = "Storage"

StorageCategory signifies the Storage Category

View Source
const UnallocatedSuffix = "__unallocated__"

UnallocatedSuffix indicates an unallocated allocation property

View Source
const UndefinedKey = "__undefined__"

UndefinedKey is used in composing Asset group keys if the group does not have that property defined. E.g. if aggregating on Cluster, Assets in the AssetSet where Asset has no cluster will be grouped under key "__undefined__"

View Source
const UnmountedSuffix = "__unmounted__"

UnmountedSuffix indicated allocation to an unmounted PV

Variables

This section is empty.

Functions

func ComputeAllocationTotals

func ComputeAllocationTotals(as *AllocationSet, prop string) map[string]*AllocationTotals

ComputeAllocationTotals totals the resource costs of the given AllocationSet using the given property, i.e. cluster or node, where "node" really means to use the fully-qualified (cluster, node) tuple.

func ComputeAssetTotals

func ComputeAssetTotals(as *AssetSet, prop AssetProperty) map[string]*AssetTotals

ComputeAssetTotals totals the resource costs of the given AssetSet, using the given property, i.e. cluster or node, where "node" really means to use the fully-qualified (cluster, node) tuple. NOTE: we're not capturing LoadBalancers here yet, but only because we don't yet need them. They could be added.

func ComputeIdleCoefficients

func ComputeIdleCoefficients(shareSplit, key string, cpuCost, gpuCost, ramCost float64, allocationTotals map[string]*AllocationTotals) (float64, float64, float64)

ComputeIdleCoefficients returns the idle coefficients for CPU, GPU, and RAM (in that order) for the given resource costs and totals.

func ParseProperty

func ParseProperty(text string) (string, error)

func ParseProvider

func ParseProvider(str string) string

ParseProvider attempts to parse and return a known provider, given a string

func QueryAllocationAsync

func QueryAllocationAsync(allocationQuerier AllocationQuerier, start, end time.Time, opts *AllocationQueryOptions) (chan *AllocationSetRange, chan error)

QueryAllocationAsync provide a functions for retrieving results from any AllocationQuerier Asynchronously

func QueryAssetAsync

func QueryAssetAsync(assetQuerier AssetQuerier, start, end time.Time, opts *AssetQueryOptions) (chan *AssetSetRange, chan error)

QueryAsseetAsync provide a functions for retrieving results from any AssetQuerier Asynchronously

func QueryCloudUsageAsync

func QueryCloudUsageAsync(cloudUsageQuerier CloudUsageQuerier, start, end time.Time, opts *CloudUsageQueryOptions) (chan *CloudUsageSetRange, chan error)

QueryCloudUsageAsync provide a functions for retrieving results from any CloudUsageQuerier Asynchronously

func QuerySummaryAllocationAsync

func QuerySummaryAllocationAsync(summaryAllocationQuerier SummaryAllocationQuerier, start, end time.Time, opts *AllocationQueryOptions) (chan *SummaryAllocationSetRange, chan error)

QuerySummaryAllocationAsync provide a functions for retrieving results from any SummaryAllocationQuerier Asynchronously

func RoundBack

func RoundBack(t time.Time, resolution time.Duration) time.Time

RoundBack rounds the given time back to a multiple of the given resolution in the given time's timezone. e.g. 2020-01-01T12:37:48-0700, 24h = 2020-01-01T00:00:00-0700

func RoundForward

func RoundForward(t time.Time, resolution time.Duration) time.Time

RoundForward rounds the given time forward to a multiple of the given resolution in the given time's timezone. e.g. 2020-01-01T12:37:48-0700, 24h = 2020-01-02T00:00:00-0700

Types

type AggAudit added in v1.95.0

type AggAudit struct {
	Status        AuditStatus
	Description   string
	LastRun       time.Time
	Results       map[string]map[string]*AuditFloatResult
	MissingValues []*AuditMissingValue
}

AggAudit contains the results of an Audit on an AggStore keyed on aggregation prop and Allocation key

func (*AggAudit) Clone added in v1.95.0

func (aa *AggAudit) Clone() *AggAudit

Clone returns a deep copy of the caller

func (*AggAudit) MarshalBinary added in v1.95.0

func (target *AggAudit) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this AggAudit instance into a byte array

func (*AggAudit) MarshalBinaryWithContext added in v1.95.0

func (target *AggAudit) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this AggAudit instance into a byte array leveraging a predefined context.

func (*AggAudit) UnmarshalBinary added in v1.95.0

func (target *AggAudit) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the AggAudit type

func (*AggAudit) UnmarshalBinaryWithContext added in v1.95.0

func (target *AggAudit) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the AggAudit type

type Allocation

type Allocation struct {
	Name                       string                `json:"name"`
	Properties                 *AllocationProperties `json:"properties,omitempty"`
	Window                     Window                `json:"window"`
	Start                      time.Time             `json:"start"`
	End                        time.Time             `json:"end"`
	CPUCoreHours               float64               `json:"cpuCoreHours"`
	CPUCoreRequestAverage      float64               `json:"cpuCoreRequestAverage"`
	CPUCoreUsageAverage        float64               `json:"cpuCoreUsageAverage"`
	CPUCost                    float64               `json:"cpuCost"`
	CPUCostAdjustment          float64               `json:"cpuCostAdjustment"`
	GPUHours                   float64               `json:"gpuHours"`
	GPUCost                    float64               `json:"gpuCost"`
	GPUCostAdjustment          float64               `json:"gpuCostAdjustment"`
	NetworkTransferBytes       float64               `json:"networkTransferBytes"`
	NetworkReceiveBytes        float64               `json:"networkReceiveBytes"`
	NetworkCost                float64               `json:"networkCost"`
	NetworkCostAdjustment      float64               `json:"networkCostAdjustment"`
	LoadBalancerCost           float64               `json:"loadBalancerCost"`
	LoadBalancerCostAdjustment float64               `json:"loadBalancerCostAdjustment"`
	PVs                        PVAllocations         `json:"-"`
	PVCostAdjustment           float64               `json:"pvCostAdjustment"`
	RAMByteHours               float64               `json:"ramByteHours"`
	RAMBytesRequestAverage     float64               `json:"ramByteRequestAverage"`
	RAMBytesUsageAverage       float64               `json:"ramByteUsageAverage"`
	RAMCost                    float64               `json:"ramCost"`
	RAMCostAdjustment          float64               `json:"ramCostAdjustment"`
	SharedCost                 float64               `json:"sharedCost"`
	ExternalCost               float64               `json:"externalCost"`
	// RawAllocationOnly is a pointer so if it is not present it will be
	// marshalled as null rather than as an object with Go default values.
	RawAllocationOnly *RawAllocationOnlyData `json:"rawAllocationOnly"`
}

Allocation is a unit of resource allocation and cost for a given window of time and for a given kubernetes construct with its associated set of properties. TODO:CLEANUP consider dropping name in favor of just Allocation and an Assets-style key() function for AllocationSet.

func AssetToExternalAllocation

func AssetToExternalAllocation(asset Asset, aggregateBy []string, labelConfig *LabelConfig) (*Allocation, error)

AssetToExternalAllocation converts the given asset to an Allocation, given the properties to use to aggregate, and the mapping from Allocation property to Asset label. For example, consider this asset:

CURRENT: Asset ETL stores its data ALREADY MAPPED from label to k8s concept. This isn't ideal-- see the TOOD.

  Cloud {
	   TotalCost: 10.00,
	   Labels{
      "kubernetes_namespace":"monitoring",
	     "env":"prod"
	   }
  }

Given the following parameters, we expect to return:

  1. single-prop full match aggregateBy = ["namespace"] => Allocation{Name: "monitoring", ExternalCost: 10.00, TotalCost: 10.00}, nil

  2. multi-prop full match aggregateBy = ["namespace", "label:env"] allocationPropertyLabels = {"namespace":"kubernetes_namespace"} => Allocation{Name: "monitoring/env=prod", ExternalCost: 10.00, TotalCost: 10.00}, nil

  3. multi-prop partial match aggregateBy = ["namespace", "label:foo"] => Allocation{Name: "monitoring/__unallocated__", ExternalCost: 10.00, TotalCost: 10.00}, nil

  4. no match aggregateBy = ["cluster"] => nil, err

TODO:

  Cloud {
	   TotalCost: 10.00,
	   Labels{
      "kubernetes_namespace":"monitoring",
	     "env":"prod"
	   }
  }

Given the following parameters, we expect to return:

  1. single-prop full match aggregateBy = ["namespace"] allocationPropertyLabels = {"namespace":"kubernetes_namespace"} => Allocation{Name: "monitoring", ExternalCost: 10.00, TotalCost: 10.00}, nil

  2. multi-prop full match aggregateBy = ["namespace", "label:env"] allocationPropertyLabels = {"namespace":"kubernetes_namespace"} => Allocation{Name: "monitoring/env=prod", ExternalCost: 10.00, TotalCost: 10.00}, nil

  3. multi-prop partial match aggregateBy = ["namespace", "label:foo"] allocationPropertyLabels = {"namespace":"kubernetes_namespace"} => Allocation{Name: "monitoring/__unallocated__", ExternalCost: 10.00, TotalCost: 10.00}, nil

  4. no match aggregateBy = ["cluster"] allocationPropertyLabels = {"namespace":"kubernetes_namespace"} => nil, err

(See asset_test.go for assertions of these examples and more.)

func NewMockUnitAllocation

func NewMockUnitAllocation(name string, start time.Time, resolution time.Duration, props *AllocationProperties) *Allocation

NewMockUnitAllocation creates an *Allocation with all of its float64 values set to 1 and generic properties if not provided in arg

func (*Allocation) Add

func (a *Allocation) Add(that *Allocation) (*Allocation, error)

Add returns the result of summing the two given Allocations, which sums the summary fields (e.g. costs, resources) and recomputes efficiency. Neither of the two original Allocations are mutated in the process.

func (*Allocation) CPUCores

func (a *Allocation) CPUCores() float64

CPUCores converts the Allocation's CPUCoreHours into average CPUCores

func (*Allocation) CPUEfficiency

func (a *Allocation) CPUEfficiency() float64

CPUEfficiency is the ratio of usage to request. If there is no request and no usage or cost, then efficiency is zero. If there is no request, but there is usage or cost, then efficiency is 100%.

func (*Allocation) CPUTotalCost

func (a *Allocation) CPUTotalCost() float64

CPUTotalCost calculates total CPU cost of Allocation including adjustment

func (*Allocation) Clone

func (a *Allocation) Clone() *Allocation

Clone returns a deep copy of the given Allocation

func (*Allocation) Equal

func (a *Allocation) Equal(that *Allocation) bool

Equal returns true if the values held in the given Allocation precisely match those of the receiving Allocation. nil does not match nil. Floating point values need to match according to util.IsApproximately, which accounts for small, reasonable floating point error margins.

func (*Allocation) GPUTotalCost

func (a *Allocation) GPUTotalCost() float64

GPUTotalCost calculates total GPU cost of Allocation including adjustment

func (*Allocation) GPUs

func (a *Allocation) GPUs() float64

GPUs converts the Allocation's GPUHours into average GPUs

func (*Allocation) IsAggregated

func (a *Allocation) IsAggregated() bool

IsAggregated is true if the given Allocation has been aggregated, which we define by a lack of AllocationProperties.

func (*Allocation) IsExternal

func (a *Allocation) IsExternal() bool

IsExternal is true if the given Allocation represents external costs.

func (*Allocation) IsIdle

func (a *Allocation) IsIdle() bool

IsIdle is true if the given Allocation represents idle costs.

func (*Allocation) IsUnallocated

func (a *Allocation) IsUnallocated() bool

IsUnallocated is true if the given Allocation represents unallocated costs.

func (*Allocation) IsUnmounted

func (a *Allocation) IsUnmounted() bool

IsUnmounted is true if the given Allocation represents unmounted volume costs.

func (*Allocation) LBTotalCost

func (a *Allocation) LBTotalCost() float64

LBTotalCost calculates total LB cost of Allocation including adjustment TODO deprecate

func (*Allocation) LoadBalancerTotalCost

func (a *Allocation) LoadBalancerTotalCost() float64

LoadBalancerTotalCost calculates total LB cost of Allocation including adjustment

func (*Allocation) MarshalBinary

func (target *Allocation) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this Allocation instance into a byte array

func (*Allocation) MarshalBinaryWithContext

func (target *Allocation) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this Allocation instance into a byte array leveraging a predefined context.

func (*Allocation) MarshalJSON

func (a *Allocation) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (*Allocation) Minutes

func (a *Allocation) Minutes() float64

Minutes returns the number of minutes the Allocation represents, as defined by the difference between the end and start times.

func (*Allocation) NetworkTotalCost

func (a *Allocation) NetworkTotalCost() float64

NetworkTotalCost calculates total Network cost of Allocation including adjustment

func (*Allocation) PVByteHours

func (a *Allocation) PVByteHours() float64

PVByteHours calculate cumulative ByteHours of all PVs that Allocation is attached to

func (*Allocation) PVBytes

func (a *Allocation) PVBytes() float64

PVBytes converts the Allocation's PVByteHours into average PVBytes

func (*Allocation) PVCost

func (a *Allocation) PVCost() float64

PVCost calculate cumulative cost of all PVs that Allocation is attached to

func (*Allocation) PVTotalCost

func (a *Allocation) PVTotalCost() float64

PVTotalCost calculates total PV cost of Allocation including adjustment

func (*Allocation) RAMBytes

func (a *Allocation) RAMBytes() float64

RAMBytes converts the Allocation's RAMByteHours into average RAMBytes

func (*Allocation) RAMEfficiency

func (a *Allocation) RAMEfficiency() float64

RAMEfficiency is the ratio of usage to request. If there is no request and no usage or cost, then efficiency is zero. If there is no request, but there is usage or cost, then efficiency is 100%.

func (*Allocation) RAMTotalCost

func (a *Allocation) RAMTotalCost() float64

RAMTotalCost calculates total RAM cost of Allocation including adjustment

func (*Allocation) ResetAdjustments

func (a *Allocation) ResetAdjustments()

ResetAdjustments sets all cost adjustment fields to zero

func (*Allocation) Resolution

func (a *Allocation) Resolution() time.Duration

Resolution returns the duration of time covered by the Allocation

func (*Allocation) Share

func (a *Allocation) Share(that *Allocation) (*Allocation, error)

Share adds the TotalCost of the given Allocation to the SharedCost of the receiving Allocation. No Start, End, Window, or AllocationProperties are considered. Neither Allocation is mutated; a new Allocation is always returned.

func (*Allocation) SharedTotalCost

func (a *Allocation) SharedTotalCost() float64

SharedTotalCost calculates total shared cost of Allocation including adjustment

func (*Allocation) String

func (a *Allocation) String() string

String represents the given Allocation as a string

func (*Allocation) TotalCost

func (a *Allocation) TotalCost() float64

TotalCost is the total cost of the Allocation including adjustments

func (*Allocation) TotalEfficiency

func (a *Allocation) TotalEfficiency() float64

TotalEfficiency is the cost-weighted average of CPU and RAM efficiency. If there is no cost at all, then efficiency is zero.

func (*Allocation) UnmarshalBinary

func (target *Allocation) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the Allocation type

func (*Allocation) UnmarshalBinaryWithContext

func (target *Allocation) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the Allocation type

type AllocationAggregationOptions

type AllocationAggregationOptions struct {
	AllocationTotalsStore AllocationTotalsStore
	FilterFuncs           []AllocationMatchFunc
	IdleByNode            bool
	LabelConfig           *LabelConfig
	MergeUnallocated      bool
	Reconcile             bool
	ReconcileNetwork      bool
	ShareFuncs            []AllocationMatchFunc
	ShareIdle             string
	ShareSplit            string
	SharedHourlyCosts     map[string]float64
	SplitIdle             bool
}

AllocationAggregationOptions provide advanced functionality to AggregateBy, including filtering results and sharing allocations. FilterFuncs are a list of match functions such that, if any function fails, the allocation is ignored. ShareFuncs are a list of match functions such that, if any function succeeds, the allocation is marked as a shared resource. ShareIdle is a simple flag for sharing idle resources.

type AllocationAnnotations

type AllocationAnnotations map[string]string

AllocationAnnotations is a schema-free mapping of key/value pairs that can be attributed to an Allocation

type AllocationFilter

type AllocationFilter interface {
	// Matches is the canonical in-Go function for determing if an Allocation
	// matches a filter.
	Matches(a *Allocation) bool

	// Flattened converts a filter into a minimal form, removing unnecessary
	// intermediate objects, like single-element or zero-element AND and OR
	// conditions.
	//
	// It returns nil if the filter is filtering nothing.
	//
	// Example:
	// (and (or (namespaceequals "kubecost")) (or)) ->
	// (namespaceequals "kubecost")
	//
	// (and (or)) -> nil
	Flattened() AllocationFilter

	String() string
}

AllocationFilter represents anything that can be used to filter an Allocation.

Implement this interface with caution. While it is generic, it is intended to be introspectable so query handlers can perform various optimizations. These optimizations include: - Routing a query to the most optimal cache - Querying backing data stores efficiently (e.g. translation to SQL)

Custom implementations of this interface outside of this package should not expect to receive these benefits. Passing a custom implementation to a handler may in errors.

type AllocationFilterAnd

type AllocationFilterAnd struct {
	Filters []AllocationFilter
}

AllocationFilterOr is a set of filters that should be evaluated as a logical AND.

func (AllocationFilterAnd) Flattened added in v1.95.0

func (filter AllocationFilterAnd) Flattened() AllocationFilter

Flattened converts a filter into a minimal form, removing unnecessary intermediate objects

Flattened returns: - nil if filter contains no filters - the inner filter if filter contains one filter - an equivalent AllocationFilterAnd if filter contains more than one filter

func (AllocationFilterAnd) Matches

func (and AllocationFilterAnd) Matches(a *Allocation) bool

func (AllocationFilterAnd) String added in v1.95.0

func (af AllocationFilterAnd) String() string

type AllocationFilterCondition

type AllocationFilterCondition struct {
	Field FilterField
	Op    FilterOp

	// Key is for filters that require key-value pairs, like labels or
	// annotations.
	//
	// A filter of 'label[app]:"foo"' has Key="app" and Value="foo"
	Key string

	// Value is for _all_ filters. A filter of 'namespace:"kubecost"' has
	// Value="kubecost"
	Value string
}

AllocationFilterCondition is the lowest-level type of filter. It represents the a filter operation (equality, inequality, etc.) on a field (namespace, label, etc.).

func (AllocationFilterCondition) Flattened added in v1.95.0

func (filter AllocationFilterCondition) Flattened() AllocationFilter

Flattened returns itself because you cannot flatten a base condition further

func (AllocationFilterCondition) Matches

func (filter AllocationFilterCondition) Matches(a *Allocation) bool

func (AllocationFilterCondition) String added in v1.95.0

func (afc AllocationFilterCondition) String() string

type AllocationFilterOr

type AllocationFilterOr struct {
	Filters []AllocationFilter
}

AllocationFilterOr is a set of filters that should be evaluated as a logical OR.

func (AllocationFilterOr) Flattened added in v1.95.0

func (filter AllocationFilterOr) Flattened() AllocationFilter

Flattened converts a filter into a minimal form, removing unnecessary intermediate objects

Flattened returns: - nil if filter contains no filters - the inner filter if filter contains one filter - an equivalent AllocationFilterOr if filter contains more than one filter

func (AllocationFilterOr) Matches

func (or AllocationFilterOr) Matches(a *Allocation) bool

func (AllocationFilterOr) String added in v1.95.0

func (af AllocationFilterOr) String() string

type AllocationLabels

type AllocationLabels map[string]string

AllocationLabels is a schema-free mapping of key/value pairs that can be attributed to an Allocation

type AllocationMatchFunc

type AllocationMatchFunc func(*Allocation) bool

AllocationMatchFunc is a function that can be used to match Allocations by returning true for any given Allocation if a condition is met.

type AllocationProperties

type AllocationProperties struct {
	Cluster        string                `json:"cluster,omitempty"`
	Node           string                `json:"node,omitempty"`
	Container      string                `json:"container,omitempty"`
	Controller     string                `json:"controller,omitempty"`
	ControllerKind string                `json:"controllerKind,omitempty"`
	Namespace      string                `json:"namespace,omitempty"`
	Pod            string                `json:"pod,omitempty"`
	Services       []string              `json:"services,omitempty"`
	ProviderID     string                `json:"providerID,omitempty"`
	Labels         AllocationLabels      `json:"labels,omitempty"`
	Annotations    AllocationAnnotations `json:"annotations,omitempty"`
}

AllocationProperties describes a set of Kubernetes objects.

func (*AllocationProperties) Clone

func (*AllocationProperties) Equal

func (*AllocationProperties) GenerateKey

func (p *AllocationProperties) GenerateKey(aggregateBy []string, labelConfig *LabelConfig) string

GenerateKey generates a string that represents the key by which the AllocationProperties should be aggregated, given the properties defined by the aggregateBy parameter and the given label configuration.

func (*AllocationProperties) Intersection

Intersection returns an *AllocationProperties which contains all matching fields between the calling and parameter AllocationProperties nillable slices and maps are left as nil

func (*AllocationProperties) MarshalBinary

func (target *AllocationProperties) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this AllocationProperties instance into a byte array

func (*AllocationProperties) MarshalBinaryWithContext

func (target *AllocationProperties) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this AllocationProperties instance into a byte array leveraging a predefined context.

func (*AllocationProperties) String

func (p *AllocationProperties) String() string

func (*AllocationProperties) UnmarshalBinary

func (target *AllocationProperties) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the AllocationProperties type

func (*AllocationProperties) UnmarshalBinaryWithContext

func (target *AllocationProperties) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the AllocationProperties type

type AllocationQuerier

type AllocationQuerier interface {
	QueryAllocation(start, end time.Time, opts *AllocationQueryOptions) (*AllocationSetRange, error)
}

AllocationQuerier interface defining api for requesting Allocation data

type AllocationQueryOptions

type AllocationQueryOptions struct {
	Accumulate              bool
	AccumulateBy            time.Duration
	AggregateBy             []string
	Compute                 bool
	DisableAggregatedStores bool
	FilterFuncs             []AllocationMatchFunc
	IdleByNode              bool
	IncludeExternal         bool
	IncludeIdle             bool
	LabelConfig             *LabelConfig
	MergeUnallocated        bool
	Reconcile               bool
	ReconcileNetwork        bool
	ShareFuncs              []AllocationMatchFunc
	SharedHourlyCosts       map[string]float64
	ShareIdle               string
	ShareSplit              string
	ShareTenancyCosts       bool
	SplitIdle               bool
	Step                    time.Duration
}

AllocationQueryOptions defines optional parameters for querying an Allocation Store

type AllocationReconciliationAudit added in v1.95.0

type AllocationReconciliationAudit struct {
	Status        AuditStatus
	Description   string
	LastRun       time.Time
	Resources     map[string]map[string]*AuditFloatResult
	MissingValues []*AuditMissingValue
}

AllocationReconciliationAudit records the differences of between compute resources (cpu, ram, gpu) costs between allocations by nodes and node assets keyed on node name and compute resource

func (*AllocationReconciliationAudit) Clone added in v1.95.0

Clone returns a deep copy of the caller

func (*AllocationReconciliationAudit) MarshalBinary added in v1.95.0

func (target *AllocationReconciliationAudit) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this AllocationReconciliationAudit instance into a byte array

func (*AllocationReconciliationAudit) MarshalBinaryWithContext added in v1.95.0

func (target *AllocationReconciliationAudit) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this AllocationReconciliationAudit instance into a byte array leveraging a predefined context.

func (*AllocationReconciliationAudit) UnmarshalBinary added in v1.95.0

func (target *AllocationReconciliationAudit) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the AllocationReconciliationAudit type

func (*AllocationReconciliationAudit) UnmarshalBinaryWithContext added in v1.95.0

func (target *AllocationReconciliationAudit) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the AllocationReconciliationAudit type

type AllocationSet

type AllocationSet struct {
	sync.RWMutex

	FromSource string // stores the name of the source used to compute the data
	Window     Window
	Warnings   []string
	Errors     []string
	// contains filtered or unexported fields
}

AllocationSet stores a set of Allocations, each with a unique name, that share a window. An AllocationSet is mutable, so treat it like a threadsafe map.

func GenerateMockAllocationSet

func GenerateMockAllocationSet(start time.Time) *AllocationSet

GenerateMockAllocationSet creates generic allocation set without idle allocations

func GenerateMockAllocationSetClusterIdle

func GenerateMockAllocationSetClusterIdle(start time.Time) *AllocationSet

GenerateMockAllocationSetClusterIdle creates generic allocation set which includes an idle set broken down by cluster

func GenerateMockAllocationSetNodeIdle

func GenerateMockAllocationSetNodeIdle(start time.Time) *AllocationSet

GenerateMockAllocationSetNodeIdle creates generic allocation set which includes an idle set broken down by node

func GenerateMockAllocationSetWithAssetProperties

func GenerateMockAllocationSetWithAssetProperties(start time.Time) *AllocationSet

GenerateMockAllocationSetWithAssetProperties with no idle and connections to Assets in properties

func NewAllocationSet

func NewAllocationSet(start, end time.Time, allocs ...*Allocation) *AllocationSet

NewAllocationSet instantiates a new AllocationSet and, optionally, inserts the given list of Allocations

func (*AllocationSet) AggregateBy

func (as *AllocationSet) AggregateBy(aggregateBy []string, options *AllocationAggregationOptions) error

AggregateBy aggregates the Allocations in the given AllocationSet by the given AllocationProperty. This will only be legal if the AllocationSet is divisible by the given AllocationProperty; e.g. Containers can be divided by Namespace, but not vice-a-versa.

func (*AllocationSet) Clone

func (as *AllocationSet) Clone() *AllocationSet

Clone returns a new AllocationSet with a deep copy of the given AllocationSet's allocations.

func (*AllocationSet) Delete

func (as *AllocationSet) Delete(name string)

Delete removes the allocation with the given name from the set

func (*AllocationSet) Each

func (as *AllocationSet) Each(f func(string, *Allocation))

Each invokes the given function for each Allocation in the set

func (*AllocationSet) End

func (as *AllocationSet) End() time.Time

End returns the End time of the AllocationSet window

func (*AllocationSet) ExternalAllocations

func (as *AllocationSet) ExternalAllocations() map[string]*Allocation

ExternalAllocations returns a map of the external allocations in the set. Returns clones of the actual Allocations, so mutability is not a problem.

func (*AllocationSet) ExternalCost

func (as *AllocationSet) ExternalCost() float64

ExternalCost returns the total aggregated external costs of the set

func (*AllocationSet) Get

func (as *AllocationSet) Get(key string) *Allocation

Get returns the Allocation at the given key in the AllocationSet

func (*AllocationSet) IdleAllocations

func (as *AllocationSet) IdleAllocations() map[string]*Allocation

IdleAllocations returns a map of the idle allocations in the AllocationSet. Returns clones of the actual Allocations, so mutability is not a problem.

func (*AllocationSet) Insert

func (as *AllocationSet) Insert(that *Allocation) error

Insert aggregates the current entry in the AllocationSet by the given Allocation, but only if the Allocation is valid, i.e. matches the AllocationSet's window. If there is no existing entry, one is created. Nil error response indicates success.

func (*AllocationSet) IsEmpty

func (as *AllocationSet) IsEmpty() bool

IsEmpty returns true if the AllocationSet is nil, or if it contains zero allocations.

func (*AllocationSet) Length

func (as *AllocationSet) Length() int

Length returns the number of Allocations in the set

func (*AllocationSet) Map

func (as *AllocationSet) Map() map[string]*Allocation

Map clones and returns a map of the AllocationSet's Allocations

func (*AllocationSet) MarshalBinary

func (target *AllocationSet) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this AllocationSet instance into a byte array

func (*AllocationSet) MarshalBinaryWithContext

func (target *AllocationSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this AllocationSet instance into a byte array leveraging a predefined context.

func (*AllocationSet) MarshalJSON

func (as *AllocationSet) MarshalJSON() ([]byte, error)

MarshalJSON JSON-encodes the AllocationSet

func (*AllocationSet) ResetAdjustments

func (as *AllocationSet) ResetAdjustments()

ResetAdjustments sets all cost adjustment fields to zero

func (*AllocationSet) Resolution

func (as *AllocationSet) Resolution() time.Duration

Resolution returns the AllocationSet's window duration

func (*AllocationSet) Set

func (as *AllocationSet) Set(alloc *Allocation) error

Set uses the given Allocation to overwrite the existing entry in the AllocationSet under the Allocation's name.

func (*AllocationSet) Start

func (as *AllocationSet) Start() time.Time

Start returns the Start time of the AllocationSet window

func (*AllocationSet) String

func (as *AllocationSet) String() string

String represents the given Allocation as a string

func (*AllocationSet) TotalCost

func (as *AllocationSet) TotalCost() float64

TotalCost returns the sum of all TotalCosts of the allocations contained

func (*AllocationSet) UTCOffset

func (as *AllocationSet) UTCOffset() time.Duration

UTCOffset returns the AllocationSet's configured UTCOffset.

func (*AllocationSet) UnmarshalBinary

func (target *AllocationSet) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the AllocationSet type

func (*AllocationSet) UnmarshalBinaryWithContext

func (target *AllocationSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the AllocationSet type

type AllocationSetRange

type AllocationSetRange struct {
	sync.RWMutex

	FromStore string // stores the name of the store used to retrieve the data
	// contains filtered or unexported fields
}

AllocationSetRange is a thread-safe slice of AllocationSets. It is meant to be used such that the AllocationSets held are consecutive and coherent with respect to using the same aggregation properties, UTC offset, and resolution. However these rules are not necessarily enforced, so use wisely.

func NewAllocationSetRange

func NewAllocationSetRange(allocs ...*AllocationSet) *AllocationSetRange

NewAllocationSetRange instantiates a new range composed of the given AllocationSets in the order provided.

func (*AllocationSetRange) Accumulate

func (asr *AllocationSetRange) Accumulate() (*AllocationSet, error)

Accumulate sums each AllocationSet in the given range, returning a single cumulative AllocationSet for the entire range.

func (*AllocationSetRange) AccumulateBy

func (asr *AllocationSetRange) AccumulateBy(resolution time.Duration) (*AllocationSetRange, error)

AccumulateBy sums AllocationSets based on the resolution given. The resolution given is subject to the scale used for the AllocationSets. Resolutions not evenly divisible by the AllocationSetRange window durations accumulate sets until a sum greater than or equal to the resolution is met, at which point AccumulateBy will start summing from 0 until the requested resolution is met again. If the requested resolution is smaller than the window of an AllocationSet then the resolution will default to the duration of a set. Resolutions larger than the duration of the entire AllocationSetRange will default to the duration of the range.

func (*AllocationSetRange) AggregateBy

func (asr *AllocationSetRange) AggregateBy(aggregateBy []string, options *AllocationAggregationOptions) error

AggregateBy aggregates each AllocationSet in the range by the given properties and options.

func (*AllocationSetRange) Append

func (asr *AllocationSetRange) Append(that *AllocationSet)

Append appends the given AllocationSet to the end of the range. It does not validate whether or not that violates window continuity.

func (*AllocationSetRange) Each

func (asr *AllocationSetRange) Each(f func(int, *AllocationSet))

Each invokes the given function for each AllocationSet in the range

func (*AllocationSetRange) End

func (asr *AllocationSetRange) End() (time.Time, error)

End returns the latest end of all Allocations in the AllocationSetRange. It returns an error if there are no allocations.

func (*AllocationSetRange) Get

func (asr *AllocationSetRange) Get(i int) (*AllocationSet, error)

Get retrieves the AllocationSet at the given index of the range.

func (*AllocationSetRange) InsertRange

func (asr *AllocationSetRange) InsertRange(that *AllocationSetRange) error

InsertRange merges the given AllocationSetRange into the receiving one by lining up sets with matching windows, then inserting each allocation from the given ASR into the respective set in the receiving ASR. If the given ASR contains an AllocationSet from a window that does not exist in the receiving ASR, then an error is returned. However, the given ASR does not need to cover the full range of the receiver.

func (*AllocationSetRange) Length

func (asr *AllocationSetRange) Length() int

Length returns the length of the range, which is zero if nil

func (*AllocationSetRange) MarshalBinary

func (target *AllocationSetRange) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this AllocationSetRange instance into a byte array

func (*AllocationSetRange) MarshalBinaryWithContext

func (target *AllocationSetRange) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this AllocationSetRange instance into a byte array leveraging a predefined context.

func (*AllocationSetRange) MarshalJSON

func (asr *AllocationSetRange) MarshalJSON() ([]byte, error)

MarshalJSON JSON-encodes the range

func (*AllocationSetRange) Minutes

func (asr *AllocationSetRange) Minutes() float64

Minutes returns the duration, in minutes, between the earliest start and the latest end of all allocations in the AllocationSetRange.

func (*AllocationSetRange) Slice

func (asr *AllocationSetRange) Slice() []*AllocationSet

Slice copies the underlying slice of AllocationSets, maintaining order, and returns the copied slice.

func (*AllocationSetRange) Start

func (asr *AllocationSetRange) Start() (time.Time, error)

Start returns the earliest start of all Allocations in the AllocationSetRange. It returns an error if there are no allocations.

func (*AllocationSetRange) String

func (asr *AllocationSetRange) String() string

String represents the given AllocationSetRange as a string

func (*AllocationSetRange) TotalCost

func (asr *AllocationSetRange) TotalCost() float64

TotalCost returns the sum of all TotalCosts of the allocations contained

func (*AllocationSetRange) UTCOffset

func (asr *AllocationSetRange) UTCOffset() time.Duration

UTCOffset returns the detected UTCOffset of the AllocationSets within the range. Defaults to 0 if the range is nil or empty. Does not warn if there are sets with conflicting UTCOffsets (just returns the first).

func (*AllocationSetRange) UnmarshalBinary

func (target *AllocationSetRange) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the AllocationSetRange type

func (*AllocationSetRange) UnmarshalBinaryWithContext

func (target *AllocationSetRange) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the AllocationSetRange type

func (*AllocationSetRange) Window

func (asr *AllocationSetRange) Window() Window

Window returns the full window that the AllocationSetRange spans, from the start of the first AllocationSet to the end of the last one.

type AllocationTotals

type AllocationTotals struct {
	Start                          time.Time `json:"start"`
	End                            time.Time `json:"end"`
	Cluster                        string    `json:"cluster"`
	Node                           string    `json:"node"`
	Count                          int       `json:"count"`
	CPUCost                        float64   `json:"cpuCost"`
	CPUCostAdjustment              float64   `json:"cpuCostAdjustment"`
	GPUCost                        float64   `json:"gpuCost"`
	GPUCostAdjustment              float64   `json:"gpuCostAdjustment"`
	LoadBalancerCost               float64   `json:"loadBalancerCost"`
	LoadBalancerCostAdjustment     float64   `json:"loadBalancerCostAdjustment"`
	NetworkCost                    float64   `json:"networkCost"`
	NetworkCostAdjustment          float64   `json:"networkCostAdjustment"`
	PersistentVolumeCost           float64   `json:"persistentVolumeCost"`
	PersistentVolumeCostAdjustment float64   `json:"persistentVolumeCostAdjustment"`
	RAMCost                        float64   `json:"ramCost"`
	RAMCostAdjustment              float64   `json:"ramCostAdjustment"`
}

AllocationTotals represents aggregate costs of all Allocations for a given cluster or tuple of (cluster, node) between a given start and end time, where the costs are aggregated per-resource. AllocationTotals is designed to be used as a pre-computed intermediate data structure when contextual knowledge is required to carry out a task, but computing totals on-the-fly would be expensive; e.g. idle allocation; sharing coefficients for idle or shared resources, etc.

func (*AllocationTotals) ClearAdjustments

func (art *AllocationTotals) ClearAdjustments()

ClearAdjustments sets all adjustment fields to 0.0

func (*AllocationTotals) Clone

func (art *AllocationTotals) Clone() *AllocationTotals

Clone deep copies the AllocationTotals

func (*AllocationTotals) TotalCPUCost

func (art *AllocationTotals) TotalCPUCost() float64

TotalCPUCost returns CPU cost with adjustment.

func (*AllocationTotals) TotalCost

func (art *AllocationTotals) TotalCost() float64

TotalCost returns the sum of all costs.

func (*AllocationTotals) TotalGPUCost

func (art *AllocationTotals) TotalGPUCost() float64

TotalGPUCost returns GPU cost with adjustment.

func (*AllocationTotals) TotalLoadBalancerCost

func (art *AllocationTotals) TotalLoadBalancerCost() float64

TotalLoadBalancerCost returns LoadBalancer cost with adjustment.

func (*AllocationTotals) TotalNetworkCost

func (art *AllocationTotals) TotalNetworkCost() float64

TotalNetworkCost returns Network cost with adjustment.

func (*AllocationTotals) TotalPersistentVolumeCost

func (art *AllocationTotals) TotalPersistentVolumeCost() float64

TotalPersistentVolumeCost returns PersistentVolume cost with adjustment.

func (*AllocationTotals) TotalRAMCost

func (art *AllocationTotals) TotalRAMCost() float64

TotalRAMCost returns RAM cost with adjustment.

type AllocationTotalsSet

type AllocationTotalsSet struct {
	Cluster map[string]*AllocationTotals `json:"cluster"`
	Node    map[string]*AllocationTotals `json:"node"`
	Window  Window                       `json:"window"`
}

AllocationTotalsSet represents totals, summed by both "cluster" and "node" for a given window of time.

func NewAllocationTotalsSet

func NewAllocationTotalsSet(window Window, byCluster, byNode map[string]*AllocationTotals) *AllocationTotalsSet

func UpdateAllocationTotalsStore

func UpdateAllocationTotalsStore(arts AllocationTotalsStore, as *AllocationSet) (*AllocationTotalsSet, error)

UpdateAllocationTotalsStore updates an AllocationTotalsStore by totaling the given AllocationSet and saving the totals.

type AllocationTotalsStore

type AllocationTotalsStore interface {
	GetAllocationTotalsByCluster(start, end time.Time) (map[string]*AllocationTotals, bool)
	GetAllocationTotalsByNode(start, end time.Time) (map[string]*AllocationTotals, bool)
	SetAllocationTotalsByCluster(start, end time.Time, rts map[string]*AllocationTotals)
	SetAllocationTotalsByNode(start, end time.Time, rts map[string]*AllocationTotals)
}

AllocationTotalsStore allows for storing (i.e. setting and getting) AllocationTotals by cluster and by node.

type Any

type Any struct {
	Cost float64
	// contains filtered or unexported fields
}

Any is the most general Asset, which is usually created as a result of adding two Assets of different types.

func NewAsset

func NewAsset(start, end time.Time, window Window) *Any

NewAsset creates a new Any-type Asset for the given period of time

func (*Any) Add

func (a *Any) Add(that Asset) Asset

Add sums the Asset with the given Asset to produce a new Asset, maintaining as much relevant information as possible (i.e. type, properties, labels).

func (*Any) Adjustment

func (a *Any) Adjustment() float64

Adjustment returns the Asset's cost adjustment

func (*Any) Clone

func (a *Any) Clone() Asset

Clone returns a cloned instance of the Asset

func (*Any) End

func (a *Any) End() time.Time

End returns the Asset's end time within the window

func (*Any) Equal

func (a *Any) Equal(that Asset) bool

Equal returns true if the given Asset is an exact match of the receiver

func (*Any) ExpandWindow

func (a *Any) ExpandWindow(window Window)

ExpandWindow expands the Asset's window by the given window

func (*Any) InterfaceToAny

func (a *Any) InterfaceToAny(itf interface{}) error

Converts interface{} to Any, carrying over relevant fields

func (*Any) Labels

func (a *Any) Labels() AssetLabels

Labels returns the Asset's labels

func (*Any) MarshalBinary

func (target *Any) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this Any instance into a byte array

func (*Any) MarshalBinaryWithContext

func (target *Any) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this Any instance into a byte array leveraging a predefined context.

func (*Any) MarshalJSON

func (a *Any) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (*Any) Minutes

func (a *Any) Minutes() float64

Minutes returns the number of minutes the Asset was active within the window

func (*Any) Properties

func (a *Any) Properties() *AssetProperties

Properties returns the Asset's properties

func (*Any) SetAdjustment

func (a *Any) SetAdjustment(adj float64)

SetAdjustment sets the Asset's cost adjustment

func (*Any) SetLabels

func (a *Any) SetLabels(labels AssetLabels)

SetLabels sets the Asset's labels

func (*Any) SetProperties

func (a *Any) SetProperties(props *AssetProperties)

SetProperties sets the Asset's properties

func (*Any) SetStartEnd

func (a *Any) SetStartEnd(start, end time.Time)

SetStartEnd sets the Asset's Start and End fields

func (*Any) Start

func (a *Any) Start() time.Time

Start returns the Asset's start time within the window

func (*Any) String

func (a *Any) String() string

String implements fmt.Stringer

func (*Any) TotalCost

func (a *Any) TotalCost() float64

TotalCost returns the Asset's TotalCost

func (*Any) Type

func (a *Any) Type() AssetType

Type returns the Asset's type

func (*Any) UnmarshalBinary

func (target *Any) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the Any type

func (*Any) UnmarshalBinaryWithContext

func (target *Any) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the Any type

func (*Any) UnmarshalJSON

func (a *Any) UnmarshalJSON(b []byte) error

func (*Any) Window

func (a *Any) Window() Window

Window returns the Asset's window

type Asset

type Asset interface {
	// Type identifies the kind of Asset, which must always exist and should
	// be defined by the underlying type implementing the interface.
	Type() AssetType

	// Properties are a map of predefined traits, which may or may not exist,
	// but must conform to the AssetProperty schema
	Properties() *AssetProperties
	SetProperties(*AssetProperties)

	// Labels are a map of undefined string-to-string values
	Labels() AssetLabels
	SetLabels(AssetLabels)

	// Monetary values
	Adjustment() float64
	SetAdjustment(float64)
	TotalCost() float64

	// Temporal values
	Start() time.Time
	End() time.Time
	SetStartEnd(time.Time, time.Time)
	Window() Window
	ExpandWindow(Window)
	Minutes() float64

	// Operations and comparisons
	Add(Asset) Asset
	Clone() Asset
	Equal(Asset) bool

	// Representations
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler
	json.Marshaler
	fmt.Stringer
}

Asset defines an entity within a cluster that has a defined cost over a given period of time.

type AssetAPIResponse

type AssetAPIResponse struct {
	Code int                   `json:"code"`
	Data AssetSetRangeResponse `json:"data"`
}

This is a helper type. The Asset API returns a json which cannot be natively unmarshaled into any Asset struct. Therefore, this struct IN COMBINATION WITH DESERIALIZATION LOGIC DEFINED IN asset_unmarshal.go can unmarshal a json directly from an Assets API query

type AssetAggregationOptions

type AssetAggregationOptions struct {
	SharedHourlyCosts map[string]float64
	FilterFuncs       []AssetMatchFunc
}

type AssetLabels

type AssetLabels map[string]string

AssetLabels is a schema-free mapping of key/value pairs that can be attributed to an Asset as a flexible a

func (AssetLabels) Append

func (al AssetLabels) Append(newLabels map[string]string, overwrite bool)

Append joins AssetLabels with a given map of labels

func (AssetLabels) Clone

func (al AssetLabels) Clone() AssetLabels

Clone returns a cloned map of labels

func (AssetLabels) Equal

func (al AssetLabels) Equal(that AssetLabels) bool

Equal returns true only if the two set of labels are exact matches

func (AssetLabels) Merge

func (al AssetLabels) Merge(that AssetLabels) AssetLabels

Merge retains only the labels shared with the given AssetLabels

type AssetMatchFunc

type AssetMatchFunc func(Asset) bool

AssetMatchFunc is a function that can be used to match Assets by returning true for any given Asset if a condition is met.

type AssetProperties

type AssetProperties struct {
	Category   string `json:"category,omitempty"`
	Provider   string `json:"provider,omitempty"`
	Account    string `json:"account,omitempty"`
	Project    string `json:"project,omitempty"`
	Service    string `json:"service,omitempty"`
	Cluster    string `json:"cluster,omitempty"`
	Name       string `json:"name,omitempty"`
	ProviderID string `json:"providerID,omitempty"`
}

AssetProperties describes all properties assigned to an Asset.

func (*AssetProperties) Clone

func (ap *AssetProperties) Clone() *AssetProperties

Clone returns a cloned instance of the given AssetProperties

func (*AssetProperties) Equal

func (ap *AssetProperties) Equal(that *AssetProperties) bool

Equal returns true only if both AssetProperties are non-nil exact matches

func (*AssetProperties) Keys

func (ap *AssetProperties) Keys(props []AssetProperty) []string

Keys returns the list of string values used to key the Asset based on the list of properties provided.

func (*AssetProperties) MarshalBinary

func (target *AssetProperties) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this AssetProperties instance into a byte array

func (*AssetProperties) MarshalBinaryWithContext

func (target *AssetProperties) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this AssetProperties instance into a byte array leveraging a predefined context.

func (*AssetProperties) Merge

Merge retains only the properties shared with the given AssetProperties

func (*AssetProperties) String

func (ap *AssetProperties) String() string

String represents the properties as a string

func (*AssetProperties) UnmarshalBinary

func (target *AssetProperties) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the AssetProperties type

func (*AssetProperties) UnmarshalBinaryWithContext

func (target *AssetProperties) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the AssetProperties type

type AssetProperty

type AssetProperty string

AssetProperty is a kind of property belonging to an Asset

const (
	// AssetNilProp is the zero-value of AssetProperty
	AssetNilProp AssetProperty = ""

	// AssetAccountProp describes the account of the Asset
	AssetAccountProp AssetProperty = "account"

	// AssetCategoryProp describes the category of the Asset
	AssetCategoryProp AssetProperty = "category"

	// AssetClusterProp describes the cluster of the Asset
	AssetClusterProp AssetProperty = "cluster"

	// AssetNameProp describes the name of the Asset
	AssetNameProp AssetProperty = "name"

	// AssetNodeProp describes the node of the Asset
	AssetNodeProp AssetProperty = "node"

	// AssetProjectProp describes the project of the Asset
	AssetProjectProp AssetProperty = "project"

	// AssetProviderProp describes the provider of the Asset
	AssetProviderProp AssetProperty = "provider"

	// AssetProviderIDProp describes the providerID of the Asset
	AssetProviderIDProp AssetProperty = "providerID"

	// AssetServiceProp describes the service of the Asset
	AssetServiceProp AssetProperty = "service"

	// AssetTypeProp describes the type of the Asset
	AssetTypeProp AssetProperty = "type"
)

func ParseAssetProperty

func ParseAssetProperty(text string) (AssetProperty, error)

ParseAssetProperty attempts to parse a string into an AssetProperty

type AssetQuerier

type AssetQuerier interface {
	QueryAsset(start, end time.Time, opts *AssetQueryOptions) (*AssetSetRange, error)
}

AssetQuerier interface defining api for requesting Asset data

type AssetQueryOptions

type AssetQueryOptions struct {
	Accumulate              bool
	AggregateBy             []string
	Compute                 bool
	DisableAdjustments      bool
	DisableAggregatedStores bool
	FilterFuncs             []AssetMatchFunc
	IncludeCloud            bool
	SharedHourlyCosts       map[string]float64
	Step                    time.Duration
}

AssetQueryOptions defines optional parameters for querying an Asset Store

type AssetReconciliationAudit added in v1.95.0

type AssetReconciliationAudit struct {
	Status        AuditStatus
	Description   string
	LastRun       time.Time
	Results       map[string]map[string]*AuditFloatResult
	MissingValues []*AuditMissingValue
}

AssetReconciliationAudit records differences in assets and the Cloud

func (*AssetReconciliationAudit) Clone added in v1.95.0

Clone returns a deep copy of the caller

func (*AssetReconciliationAudit) MarshalBinary added in v1.95.0

func (target *AssetReconciliationAudit) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this AssetReconciliationAudit instance into a byte array

func (*AssetReconciliationAudit) MarshalBinaryWithContext added in v1.95.0

func (target *AssetReconciliationAudit) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this AssetReconciliationAudit instance into a byte array leveraging a predefined context.

func (*AssetReconciliationAudit) UnmarshalBinary added in v1.95.0

func (target *AssetReconciliationAudit) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the AssetReconciliationAudit type

func (*AssetReconciliationAudit) UnmarshalBinaryWithContext added in v1.95.0

func (target *AssetReconciliationAudit) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the AssetReconciliationAudit type

type AssetSet

type AssetSet struct {
	sync.RWMutex

	FromSource string // stores the name of the source used to compute the data
	Window     Window
	Warnings   []string
	Errors     []string
	// contains filtered or unexported fields
}

AssetSet stores a set of Assets, each with a unique name, that share a window. An AssetSet is mutable, so treat it like a threadsafe map.

func GenerateMockAssetSet

func GenerateMockAssetSet(start time.Time) *AssetSet

GenerateMockAssetSet generates the following topology:

| Asset | Cost | Adj | +------------------------------+------+------+

cluster1:
  node1:                        6.00   1.00
  node2:                        4.00   1.50
  node3:                        7.00  -0.50
  disk1:                        2.50   0.00
  disk2:                        1.50   0.00
  clusterManagement1:           3.00   0.00

+------------------------------+------+------+

cluster1 subtotal              24.00   2.00

+------------------------------+------+------+

cluster2:
  node4:                       12.00  -1.00
  disk3:                        2.50   0.00
  disk4:                        1.50   0.00
  clusterManagement2:           0.00   0.00

+------------------------------+------+------+

cluster2 subtotal              16.00  -1.00

+------------------------------+------+------+

cluster3:
  node5:                       17.00   2.00

+------------------------------+------+------+

cluster3 subtotal              17.00   2.00

+------------------------------+------+------+

total                          57.00   3.00

+------------------------------+------+------+

func GenerateMockAssetSets

func GenerateMockAssetSets(start, end time.Time) []*AssetSet

GenerateMockAssetSets creates generic AssetSets

func NewAssetSet

func NewAssetSet(start, end time.Time, assets ...Asset) *AssetSet

NewAssetSet instantiates a new AssetSet and, optionally, inserts the given list of Assets

func (*AssetSet) AggregateBy

func (as *AssetSet) AggregateBy(aggregateBy []string, opts *AssetAggregationOptions) error

AggregateBy aggregates the Assets in the AssetSet by the given list of AssetProperties, such that each asset is binned by a key determined by its relevant property values.

func (*AssetSet) Clone

func (as *AssetSet) Clone() *AssetSet

Clone returns a new AssetSet with a deep copy of the given AssetSet's assets.

func (*AssetSet) Each

func (as *AssetSet) Each(f func(string, Asset))

Each invokes the given function for each Asset in the set

func (*AssetSet) End

func (as *AssetSet) End() time.Time

End returns the end time of the AssetSet's window

func (*AssetSet) FindMatch

func (as *AssetSet) FindMatch(query Asset, aggregateBy []string) (Asset, error)

FindMatch attempts to find a match in the AssetSet for the given Asset on the provided properties and labels. If a match is not found, FindMatch returns nil and a Not Found error.

func (*AssetSet) Get

func (as *AssetSet) Get(key string) (Asset, bool)

Get returns the Asset in the AssetSet at the given key, or nil and false if no Asset exists for the given key

func (*AssetSet) Insert

func (as *AssetSet) Insert(asset Asset) error

Insert inserts the given Asset into the AssetSet, using the AssetSet's configured properties to determine the key under which the Asset will be inserted.

func (*AssetSet) IsEmpty

func (as *AssetSet) IsEmpty() bool

IsEmpty returns true if the AssetSet is nil, or if it contains zero assets.

func (*AssetSet) Length

func (as *AssetSet) Length() int

func (*AssetSet) Map

func (as *AssetSet) Map() map[string]Asset

Map clones and returns a map of the AssetSet's Assets

func (*AssetSet) MarshalBinary

func (target *AssetSet) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this AssetSet instance into a byte array

func (*AssetSet) MarshalBinaryWithContext

func (target *AssetSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this AssetSet instance into a byte array leveraging a predefined context.

func (*AssetSet) MarshalJSON

func (as *AssetSet) MarshalJSON() ([]byte, error)

MarshalJSON JSON-encodes the AssetSet

func (*AssetSet) ReconciliationMatch

func (as *AssetSet) ReconciliationMatch(query Asset) (Asset, bool, error)

ReconciliationMatch attempts to find an exact match in the AssetSet on (Category, ProviderID). If a match is found, it returns the Asset with the intent to adjust it. If no match exists, it attempts to find one on only (ProviderID). If that match is found, it returns the Asset with the intent to insert the associated Cloud cost.

func (*AssetSet) ReconciliationMatchMap added in v1.95.0

func (as *AssetSet) ReconciliationMatchMap() map[string]map[string]Asset

ReconciliationMatchMap returns a map of the calling AssetSet's Assets, by provider id and category. This data structure allows for reconciliation matching to be done in constant time and prevents duplicate reconciliation.

func (*AssetSet) Resolution

func (as *AssetSet) Resolution() time.Duration

Resolution returns the AssetSet's window duration

func (*AssetSet) Set

func (as *AssetSet) Set(asset Asset, aggregateBy []string) error

func (*AssetSet) Start

func (as *AssetSet) Start() time.Time

func (*AssetSet) TotalCost

func (as *AssetSet) TotalCost() float64

func (*AssetSet) UTCOffset

func (as *AssetSet) UTCOffset() time.Duration

func (*AssetSet) UnmarshalBinary

func (target *AssetSet) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the AssetSet type

func (*AssetSet) UnmarshalBinaryWithContext

func (target *AssetSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the AssetSet type

type AssetSetRange

type AssetSetRange struct {
	sync.RWMutex

	FromStore string // stores the name of the store used to retrieve the data
	// contains filtered or unexported fields
}

AssetSetRange is a thread-safe slice of AssetSets. It is meant to be used such that the AssetSets held are consecutive and coherent with respect to using the same aggregation properties, UTC offset, and resolution. However these rules are not necessarily enforced, so use wisely.

func NewAssetSetRange

func NewAssetSetRange(assets ...*AssetSet) *AssetSetRange

NewAssetSetRange instantiates a new range composed of the given AssetSets in the order provided.

func (*AssetSetRange) Accumulate

func (asr *AssetSetRange) Accumulate() (*AssetSet, error)

Accumulate sums each AssetSet in the given range, returning a single cumulative AssetSet for the entire range.

func (*AssetSetRange) AggregateBy

func (asr *AssetSetRange) AggregateBy(aggregateBy []string, opts *AssetAggregationOptions) error

func (*AssetSetRange) Append

func (asr *AssetSetRange) Append(that *AssetSet)

func (*AssetSetRange) Each

func (asr *AssetSetRange) Each(f func(int, *AssetSet))

Each invokes the given function for each AssetSet in the range

func (*AssetSetRange) End

func (asr *AssetSetRange) End() (time.Time, error)

End returns the latest end of all Assets in the AssetSetRange. It returns an error if there are no assets.

func (*AssetSetRange) Get

func (asr *AssetSetRange) Get(i int) (*AssetSet, error)

func (*AssetSetRange) InsertRange

func (asr *AssetSetRange) InsertRange(that *AssetSetRange) error

InsertRange merges the given AssetSetRange into the receiving one by lining up sets with matching windows, then inserting each asset from the given ASR into the respective set in the receiving ASR. If the given ASR contains an AssetSetRange from a window that does not exist in the receiving ASR, then an error is returned. However, the given ASR does not need to cover the full range of the receiver.

func (*AssetSetRange) IsEmpty

func (asr *AssetSetRange) IsEmpty() bool

IsEmpty returns false if AssetSetRange contains a single AssetSet that is not empty

func (*AssetSetRange) Length

func (asr *AssetSetRange) Length() int

func (*AssetSetRange) MarshalBinary

func (target *AssetSetRange) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this AssetSetRange instance into a byte array

func (*AssetSetRange) MarshalBinaryWithContext

func (target *AssetSetRange) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this AssetSetRange instance into a byte array leveraging a predefined context.

func (*AssetSetRange) MarshalJSON

func (asr *AssetSetRange) MarshalJSON() ([]byte, error)

func (*AssetSetRange) Minutes

func (asr *AssetSetRange) Minutes() float64

Minutes returns the duration, in minutes, between the earliest start and the latest end of all assets in the AssetSetRange.

func (*AssetSetRange) Start

func (asr *AssetSetRange) Start() (time.Time, error)

Start returns the earliest start of all Assets in the AssetSetRange. It returns an error if there are no assets

func (*AssetSetRange) TotalCost

func (asr *AssetSetRange) TotalCost() float64

TotalCost returns the AssetSetRange's total cost

func (*AssetSetRange) UTCOffset

func (asr *AssetSetRange) UTCOffset() time.Duration

func (*AssetSetRange) UnmarshalBinary

func (target *AssetSetRange) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the AssetSetRange type

func (*AssetSetRange) UnmarshalBinaryWithContext

func (target *AssetSetRange) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the AssetSetRange type

func (*AssetSetRange) Window

func (asr *AssetSetRange) Window() Window

Window returns the full window that the AssetSetRange spans, from the start of the first AssetSet to the end of the last one.

type AssetSetRangeResponse

type AssetSetRangeResponse struct {
	Assets []*AssetSetResponse
}

As with AssetSet, AssetSetRange does not serialize all its fields, making it impossible to reconstruct the AssetSetRange from its json. Therefore, the type a marshaled AssetSetRange unmarshals to is AssetSetRangeResponse

func (*AssetSetRangeResponse) UnmarshalJSON

func (asrr *AssetSetRangeResponse) UnmarshalJSON(b []byte) error

type AssetSetResponse

type AssetSetResponse struct {
	Assets map[string]Asset
}

This type exists because only the assets map of AssetSet is marshaled to json, which makes it impossible to recreate an AssetSet struct. Thus, the type when unmarshaling a marshaled AssetSet,is AssetSetResponse

func (*AssetSetResponse) RawMessageToAssetSetResponse

func (asr *AssetSetResponse) RawMessageToAssetSetResponse(assetMap map[string]*json.RawMessage) error

func (*AssetSetResponse) UnmarshalJSON

func (asr *AssetSetResponse) UnmarshalJSON(b []byte) error

Unmarshals a marshaled AssetSet json into AssetSetResponse

type AssetTotals

type AssetTotals struct {
	Start                           time.Time `json:"start"`
	End                             time.Time `json:"end"`
	Cluster                         string    `json:"cluster"`
	Node                            string    `json:"node"`
	Count                           int       `json:"count"`
	AttachedVolumeCost              float64   `json:"attachedVolumeCost"`
	AttachedVolumeCostAdjustment    float64   `json:"attachedVolumeCostAdjustment"`
	ClusterManagementCost           float64   `json:"clusterManagementCost"`
	ClusterManagementCostAdjustment float64   `json:"clusterManagementCostAdjustment"`
	CPUCost                         float64   `json:"cpuCost"`
	CPUCostAdjustment               float64   `json:"cpuCostAdjustment"`
	GPUCost                         float64   `json:"gpuCost"`
	GPUCostAdjustment               float64   `json:"gpuCostAdjustment"`
	LoadBalancerCost                float64   `json:"loadBalancerCost"`
	LoadBalancerCostAdjustment      float64   `json:"loadBalancerCostAdjustment"`
	PersistentVolumeCost            float64   `json:"persistentVolumeCost"`
	PersistentVolumeCostAdjustment  float64   `json:"persistentVolumeCostAdjustment"`
	RAMCost                         float64   `json:"ramCost"`
	RAMCostAdjustment               float64   `json:"ramCostAdjustment"`
}

AssetTotals represents aggregate costs of all Assets for a given cluster or tuple of (cluster, node) between a given start and end time, where the costs are aggregated per-resource. AssetTotals is designed to be used as a pre-computed intermediate data structure when contextual knowledge is required to carry out a task, but computing totals on-the-fly would be expensive; e.g. idle allocation, shared tenancy costs

func (*AssetTotals) ClearAdjustments

func (art *AssetTotals) ClearAdjustments()

ClearAdjustments sets all adjustment fields to 0.0

func (*AssetTotals) Clone

func (art *AssetTotals) Clone() *AssetTotals

Clone deep copies the AssetTotals

func (*AssetTotals) TotalAttachedVolumeCost

func (art *AssetTotals) TotalAttachedVolumeCost() float64

TotalAttachedVolumeCost returns CPU cost with adjustment.

func (*AssetTotals) TotalCPUCost

func (art *AssetTotals) TotalCPUCost() float64

TotalCPUCost returns CPU cost with adjustment.

func (*AssetTotals) TotalClusterManagementCost

func (art *AssetTotals) TotalClusterManagementCost() float64

TotalClusterManagementCost returns ClusterManagement cost with adjustment.

func (*AssetTotals) TotalCost

func (art *AssetTotals) TotalCost() float64

TotalCost returns the sum of all costs

func (*AssetTotals) TotalGPUCost

func (art *AssetTotals) TotalGPUCost() float64

TotalGPUCost returns GPU cost with adjustment.

func (*AssetTotals) TotalLoadBalancerCost

func (art *AssetTotals) TotalLoadBalancerCost() float64

TotalLoadBalancerCost returns LoadBalancer cost with adjustment.

func (*AssetTotals) TotalPersistentVolumeCost

func (art *AssetTotals) TotalPersistentVolumeCost() float64

TotalPersistentVolumeCost returns PersistentVolume cost with adjustment.

func (*AssetTotals) TotalRAMCost

func (art *AssetTotals) TotalRAMCost() float64

TotalRAMCost returns RAM cost with adjustment.

type AssetTotalsSet

type AssetTotalsSet struct {
	Cluster map[string]*AssetTotals `json:"cluster"`
	Node    map[string]*AssetTotals `json:"node"`
	Window  Window                  `json:"window"`
}

AssetTotalsSet represents totals, summed by both "cluster" and "node" for a given window of time.

func NewAssetTotalsSet

func NewAssetTotalsSet(window Window, byCluster, byNode map[string]*AssetTotals) *AssetTotalsSet

func UpdateAssetTotalsStore

func UpdateAssetTotalsStore(arts AssetTotalsStore, as *AssetSet) (*AssetTotalsSet, error)

UpdateAssetTotalsStore updates an AssetTotalsStore by totaling the given AssetSet and saving the totals.

type AssetTotalsStore

type AssetTotalsStore interface {
	GetAssetTotalsByCluster(start, end time.Time) (map[string]*AssetTotals, bool)
	GetAssetTotalsByNode(start, end time.Time) (map[string]*AssetTotals, bool)
	SetAssetTotalsByCluster(start, end time.Time, rts map[string]*AssetTotals)
	SetAssetTotalsByNode(start, end time.Time, rts map[string]*AssetTotals)
}

AssetTotalsStore allows for storing (i.e. setting and getting) AssetTotals by cluster and by node.

type AssetType

type AssetType int

AssetType identifies a type of Asset

const (
	// AnyAssetType describes the Any AssetType
	AnyAssetType AssetType = iota

	// CloudAssetType describes the Cloud AssetType
	CloudAssetType

	// ClusterManagementAssetType describes the ClusterManagement AssetType
	ClusterManagementAssetType

	// DiskAssetType describes the Disk AssetType
	DiskAssetType

	// LoadBalancerAssetType describes the LoadBalancer AssetType
	LoadBalancerAssetType

	// NetworkAssetType describes the Network AssetType
	NetworkAssetType

	// NodeAssetType describes the Node AssetType
	NodeAssetType

	// SharedAssetType describes the Shared AssetType
	SharedAssetType
)

func ParseAssetType

func ParseAssetType(text string) (AssetType, error)

ParseAssetType attempts to parse the given string into an AssetType

func (AssetType) String

func (at AssetType) String() string

String converts the given AssetType to a string

type AuditCoverage added in v1.95.0

type AuditCoverage struct {
	sync.RWMutex
	AllocationReconciliation Window `json:"allocationReconciliation"`
	AllocationAgg            Window `json:"allocationAgg"`
	AllocationTotal          Window `json:"allocationTotal"`
	AssetTotal               Window `json:"assetTotal"`
	AssetReconciliation      Window `json:"assetReconciliation"`
	ClusterEquality          Window `json:"clusterEquality"`
}

AuditCoverage tracks coverage of each audit type

func NewAuditCoverage added in v1.95.0

func NewAuditCoverage() *AuditCoverage

NewAuditCoverage create default AuditCoverage

func (*AuditCoverage) Update added in v1.95.0

func (ac *AuditCoverage) Update(as *AuditSet)

Update expands the coverage of each Window in the coverage that the given AuditSet's Window if the corresponding Audit is not nil Note: This means of determining coverage can lead to holes in the given window

type AuditFloatResult added in v1.95.0

type AuditFloatResult struct {
	Expected float64
	Actual   float64
}

AuditFloatResult structure for holding the results of a failed audit on a float value, Expected should be the value calculated by the Audit func while Actual is what is contained in the relevant store.

func (*AuditFloatResult) Clone added in v1.95.0

func (afr *AuditFloatResult) Clone() *AuditFloatResult

Clone returns a deep copy of the caller

func (*AuditFloatResult) MarshalBinary added in v1.95.0

func (target *AuditFloatResult) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this AuditFloatResult instance into a byte array

func (*AuditFloatResult) MarshalBinaryWithContext added in v1.95.0

func (target *AuditFloatResult) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this AuditFloatResult instance into a byte array leveraging a predefined context.

func (*AuditFloatResult) UnmarshalBinary added in v1.95.0

func (target *AuditFloatResult) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the AuditFloatResult type

func (*AuditFloatResult) UnmarshalBinaryWithContext added in v1.95.0

func (target *AuditFloatResult) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the AuditFloatResult type

type AuditMissingValue added in v1.95.0

type AuditMissingValue struct {
	Description string
	Key         string
}

AuditMissingValue records when a value that should be present in a store or in the audit generated results are missing

func (*AuditMissingValue) MarshalBinary added in v1.95.0

func (target *AuditMissingValue) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this AuditMissingValue instance into a byte array

func (*AuditMissingValue) MarshalBinaryWithContext added in v1.95.0

func (target *AuditMissingValue) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this AuditMissingValue instance into a byte array leveraging a predefined context.

func (*AuditMissingValue) UnmarshalBinary added in v1.95.0

func (target *AuditMissingValue) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the AuditMissingValue type

func (*AuditMissingValue) UnmarshalBinaryWithContext added in v1.95.0

func (target *AuditMissingValue) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the AuditMissingValue type

type AuditSet added in v1.95.0

type AuditSet struct {
	sync.RWMutex
	AllocationReconciliation *AllocationReconciliationAudit `json:"allocationReconciliation"`
	AllocationAgg            *AggAudit                      `json:"allocationAgg"`
	AllocationTotal          *TotalAudit                    `json:"allocationTotal"`
	AssetTotal               *TotalAudit                    `json:"assetTotal"`
	AssetReconciliation      *AssetReconciliationAudit      `json:"assetReconciliation"`
	ClusterEquality          *EqualityAudit                 `json:"clusterEquality"`
	Window                   Window                         `json:"window"`
}

AuditSet is a ETLSet which contains all kind of Audits for a given Window

func NewAuditSet added in v1.95.0

func NewAuditSet(start, end time.Time) *AuditSet

NewAuditSet creates an empty AuditSet with the given window

func (*AuditSet) Clone added in v1.95.0

func (as *AuditSet) Clone() *AuditSet

Clone returns a deep copy of the caller

func (*AuditSet) CloneSet added in v1.95.0

func (as *AuditSet) CloneSet() ETLSet

CloneSet returns a deep copy of the caller and returns set

func (*AuditSet) ConstructSet added in v1.95.0

func (as *AuditSet) ConstructSet() ETLSet

ConstructSet fulfills the ETLSet interface to provide an empty version of itself so that it can be initialized in its generic form.

func (*AuditSet) GetWindow added in v1.95.0

func (as *AuditSet) GetWindow() Window

GetWindow returns AuditSet Window

func (*AuditSet) IsEmpty added in v1.95.0

func (as *AuditSet) IsEmpty() bool

IsEmpty returns true if any of the audits are non-nil

func (*AuditSet) MarshalBinary added in v1.95.0

func (target *AuditSet) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this AuditSet instance into a byte array

func (*AuditSet) MarshalBinaryWithContext added in v1.95.0

func (target *AuditSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this AuditSet instance into a byte array leveraging a predefined context.

func (*AuditSet) UnmarshalBinary added in v1.95.0

func (target *AuditSet) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the AuditSet type

func (*AuditSet) UnmarshalBinaryWithContext added in v1.95.0

func (target *AuditSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the AuditSet type

func (*AuditSet) UpdateAuditSet added in v1.95.0

func (as *AuditSet) UpdateAuditSet(that *AuditSet) *AuditSet

UpdateAuditSet overwrites any audit fields in the caller with those in the given AuditSet which are not nil

type AuditSetRange added in v1.95.0

type AuditSetRange struct {
	SetRange[*AuditSet]
}

AuditSetRange SetRange of AuditSets

func (*AuditSetRange) MarshalBinary added in v1.95.0

func (target *AuditSetRange) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this AuditSetRange instance into a byte array

func (*AuditSetRange) MarshalBinaryWithContext added in v1.95.0

func (target *AuditSetRange) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this AuditSetRange instance into a byte array leveraging a predefined context.

func (*AuditSetRange) UnmarshalBinary added in v1.95.0

func (target *AuditSetRange) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the AuditSetRange type

func (*AuditSetRange) UnmarshalBinaryWithContext added in v1.95.0

func (target *AuditSetRange) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the AuditSetRange type

type AuditStatus added in v1.95.0

type AuditStatus string

AuditStatus are possible outcomes of an audit

type AuditType added in v1.95.0

type AuditType string

AuditType the types of Audits, each of which should be contained in an AuditSet

const (
	AuditAllocationReconciliation AuditType = "AuditAllocationReconciliation"
	AuditAllocationTotalStore     AuditType = "AuditAllocationTotalStore"
	AuditAllocationAggStore       AuditType = "AuditAllocationAggStore"
	AuditAssetReconciliation      AuditType = "AuditAssetReconciliation"
	AuditAssetTotalStore          AuditType = "AuditAssetTotalStore"
	AuditAssetAggStore            AuditType = "AuditAssetAggStore"
	AuditClusterEquality          AuditType = "AuditClusterEquality"

	AuditAll         AuditType = ""
	AuditInvalidType AuditType = "InvalidType"
)

func ToAuditType added in v1.95.0

func ToAuditType(check string) AuditType

ToAuditType converts a string to an Audit type

type BinDecoder

type BinDecoder interface {
	UnmarshalBinaryWithContext(*DecodingContext) error
}

BinDecoder is a decoding interface which defines a context based unmarshal contract.

type BinEncoder

type BinEncoder interface {
	MarshalBinaryWithContext(*EncodingContext) error
}

BinEncoder is an encoding interface which defines a context based marshal contract.

type BoundaryError

type BoundaryError struct {
	Requested Window
	Supported Window
	Message   string
}

func NewBoundaryError

func NewBoundaryError(req, sup Window, msg string) *BoundaryError

func (*BoundaryError) Error

func (be *BoundaryError) Error() string

type Breakdown

type Breakdown struct {
	Idle   float64 `json:"idle"`
	Other  float64 `json:"other"`
	System float64 `json:"system"`
	User   float64 `json:"user"`
}

Breakdown describes a resource's use as a percentage of various usage types

func (*Breakdown) Clone

func (b *Breakdown) Clone() *Breakdown

Clone returns a cloned instance of the Breakdown

func (*Breakdown) Equal

func (b *Breakdown) Equal(that *Breakdown) bool

Equal returns true if the two Breakdowns are exact matches

func (*Breakdown) MarshalBinary

func (target *Breakdown) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this Breakdown instance into a byte array

func (*Breakdown) MarshalBinaryWithContext

func (target *Breakdown) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this Breakdown instance into a byte array leveraging a predefined context.

func (*Breakdown) UnmarshalBinary

func (target *Breakdown) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the Breakdown type

func (*Breakdown) UnmarshalBinaryWithContext

func (target *Breakdown) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the Breakdown type

type Cloud

type Cloud struct {
	Cost   float64
	Credit float64 // Credit is a negative value representing dollars credited back to a given line-item
	// contains filtered or unexported fields
}

Cloud describes a cloud asset

func NewCloud

func NewCloud(category, providerID string, start, end time.Time, window Window) *Cloud

NewCloud returns a new Cloud Asset

func (*Cloud) Add

func (ca *Cloud) Add(a Asset) Asset

Add sums the Asset with the given Asset to produce a new Asset, maintaining as much relevant information as possible (i.e. type, properties, labels).

func (*Cloud) Adjustment

func (ca *Cloud) Adjustment() float64

Adjustment returns the Asset's adjustment value

func (*Cloud) Clone

func (ca *Cloud) Clone() Asset

Clone returns a cloned instance of the Asset

func (*Cloud) End

func (ca *Cloud) End() time.Time

End returns the Asset's precise end time within the window

func (*Cloud) Equal

func (ca *Cloud) Equal(a Asset) bool

Equal returns true if the given Asset precisely equals the Asset

func (*Cloud) ExpandWindow

func (ca *Cloud) ExpandWindow(window Window)

ExpandWindow expands the Asset's window by the given window

func (*Cloud) InterfaceToCloud

func (ca *Cloud) InterfaceToCloud(itf interface{}) error

Converts interface{} to Cloud, carrying over relevant fields

func (*Cloud) Labels

func (ca *Cloud) Labels() AssetLabels

Labels returns the AssetLabels

func (*Cloud) MarshalBinary

func (target *Cloud) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this Cloud instance into a byte array

func (*Cloud) MarshalBinaryWithContext

func (target *Cloud) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this Cloud instance into a byte array leveraging a predefined context.

func (*Cloud) MarshalJSON

func (ca *Cloud) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (*Cloud) Minutes

func (ca *Cloud) Minutes() float64

Minutes returns the number of Minutes the Asset ran

func (*Cloud) Properties

func (ca *Cloud) Properties() *AssetProperties

Properties returns the AssetProperties

func (*Cloud) SetAdjustment

func (ca *Cloud) SetAdjustment(adj float64)

SetAdjustment sets the Asset's adjustment value

func (*Cloud) SetLabels

func (ca *Cloud) SetLabels(labels AssetLabels)

SetLabels sets the Asset's labels

func (*Cloud) SetProperties

func (ca *Cloud) SetProperties(props *AssetProperties)

SetProperties sets the Asset's properties

func (*Cloud) SetStartEnd

func (ca *Cloud) SetStartEnd(start, end time.Time)

SetStartEnd sets the Asset's Start and End fields

func (*Cloud) Start

func (ca *Cloud) Start() time.Time

Start returns the Asset's precise start time within the window

func (*Cloud) String

func (ca *Cloud) String() string

String implements fmt.Stringer

func (*Cloud) TotalCost

func (ca *Cloud) TotalCost() float64

TotalCost returns the Asset's total cost

func (*Cloud) Type

func (ca *Cloud) Type() AssetType

Type returns the AssetType

func (*Cloud) UnmarshalBinary

func (target *Cloud) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the Cloud type

func (*Cloud) UnmarshalBinaryWithContext

func (target *Cloud) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the Cloud type

func (*Cloud) UnmarshalJSON

func (ca *Cloud) UnmarshalJSON(b []byte) error

func (*Cloud) Window

func (ca *Cloud) Window() Window

Window returns the window within which the Asset ran

type CloudAssetStatus

type CloudAssetStatus struct {
	Coverage    Window    `json:"coverage"`
	LastRun     time.Time `json:"lastRun"`
	NextRun     time.Time `json:"nextRun"`
	Progress    float64   `json:"progress"`
	RefreshRate string    `json:"refreshRate"`
	Resolution  string    `json:"resolution"`
	StartTime   time.Time `json:"startTime"`
}

CloudAssetStatus describes CloudAsset metadata of a CloudStore

type CloudStatus

type CloudStatus struct {
	CloudConnectionStatus string                `json:"cloudConnectionStatus"`
	ProviderType          string                `json:"providerType"`
	CloudUsage            *CloudAssetStatus     `json:"cloudUsage,omitempty"`
	Reconciliation        *ReconciliationStatus `json:"reconciliation,omitempty"`
}

CloudStatus describes CloudStore metadata

type CloudUsage

type CloudUsage = Cloud

CloudUsage is temporarily aliased as the Cloud Asset type until further infrastructure and pages can be built to support its usage

type CloudUsageAggregationOptions

type CloudUsageAggregationOptions = AssetAggregationOptions

CloudUsageAggregationOptions is temporarily aliased as the AssetAggregationOptions until further infrastructure and pages can be built to support its usage

type CloudUsageFilter

type CloudUsageFilter struct {
	Categories  []string            `json:"categories"`
	Providers   []string            `json:"providers"`
	ProviderIDs []string            `json:"providerIDs"`
	Accounts    []string            `json:"accounts"`
	Projects    []string            `json:"projects"`
	Services    []string            `json:"services"`
	Labels      map[string][]string `json:"labels"`
}

type CloudUsageMatchFunc

type CloudUsageMatchFunc = AssetMatchFunc

CloudUsageMatchFunc is temporarily aliased as the AssetMatchFunc until further infrastructure and pages can be built to support its usage

type CloudUsageQuerier

type CloudUsageQuerier interface {
	QueryCloudUsage(start, end time.Time, opts *CloudUsageQueryOptions) (*CloudUsageSetRange, error)
}

CloudUsageQuerier interface defining api for requesting CloudUsage data

type CloudUsageQueryOptions

type CloudUsageQueryOptions struct {
	Accumulate   bool
	AggregateBy  []string
	Compute      bool
	FilterFuncs  []CloudUsageMatchFunc
	FilterValues CloudUsageFilter
}

CloudUsageQueryOptions define optional parameters for querying a Store

type CloudUsageSet

type CloudUsageSet = AssetSet

CloudUsageSet is temporarily aliased as the AssetSet until further infrastructure and pages can be built to support its usage

type CloudUsageSetRange

type CloudUsageSetRange = AssetSetRange

CloudUsageSetRange is temporarily aliased as the AssetSetRange until further infrastructure and pages can be built to support its usage

type ClusterManagement

type ClusterManagement struct {
	Cost float64
	// contains filtered or unexported fields
}

ClusterManagement describes a provider's cluster management fee

func NewClusterManagement

func NewClusterManagement(provider, cluster string, window Window) *ClusterManagement

NewClusterManagement creates and returns a new ClusterManagement instance

func (*ClusterManagement) Add

func (cm *ClusterManagement) Add(a Asset) Asset

Add sums the Asset with the given Asset to produce a new Asset, maintaining as much relevant information as possible (i.e. type, properties, labels).

func (*ClusterManagement) Adjustment

func (cm *ClusterManagement) Adjustment() float64

Adjustment does not apply to ClusterManagement

func (*ClusterManagement) Clone

func (cm *ClusterManagement) Clone() Asset

Clone returns a cloned instance of the Asset

func (*ClusterManagement) End

func (cm *ClusterManagement) End() time.Time

End returns the Asset's precise end time within the window

func (*ClusterManagement) Equal

func (cm *ClusterManagement) Equal(a Asset) bool

Equal returns true if the given Asset exactly matches the Asset

func (*ClusterManagement) ExpandWindow

func (cm *ClusterManagement) ExpandWindow(window Window)

ExpandWindow expands the Asset's window by the given window

func (*ClusterManagement) InterfaceToClusterManagement

func (cm *ClusterManagement) InterfaceToClusterManagement(itf interface{}) error

Converts interface{} to ClusterManagement, carrying over relevant fields

func (*ClusterManagement) Labels

func (cm *ClusterManagement) Labels() AssetLabels

Labels returns the Asset's labels

func (*ClusterManagement) MarshalBinary

func (target *ClusterManagement) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this ClusterManagement instance into a byte array

func (*ClusterManagement) MarshalBinaryWithContext

func (target *ClusterManagement) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this ClusterManagement instance into a byte array leveraging a predefined context.

func (*ClusterManagement) MarshalJSON

func (cm *ClusterManagement) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshler

func (*ClusterManagement) Minutes

func (cm *ClusterManagement) Minutes() float64

Minutes returns the number of minutes the Asset ran

func (*ClusterManagement) Properties

func (cm *ClusterManagement) Properties() *AssetProperties

Properties returns the Asset's properties

func (*ClusterManagement) SetAdjustment

func (cm *ClusterManagement) SetAdjustment(adj float64)

SetAdjustment does not apply to ClusterManagement

func (*ClusterManagement) SetLabels

func (cm *ClusterManagement) SetLabels(props AssetLabels)

SetLabels sets the Asset's properties

func (*ClusterManagement) SetProperties

func (cm *ClusterManagement) SetProperties(props *AssetProperties)

SetProperties sets the Asset's properties

func (*ClusterManagement) SetStartEnd

func (cm *ClusterManagement) SetStartEnd(start, end time.Time)

SetStartEnd sets the Asset's Start and End fields (not applicable here)

func (*ClusterManagement) Start

func (cm *ClusterManagement) Start() time.Time

Start returns the Asset's precise start time within the window

func (*ClusterManagement) String

func (cm *ClusterManagement) String() string

String implements fmt.Stringer

func (*ClusterManagement) TotalCost

func (cm *ClusterManagement) TotalCost() float64

TotalCost returns the Asset's total cost

func (*ClusterManagement) Type

func (cm *ClusterManagement) Type() AssetType

Type returns the Asset's type

func (*ClusterManagement) UnmarshalBinary

func (target *ClusterManagement) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the ClusterManagement type

func (*ClusterManagement) UnmarshalBinaryWithContext

func (target *ClusterManagement) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the ClusterManagement type

func (*ClusterManagement) UnmarshalJSON

func (cm *ClusterManagement) UnmarshalJSON(b []byte) error

func (*ClusterManagement) Window

func (cm *ClusterManagement) Window() Window

Window return the Asset's window

type DecodingContext

type DecodingContext struct {
	Buffer *util.Buffer
	Table  []string
}

DecodingContext is a context object passed to the decoders to ensure parent objects reuse as much data as possible

func (*DecodingContext) IsStringTable

func (dc *DecodingContext) IsStringTable() bool

IsStringTable returns true if the table is available

type Diff added in v1.95.0

type Diff[T any] struct {
	Entity T
	Kind   DiffKind
}

Diff stores an object and a string that denotes whether that object was added or removed from a set of those objects

func DiffAsset added in v1.95.0

func DiffAsset(before, after *AssetSet) []Diff[Asset]

DiffAsset takes two AssetSets and returns a slice of Diffs by checking the keys of each AssetSet. If a key is not found, a Diff is generated and added to the slice.

type DiffKind added in v1.95.0

type DiffKind string
const (
	DiffAdded   DiffKind = "added"
	DiffRemoved          = "removed"
)

type DirectoryStatus

type DirectoryStatus struct {
	Path         string       `json:"path"`
	Size         string       `json:"size"`
	LastModified time.Time    `json:"lastModified"`
	FileCount    int          `json:"fileCount"`
	Files        []FileStatus `json:"files"`
}

DirectoryStatus describes metadata of a directory of files

type Disk

type Disk struct {
	Cost      float64
	ByteHours float64
	Local     float64
	Breakdown *Breakdown
	// contains filtered or unexported fields
}

Disk represents an in-cluster disk Asset

func NewDisk

func NewDisk(name, cluster, providerID string, start, end time.Time, window Window) *Disk

NewDisk creates and returns a new Disk Asset

func (*Disk) Add

func (d *Disk) Add(a Asset) Asset

Add sums the Asset with the given Asset to produce a new Asset, maintaining as much relevant information as possible (i.e. type, properties, labels).

func (*Disk) Adjustment

func (d *Disk) Adjustment() float64

Adjustment returns the Asset's cost adjustment

func (*Disk) Bytes

func (d *Disk) Bytes() float64

Bytes returns the number of bytes belonging to the disk. This could be fractional because it's the number of byte*hours divided by the number of hours running; e.g. the sum of a 100GiB disk running for the first 10 hours and a 30GiB disk running for the last 20 hours of the same 24-hour window would produce:

(100*10 + 30*20) / 24 = 66.667GiB

However, any number of disks running for the full span of a window will report the actual number of bytes of the static disk; e.g. the above scenario for one entire 24-hour window:

(100*24 + 30*24) / 24 = (100 + 30) = 130GiB

func (*Disk) Clone

func (d *Disk) Clone() Asset

Clone returns a cloned instance of the Asset

func (*Disk) End

func (d *Disk) End() time.Time

End returns the precise start time of the Asset within the window

func (*Disk) Equal

func (d *Disk) Equal(a Asset) bool

Equal returns true if the two Assets match exactly

func (*Disk) ExpandWindow

func (d *Disk) ExpandWindow(window Window)

ExpandWindow expands the Asset's window by the given window

func (*Disk) InterfaceToDisk

func (d *Disk) InterfaceToDisk(itf interface{}) error

Converts interface{} to Disk, carrying over relevant fields

func (*Disk) Labels

func (d *Disk) Labels() AssetLabels

Labels returns the Asset's labels

func (*Disk) MarshalBinary

func (target *Disk) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this Disk instance into a byte array

func (*Disk) MarshalBinaryWithContext

func (target *Disk) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this Disk instance into a byte array leveraging a predefined context.

func (*Disk) MarshalJSON

func (d *Disk) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (*Disk) Minutes

func (d *Disk) Minutes() float64

Minutes returns the number of minutes the Asset ran

func (*Disk) Properties

func (d *Disk) Properties() *AssetProperties

Properties returns the Asset's properties

func (*Disk) SetAdjustment

func (d *Disk) SetAdjustment(adj float64)

SetAdjustment sets the Asset's cost adjustment

func (*Disk) SetLabels

func (d *Disk) SetLabels(labels AssetLabels)

SetLabels sets the Asset's labels

func (*Disk) SetProperties

func (d *Disk) SetProperties(props *AssetProperties)

SetProperties sets the Asset's properties

func (*Disk) SetStartEnd

func (d *Disk) SetStartEnd(start, end time.Time)

SetStartEnd sets the Asset's Start and End fields

func (*Disk) Start

func (d *Disk) Start() time.Time

Start returns the precise start time of the Asset within the window

func (*Disk) String

func (d *Disk) String() string

String implements fmt.Stringer

func (*Disk) TotalCost

func (d *Disk) TotalCost() float64

TotalCost returns the Asset's total cost

func (*Disk) Type

func (d *Disk) Type() AssetType

Type returns the AssetType of the Asset

func (*Disk) UnmarshalBinary

func (target *Disk) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the Disk type

func (*Disk) UnmarshalBinaryWithContext

func (target *Disk) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the Disk type

func (*Disk) UnmarshalJSON

func (d *Disk) UnmarshalJSON(b []byte) error

func (*Disk) Window

func (d *Disk) Window() Window

Window returns the window within which the Asset

type ETLSet added in v1.95.0

type ETLSet interface {
	ConstructSet() ETLSet
	CloneSet() ETLSet
	IsEmpty() bool
	GetWindow() Window

	// Representations
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler
}

ETLSet is an interface which represents the basic data block of an ETL. It is keyed by its Window

type ETLStatus

type ETLStatus struct {
	Coverage                   Window           `json:"coverage"`
	LastRun                    time.Time        `json:"lastRun"`
	Progress                   float64          `json:"progress"`
	RefreshRate                string           `json:"refreshRate"`
	Resolution                 string           `json:"resolution"`
	MaxPrometheusQueryDuration string           `json:"maxPrometheusQueryDuration"`
	StartTime                  time.Time        `json:"startTime"`
	UTCOffset                  string           `json:"utcOffset"`
	Backup                     *DirectoryStatus `json:"backup,omitempty"`
}

ETLStatus describes ETL metadata

type EncodingContext

type EncodingContext struct {
	Buffer *util.Buffer
	Table  *StringTable
}

EncodingContext is a context object passed to the encoders to ensure reuse of buffer and table data

func (*EncodingContext) IsStringTable

func (ec *EncodingContext) IsStringTable() bool

IsStringTable returns true if the table is available

type EqualityAudit added in v1.95.0

type EqualityAudit struct {
	Status        AuditStatus
	Description   string
	LastRun       time.Time
	Clusters      map[string]*AuditFloatResult
	MissingValues []*AuditMissingValue
}

EqualityAudit records the difference in cost between Allocations and Assets aggregated by cluster and keyed on cluster

func (*EqualityAudit) Clone added in v1.95.0

func (ea *EqualityAudit) Clone() *EqualityAudit

Clone returns a deep copy of the caller

func (*EqualityAudit) MarshalBinary added in v1.95.0

func (target *EqualityAudit) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this EqualityAudit instance into a byte array

func (*EqualityAudit) MarshalBinaryWithContext added in v1.95.0

func (target *EqualityAudit) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this EqualityAudit instance into a byte array leveraging a predefined context.

func (*EqualityAudit) UnmarshalBinary added in v1.95.0

func (target *EqualityAudit) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the EqualityAudit type

func (*EqualityAudit) UnmarshalBinaryWithContext added in v1.95.0

func (target *EqualityAudit) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the EqualityAudit type

type FileStatus

type FileStatus struct {
	Name         string            `json:"name"`
	Size         string            `json:"size"`
	LastModified time.Time         `json:"lastModified"`
	IsRepairing  bool              `json:"isRepairing"`
	Details      map[string]string `json:"details,omitempty"`
	Errors       []string          `json:"errors,omitempty"`
	Warnings     []string          `json:"warnings,omitempty"`
}

FileStatus describes the metadata of a single file

type FilterField

type FilterField string

FilterField is an enum that represents Allocation-specific fields that can be filtered on (namespace, label, etc.)

type FilterOp

type FilterOp string

FilterOp is an enum that represents operations that can be performed when filtering (equality, inequality, etc.)

type LabelConfig

type LabelConfig struct {
	DepartmentLabel          string `json:"department_label"`
	EnvironmentLabel         string `json:"environment_label"`
	OwnerLabel               string `json:"owner_label"`
	ProductLabel             string `json:"product_label"`
	TeamLabel                string `json:"team_label"`
	ClusterExternalLabel     string `json:"cluster_external_label"`
	NamespaceExternalLabel   string `json:"namespace_external_label"`
	ControllerExternalLabel  string `json:"controller_external_label"`
	DaemonsetExternalLabel   string `json:"daemonset_external_label"`
	DeploymentExternalLabel  string `json:"deployment_external_label"`
	StatefulsetExternalLabel string `json:"statefulset_external_label"`
	ServiceExternalLabel     string `json:"service_external_label"`
	PodExternalLabel         string `json:"pod_external_label"`
	DepartmentExternalLabel  string `json:"department_external_label"`
	EnvironmentExternalLabel string `json:"environment_external_label"`
	OwnerExternalLabel       string `json:"owner_external_label"`
	ProductExternalLabel     string `json:"product_external_label"`
	TeamExternalLabel        string `json:"team_external_label"`
}

LabelConfig is a port of type AnalyzerConfig. We need to be more thoughtful about design at some point, but this is a stop-gap measure, which is required because AnalyzerConfig is defined in package main, so it can't be imported.

func NewLabelConfig

func NewLabelConfig() *LabelConfig

NewLabelConfig creates a new LabelConfig instance with default values.

func (*LabelConfig) GetExternalAllocationName

func (lc *LabelConfig) GetExternalAllocationName(labels map[string]string, aggregateBy string) string

GetExternalAllocationName derives an external allocation name from a set of labels, given an aggregation property. If the aggregation property is, itself, a label (e.g. label:app) then this function looks for a corresponding value under "app" and returns "app=thatvalue". If the aggregation property is not a label but a Kubernetes concept (e.g. namespace) then this function first finds the "external label" configured to represent it (e.g. NamespaceExternalLabel: "kubens") and uses that label to determine an external allocation name. If no label value can be found, return an empty string.

func (*LabelConfig) Map

func (lc *LabelConfig) Map() map[string]string

Map returns the config as a basic string map, with default values if not set

func (*LabelConfig) Sanitize

func (lc *LabelConfig) Sanitize(label string) string

Sanitize returns a sanitized version of the given string, which converts all illegal characters to underscores. Illegal characters are those that Prometheus does not support; i.e. [^a-zA-Z0-9_]

type LoadBalancer

type LoadBalancer struct {
	Cost float64
	// contains filtered or unexported fields
}

LoadBalancer is an Asset representing a single load balancer in a cluster TODO: add GB of ingress processed, numForwardingRules once we start recording those to prometheus metric

func NewLoadBalancer

func NewLoadBalancer(name, cluster, providerID string, start, end time.Time, window Window) *LoadBalancer

NewLoadBalancer instantiates and returns a new LoadBalancer

func (*LoadBalancer) Add

func (lb *LoadBalancer) Add(a Asset) Asset

Add sums the Asset with the given Asset to produce a new Asset, maintaining as much relevant information as possible (i.e. type, properties, labels).

func (*LoadBalancer) Adjustment

func (lb *LoadBalancer) Adjustment() float64

Adjustment returns the Asset's cost adjustment

func (*LoadBalancer) Clone

func (lb *LoadBalancer) Clone() Asset

Clone returns a cloned instance of the given Asset

func (*LoadBalancer) End

func (lb *LoadBalancer) End() time.Time

End returns the preceise end point of the Asset within the window

func (*LoadBalancer) Equal

func (lb *LoadBalancer) Equal(a Asset) bool

Equal returns true if the tow Assets match precisely

func (*LoadBalancer) ExpandWindow

func (lb *LoadBalancer) ExpandWindow(w Window)

ExpandWindow expands the Asset's window by the given window

func (*LoadBalancer) InterfaceToLoadBalancer

func (lb *LoadBalancer) InterfaceToLoadBalancer(itf interface{}) error

Converts interface{} to LoadBalancer, carrying over relevant fields

func (*LoadBalancer) Labels

func (lb *LoadBalancer) Labels() AssetLabels

Labels returns the Asset's labels

func (*LoadBalancer) MarshalBinary

func (target *LoadBalancer) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this LoadBalancer instance into a byte array

func (*LoadBalancer) MarshalBinaryWithContext

func (target *LoadBalancer) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this LoadBalancer instance into a byte array leveraging a predefined context.

func (*LoadBalancer) MarshalJSON

func (lb *LoadBalancer) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshal

func (*LoadBalancer) Minutes

func (lb *LoadBalancer) Minutes() float64

Minutes returns the number of minutes the Asset ran within the window

func (*LoadBalancer) Properties

func (lb *LoadBalancer) Properties() *AssetProperties

Properties returns the Asset's properties

func (*LoadBalancer) SetAdjustment

func (lb *LoadBalancer) SetAdjustment(adj float64)

SetAdjustment sets the Asset's cost adjustment

func (*LoadBalancer) SetLabels

func (lb *LoadBalancer) SetLabels(labels AssetLabels)

SetLabels sets the Asset's labels

func (*LoadBalancer) SetProperties

func (lb *LoadBalancer) SetProperties(props *AssetProperties)

SetProperties sets the Asset's properties

func (*LoadBalancer) SetStartEnd

func (lb *LoadBalancer) SetStartEnd(start, end time.Time)

SetStartEnd sets the Asset's Start and End fields

func (*LoadBalancer) Start

func (lb *LoadBalancer) Start() time.Time

Start returns the preceise start point of the Asset within the window

func (*LoadBalancer) String

func (lb *LoadBalancer) String() string

String implements fmt.Stringer

func (*LoadBalancer) TotalCost

func (lb *LoadBalancer) TotalCost() float64

TotalCost returns the total cost of the Asset

func (*LoadBalancer) Type

func (lb *LoadBalancer) Type() AssetType

Type returns the AssetType of the Asset

func (*LoadBalancer) UnmarshalBinary

func (target *LoadBalancer) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the LoadBalancer type

func (*LoadBalancer) UnmarshalBinaryWithContext

func (target *LoadBalancer) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the LoadBalancer type

func (*LoadBalancer) UnmarshalJSON

func (lb *LoadBalancer) UnmarshalJSON(b []byte) error

func (*LoadBalancer) Window

func (lb *LoadBalancer) Window() Window

Window returns the window within which the Asset ran

type MemoryTotalsStore

type MemoryTotalsStore struct {
	// contains filtered or unexported fields
}

MemoryTotalsStore is an in-memory cache TotalsStore

func NewMemoryTotalsStore

func NewMemoryTotalsStore() *MemoryTotalsStore

NewMemoryTotalsStore instantiates a new MemoryTotalsStore, which is composed of four in-memory caches.

func (*MemoryTotalsStore) GetAllocationTotalsByCluster

func (mts *MemoryTotalsStore) GetAllocationTotalsByCluster(start time.Time, end time.Time) (map[string]*AllocationTotals, bool)

GetAllocationTotalsByCluster retrieves the AllocationTotals by cluster for the given start and end times.

func (*MemoryTotalsStore) GetAllocationTotalsByNode

func (mts *MemoryTotalsStore) GetAllocationTotalsByNode(start time.Time, end time.Time) (map[string]*AllocationTotals, bool)

GetAllocationTotalsByNode retrieves the AllocationTotals by node for the given start and end times.

func (*MemoryTotalsStore) GetAssetTotalsByCluster

func (mts *MemoryTotalsStore) GetAssetTotalsByCluster(start time.Time, end time.Time) (map[string]*AssetTotals, bool)

GetAssetTotalsByCluster retrieves the AssetTotals by cluster for the given start and end times.

func (*MemoryTotalsStore) GetAssetTotalsByNode

func (mts *MemoryTotalsStore) GetAssetTotalsByNode(start time.Time, end time.Time) (map[string]*AssetTotals, bool)

GetAssetTotalsByNode retrieves the AssetTotals by node for the given start and end times.

func (*MemoryTotalsStore) SetAllocationTotalsByCluster

func (mts *MemoryTotalsStore) SetAllocationTotalsByCluster(start time.Time, end time.Time, arts map[string]*AllocationTotals)

SetAllocationTotalsByCluster set the per-cluster AllocationTotals to the given values for the given start and end times.

func (*MemoryTotalsStore) SetAllocationTotalsByNode

func (mts *MemoryTotalsStore) SetAllocationTotalsByNode(start time.Time, end time.Time, arts map[string]*AllocationTotals)

SetAllocationTotalsByNode set the per-node AllocationTotals to the given values for the given start and end times.

func (*MemoryTotalsStore) SetAssetTotalsByCluster

func (mts *MemoryTotalsStore) SetAssetTotalsByCluster(start time.Time, end time.Time, arts map[string]*AssetTotals)

SetAssetTotalsByCluster set the per-cluster AssetTotals to the given values for the given start and end times.

func (*MemoryTotalsStore) SetAssetTotalsByNode

func (mts *MemoryTotalsStore) SetAssetTotalsByNode(start time.Time, end time.Time, arts map[string]*AssetTotals)

SetAssetTotalsByNode set the per-node AssetTotals to the given values for the given start and end times.

type Network

type Network struct {
	Cost float64
	// contains filtered or unexported fields
}

Network is an Asset representing a single node's network costs

func NewNetwork

func NewNetwork(name, cluster, providerID string, start, end time.Time, window Window) *Network

NewNetwork creates and returns a new Network Asset

func (*Network) Add

func (n *Network) Add(a Asset) Asset

Add sums the Asset with the given Asset to produce a new Asset, maintaining as much relevant information as possible (i.e. type, properties, labels).

func (*Network) Adjustment

func (n *Network) Adjustment() float64

Adjustment returns the Asset's cost adjustment

func (*Network) Clone

func (n *Network) Clone() Asset

Clone returns a deep copy of the given Network

func (*Network) End

func (n *Network) End() time.Time

End returns the precise end time of the Asset within the window

func (*Network) Equal

func (n *Network) Equal(a Asset) bool

Equal returns true if the tow Assets match exactly

func (*Network) ExpandWindow

func (n *Network) ExpandWindow(window Window)

ExpandWindow expands the Asset's window by the given window

func (*Network) InterfaceToNetwork

func (n *Network) InterfaceToNetwork(itf interface{}) error

Converts interface{} to Network, carrying over relevant fields

func (*Network) Labels

func (n *Network) Labels() AssetLabels

Labels returns the Asset's labels

func (*Network) MarshalBinary

func (target *Network) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this Network instance into a byte array

func (*Network) MarshalBinaryWithContext

func (target *Network) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this Network instance into a byte array leveraging a predefined context.

func (*Network) MarshalJSON

func (n *Network) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshal interface

func (*Network) Minutes

func (n *Network) Minutes() float64

Minutes returns the number of minutes the Asset ran within the window

func (*Network) Properties

func (n *Network) Properties() *AssetProperties

Properties returns the Asset's properties

func (*Network) SetAdjustment

func (n *Network) SetAdjustment(adj float64)

SetAdjustment sets the Asset's cost adjustment

func (*Network) SetLabels

func (n *Network) SetLabels(labels AssetLabels)

SetLabels sets the Asset's labels

func (*Network) SetProperties

func (n *Network) SetProperties(props *AssetProperties)

SetProperties sets the Asset's properties

func (*Network) SetStartEnd

func (n *Network) SetStartEnd(start, end time.Time)

SetStartEnd sets the Asset's Start and End fields

func (*Network) Start

func (n *Network) Start() time.Time

Start returns the precise start time of the Asset within the window

func (*Network) String

func (n *Network) String() string

String implements fmt.Stringer

func (*Network) TotalCost

func (n *Network) TotalCost() float64

TotalCost returns the Asset's total cost

func (*Network) Type

func (n *Network) Type() AssetType

Type returns the AssetType of the Asset

func (*Network) UnmarshalBinary

func (target *Network) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the Network type

func (*Network) UnmarshalBinaryWithContext

func (target *Network) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the Network type

func (*Network) UnmarshalJSON

func (n *Network) UnmarshalJSON(b []byte) error

func (*Network) Window

func (n *Network) Window() Window

Window returns the window within which the Asset ran

type Node

type Node struct {
	NodeType     string
	CPUCoreHours float64
	RAMByteHours float64
	GPUHours     float64
	CPUBreakdown *Breakdown
	RAMBreakdown *Breakdown
	CPUCost      float64
	GPUCost      float64
	GPUCount     float64
	RAMCost      float64
	Discount     float64
	Preemptible  float64
	// contains filtered or unexported fields
}

Node is an Asset representing a single node in a cluster

func NewNode

func NewNode(name, cluster, providerID string, start, end time.Time, window Window) *Node

NewNode creates and returns a new Node Asset

func (*Node) Add

func (n *Node) Add(a Asset) Asset

Add sums the Asset with the given Asset to produce a new Asset, maintaining as much relevant information as possible (i.e. type, properties, labels).

func (*Node) Adjustment

func (n *Node) Adjustment() float64

Adjustment returns the Asset's cost adjustment

func (*Node) CPUCores

func (n *Node) CPUCores() float64

CPUCores returns the number of cores belonging to the node. This could be fractional because it's the number of core*hours divided by the number of hours running; e.g. the sum of a 4-core node running for the first 10 hours and a 3-core node running for the last 20 hours of the same 24-hour window would produce:

(4*10 + 3*20) / 24 = 4.167 cores

However, any number of cores running for the full span of a window will report the actual number of cores of the static node; e.g. the above scenario for one entire 24-hour window:

(4*24 + 3*24) / 24 = (4 + 3) = 7 cores

func (*Node) Clone

func (n *Node) Clone() Asset

Clone returns a deep copy of the given Node

func (*Node) End

func (n *Node) End() time.Time

End returns the precise end time of the Asset within the window

func (*Node) Equal

func (n *Node) Equal(a Asset) bool

Equal returns true if the tow Assets match exactly

func (*Node) ExpandWindow

func (n *Node) ExpandWindow(window Window)

ExpandWindow expands the Asset's window by the given window

func (*Node) GPUs

func (n *Node) GPUs() float64

GPUs returns the amount of GPUs belonging to the node. This could be fractional because it's the number of gpu*hours divided by the number of hours running; e.g. the sum of a 2 gpu node running for the first 10 hours and a 1 gpu node running for the last 20 hours of the same 24-hour window would produce:

(2*10 + 1*20) / 24 = 1.667 GPUs

However, any number of GPUs running for the full span of a window will report the actual number of GPUs of the static node; e.g. the above scenario for one entire 24-hour window:

(2*24 + 1*24) / 24 = (2 + 1) = 3 GPUs

func (*Node) InterfaceToNode

func (n *Node) InterfaceToNode(itf interface{}) error

Converts interface{} to Node, carrying over relevant fields

func (*Node) IsPreemptible

func (n *Node) IsPreemptible() bool

IsPreemptible returns true if the node is 100% preemptible. It's possible to be "partially preemptible" by adding a preemptible node with a non-preemptible node.

func (*Node) Labels

func (n *Node) Labels() AssetLabels

Labels returns the Asset's labels

func (*Node) MarshalBinary

func (target *Node) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this Node instance into a byte array

func (*Node) MarshalBinaryWithContext

func (target *Node) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this Node instance into a byte array leveraging a predefined context.

func (*Node) MarshalJSON

func (n *Node) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshal interface

func (*Node) Minutes

func (n *Node) Minutes() float64

Minutes returns the number of minutes the Asset ran within the window

func (*Node) Properties

func (n *Node) Properties() *AssetProperties

Properties returns the Asset's properties

func (*Node) RAMBytes

func (n *Node) RAMBytes() float64

RAMBytes returns the amount of RAM belonging to the node. This could be fractional because it's the number of byte*hours divided by the number of hours running; e.g. the sum of a 12GiB-RAM node running for the first 10 hours and a 16GiB-RAM node running for the last 20 hours of the same 24-hour window would produce:

(12*10 + 16*20) / 24 = 18.333GiB RAM

However, any number of bytes running for the full span of a window will report the actual number of bytes of the static node; e.g. the above scenario for one entire 24-hour window:

(12*24 + 16*24) / 24 = (12 + 16) = 28GiB RAM

func (*Node) SetAdjustment

func (n *Node) SetAdjustment(adj float64)

SetAdjustment sets the Asset's cost adjustment

func (*Node) SetLabels

func (n *Node) SetLabels(labels AssetLabels)

SetLabels sets the Asset's labels

func (*Node) SetProperties

func (n *Node) SetProperties(props *AssetProperties)

SetProperties sets the Asset's properties

func (*Node) SetStartEnd

func (n *Node) SetStartEnd(start, end time.Time)

SetStartEnd sets the Asset's Start and End fields

func (*Node) Start

func (n *Node) Start() time.Time

Start returns the precise start time of the Asset within the window

func (*Node) String

func (n *Node) String() string

String implements fmt.Stringer

func (*Node) TotalCost

func (n *Node) TotalCost() float64

TotalCost returns the Asset's total cost

func (*Node) Type

func (n *Node) Type() AssetType

Type returns the AssetType of the Asset

func (*Node) UnmarshalBinary

func (target *Node) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the Node type

func (*Node) UnmarshalBinaryWithContext

func (target *Node) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the Node type

func (*Node) UnmarshalJSON

func (n *Node) UnmarshalJSON(b []byte) error

func (*Node) Window

func (n *Node) Window() Window

Window returns the window within which the Asset ran

type PVAllocation

type PVAllocation struct {
	ByteHours float64 `json:"byteHours"`
	Cost      float64 `json:"cost"`
}

PVAllocation contains the byte hour usage and cost of an Allocation for a single PV

func (*PVAllocation) MarshalBinary

func (target *PVAllocation) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this PVAllocation instance into a byte array

func (*PVAllocation) MarshalBinaryWithContext

func (target *PVAllocation) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this PVAllocation instance into a byte array leveraging a predefined context.

func (*PVAllocation) UnmarshalBinary

func (target *PVAllocation) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the PVAllocation type

func (*PVAllocation) UnmarshalBinaryWithContext

func (target *PVAllocation) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the PVAllocation type

type PVAllocations

type PVAllocations map[PVKey]*PVAllocation

PVAllocations is a map of Disk Asset Identifiers to the usage of them by an Allocation as recorded in a PVAllocation

func (*PVAllocations) Add

Add adds contents of that to the calling PVAllocations

func (*PVAllocations) Clone

func (pv *PVAllocations) Clone() PVAllocations

Clone creates a deep copy of a PVAllocations

type PVKey

type PVKey struct {
	Cluster string `json:"cluster"`
	Name    string `json:"name"`
}

PVKey for identifying Disk type assets

func (*PVKey) MarshalBinary

func (target *PVKey) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this PVKey instance into a byte array

func (*PVKey) MarshalBinaryWithContext

func (target *PVKey) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this PVKey instance into a byte array leveraging a predefined context.

func (*PVKey) UnmarshalBinary

func (target *PVKey) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the PVKey type

func (*PVKey) UnmarshalBinaryWithContext

func (target *PVKey) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the PVKey type

type Pair

type Pair[T any, U any] struct {
	First  T
	Second U
}

Pair is a generic struct containing a pair of instances, one of each type similar to std::pair

func NewPair

func NewPair[T any, U any](first T, second U) Pair[T, U]

Creates a new pair struct containing the provided parameters. This is useful for creating types capable of representing common paired types (result, error), (result, bool), etc...

type Querier

Querier is an aggregate interface which has the ability to query each Kubecost store type

type RawAllocationOnlyData

type RawAllocationOnlyData struct {
	CPUCoreUsageMax  float64 `json:"cpuCoreUsageMax"`
	RAMBytesUsageMax float64 `json:"ramByteUsageMax"`
}

RawAllocationOnlyData is information that only belong in "raw" Allocations, those which have not undergone aggregation, accumulation, or any other form of combination to produce a new Allocation from other Allocations.

Max usage data belongs here because computing the overall maximum from two or more Allocations is a non-trivial operation that cannot be defined without maintaining a large amount of state. Consider the following example: _______________________________________________

A1 Using 3 CPU ---- ----- ------ A2 Using 2 CPU ---- ----- ---- A3 Using 1 CPU --- -- _______________________________________________

Time ---->

The logical maximum CPU usage is 5, but this cannot be calculated iteratively, which is how we calculate aggregations and accumulations of Allocations currently. This becomes a problem I could call "maximum sum of overlapping intervals" and is essentially a variant of an interval scheduling algorithm.

If we had types to differentiate between regular Allocations and AggregatedAllocations then this type would be unnecessary and its fields would go into the regular Allocation and not in the AggregatedAllocation.

func (*RawAllocationOnlyData) Clone

Clone returns a deep copy of the given RawAllocationOnlyData

func (*RawAllocationOnlyData) MarshalBinary

func (target *RawAllocationOnlyData) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this RawAllocationOnlyData instance into a byte array

func (*RawAllocationOnlyData) MarshalBinaryWithContext

func (target *RawAllocationOnlyData) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this RawAllocationOnlyData instance into a byte array leveraging a predefined context.

func (*RawAllocationOnlyData) UnmarshalBinary

func (target *RawAllocationOnlyData) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the RawAllocationOnlyData type

func (*RawAllocationOnlyData) UnmarshalBinaryWithContext

func (target *RawAllocationOnlyData) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the RawAllocationOnlyData type

type ReconciliationStatus

type ReconciliationStatus struct {
	Coverage    Window    `json:"coverage"`
	LastRun     time.Time `json:"lastRun"`
	NextRun     time.Time `json:"nextRun"`
	Progress    float64   `json:"progress"`
	RefreshRate string    `json:"refreshRate"`
	Resolution  string    `json:"resolution"`
	StartTime   time.Time `json:"startTime"`
}

ReconciliationStatus describes Reconciliation metadata of a CloudStore

type SetRange added in v1.95.0

type SetRange[T ETLSet] struct {
	// contains filtered or unexported fields
}

SetRange is a generic implementation of the SetRanges that act as containers. It covers the basic functionality that is shared by the basic types but is meant to be extended by each implementation.

func (*SetRange[T]) Append added in v1.95.0

func (r *SetRange[T]) Append(that T)

Append attaches the given ETLSet to the end of the sets slice. currently does not check that the window is correct.

func (*SetRange[T]) Each added in v1.95.0

func (r *SetRange[T]) Each(f func(int, T))

Each invokes the given function for each ETLSet in the SetRange

func (*SetRange[T]) Get added in v1.95.0

func (r *SetRange[T]) Get(i int) (T, error)

Get retrieves the given index from the sets slice

func (*SetRange[T]) IsEmpty added in v1.95.0

func (r *SetRange[T]) IsEmpty() bool

IsEmpty returns false if SetRange contains a single ETLSet that is not empty

func (*SetRange[T]) Length added in v1.95.0

func (r *SetRange[T]) Length() int

Length returns the length of the sets slice

func (*SetRange[T]) MarshalJSON added in v1.95.0

func (r *SetRange[T]) MarshalJSON() ([]byte, error)

MarshalJSON converts SetRange to JSON

type SharedAsset

type SharedAsset struct {
	Cost float64
	// contains filtered or unexported fields
}

SharedAsset is an Asset representing a shared cost

func NewSharedAsset

func NewSharedAsset(name string, window Window) *SharedAsset

NewSharedAsset creates and returns a new SharedAsset

func (*SharedAsset) Add

func (sa *SharedAsset) Add(a Asset) Asset

Add sums the Asset with the given Asset to produce a new Asset, maintaining as much relevant information as possible (i.e. type, properties, labels).

func (*SharedAsset) Adjustment

func (sa *SharedAsset) Adjustment() float64

Adjustment is not relevant to SharedAsset, but required to implement Asset

func (*SharedAsset) Clone

func (sa *SharedAsset) Clone() Asset

Clone returns a deep copy of the given SharedAsset

func (*SharedAsset) End

func (sa *SharedAsset) End() time.Time

End returns the end time of the Asset

func (*SharedAsset) Equal

func (sa *SharedAsset) Equal(a Asset) bool

Equal returns true if the two Assets are exact matches

func (*SharedAsset) ExpandWindow

func (sa *SharedAsset) ExpandWindow(w Window)

ExpandWindow expands the Asset's window

func (*SharedAsset) InterfaceToSharedAsset

func (sa *SharedAsset) InterfaceToSharedAsset(itf interface{}) error

Converts interface{} to SharedAsset, carrying over relevant fields

func (*SharedAsset) Labels

func (sa *SharedAsset) Labels() AssetLabels

Labels returns the Asset's labels

func (*SharedAsset) MarshalBinary

func (target *SharedAsset) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this SharedAsset instance into a byte array

func (*SharedAsset) MarshalBinaryWithContext

func (target *SharedAsset) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this SharedAsset instance into a byte array leveraging a predefined context.

func (*SharedAsset) MarshalJSON

func (sa *SharedAsset) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (*SharedAsset) Minutes

func (sa *SharedAsset) Minutes() float64

Minutes returns the number of minutes the SharedAsset ran within the window

func (*SharedAsset) Properties

func (sa *SharedAsset) Properties() *AssetProperties

Properties returns the Asset's properties

func (*SharedAsset) SetAdjustment

func (sa *SharedAsset) SetAdjustment(float64)

SetAdjustment is not relevant to SharedAsset, but required to implement Asset

func (*SharedAsset) SetLabels

func (sa *SharedAsset) SetLabels(labels AssetLabels)

SetLabels sets the Asset's labels

func (*SharedAsset) SetProperties

func (sa *SharedAsset) SetProperties(props *AssetProperties)

SetProperties sets the Asset's properties

func (*SharedAsset) SetStartEnd

func (sa *SharedAsset) SetStartEnd(start, end time.Time)

SetStartEnd sets the Asset's Start and End fields (not applicable here)

func (*SharedAsset) Start

func (sa *SharedAsset) Start() time.Time

Start returns the start time of the Asset

func (*SharedAsset) String

func (sa *SharedAsset) String() string

String implements fmt.Stringer

func (*SharedAsset) TotalCost

func (sa *SharedAsset) TotalCost() float64

TotalCost returns the Asset's total cost

func (*SharedAsset) Type

func (sa *SharedAsset) Type() AssetType

Type returns the AssetType of the Asset

func (*SharedAsset) UnmarshalBinary

func (target *SharedAsset) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the SharedAsset type

func (*SharedAsset) UnmarshalBinaryWithContext

func (target *SharedAsset) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the SharedAsset type

func (*SharedAsset) UnmarshalJSON

func (sa *SharedAsset) UnmarshalJSON(b []byte) error

func (*SharedAsset) Window

func (sa *SharedAsset) Window() Window

Window returns the window within the SharedAsset ran

type StringTable

type StringTable struct {
	// contains filtered or unexported fields
}

StringTable maps strings to specific indices for encoding

func NewStringTable

func NewStringTable(contents ...string) *StringTable

NewStringTable Creates a new StringTable instance with provided contents

func (*StringTable) AddOrGet

func (st *StringTable) AddOrGet(s string) int

AddOrGet atomically retrieves a string entry's index if it exist. Otherwise, it will add the entry and return the index.

func (*StringTable) ToBytes

func (st *StringTable) ToBytes() []byte

ToBytes Converts the contents to a binary encoded representation

func (*StringTable) ToSlice

func (st *StringTable) ToSlice() []string

ToSlice Converts the contents to a string array for encoding.

type SummaryAllocation

type SummaryAllocation struct {
	Name                   string                `json:"name"`
	Properties             *AllocationProperties `json:"-"`
	Start                  time.Time             `json:"start"`
	End                    time.Time             `json:"end"`
	CPUCoreRequestAverage  float64               `json:"cpuCoreRequestAverage"`
	CPUCoreUsageAverage    float64               `json:"cpuCoreUsageAverage"`
	CPUCost                float64               `json:"cpuCost"`
	GPUCost                float64               `json:"gpuCost"`
	NetworkCost            float64               `json:"networkCost"`
	LoadBalancerCost       float64               `json:"loadBalancerCost"`
	PVCost                 float64               `json:"pvCost"`
	RAMBytesRequestAverage float64               `json:"ramByteRequestAverage"`
	RAMBytesUsageAverage   float64               `json:"ramByteUsageAverage"`
	RAMCost                float64               `json:"ramCost"`
	SharedCost             float64               `json:"sharedCost"`
	ExternalCost           float64               `json:"externalCost"`
	Share                  bool                  `json:"-"`
}

SummaryAllocation summarizes an Allocation, keeping only fields necessary for providing a high-level view of identifying the Allocation over a period of time (Start, End) over which it ran, and inspecting the associated per- resource costs (subtotaled with adjustments), total cost, and efficiency.

SummaryAllocation does not have a concept of Window (i.e. the time period within which it is defined, as opposed to the Start and End times). That context must be provided by a SummaryAllocationSet.

func NewSummaryAllocation

func NewSummaryAllocation(alloc *Allocation, reconcile, reconcileNetwork bool) *SummaryAllocation

NewSummaryAllocation converts an Allocation to a SummaryAllocation by dropping unnecessary fields and consolidating others (e.g. adjustments). Reconciliation happens here because that process is synonymous with the consolidation of adjustment fields.

func (*SummaryAllocation) Add

func (sa *SummaryAllocation) Add(that *SummaryAllocation) error

Add sums two SummaryAllocations, adding the given SummaryAllocation to the receiving one, thus mutating the receiver. For performance reasons, it simply drops Properties, so a SummaryAllocation can only be Added once.

func (*SummaryAllocation) CPUEfficiency

func (sa *SummaryAllocation) CPUEfficiency() float64

CPUEfficiency is the ratio of usage to request. If there is no request and no usage or cost, then efficiency is zero. If there is no request, but there is usage or cost, then efficiency is 100%.

func (*SummaryAllocation) Clone

func (sa *SummaryAllocation) Clone() *SummaryAllocation

Clone copies the SummaryAllocation and returns the copy

func (*SummaryAllocation) IsExternal

func (sa *SummaryAllocation) IsExternal() bool

IsExternal is true if the given SummaryAllocation represents external costs.

func (*SummaryAllocation) IsIdle

func (sa *SummaryAllocation) IsIdle() bool

IsIdle is true if the given SummaryAllocation represents idle costs.

func (*SummaryAllocation) IsUnallocated

func (sa *SummaryAllocation) IsUnallocated() bool

IsUnallocated is true if the given SummaryAllocation represents unallocated costs.

func (*SummaryAllocation) IsUnmounted

func (sa *SummaryAllocation) IsUnmounted() bool

IsUnmounted is true if the given SummaryAllocation represents unmounted volume costs.

func (*SummaryAllocation) Minutes

func (sa *SummaryAllocation) Minutes() float64

Minutes returns the number of minutes the SummaryAllocation represents, as defined by the difference between the end and start times.

func (*SummaryAllocation) RAMEfficiency

func (sa *SummaryAllocation) RAMEfficiency() float64

RAMEfficiency is the ratio of usage to request. If there is no request and no usage or cost, then efficiency is zero. If there is no request, but there is usage or cost, then efficiency is 100%.

func (*SummaryAllocation) TotalCost

func (sa *SummaryAllocation) TotalCost() float64

TotalCost is the total cost of the SummaryAllocation

func (*SummaryAllocation) TotalEfficiency

func (sa *SummaryAllocation) TotalEfficiency() float64

TotalEfficiency is the cost-weighted average of CPU and RAM efficiency. If there is no cost at all, then efficiency is zero.

type SummaryAllocationQuerier

type SummaryAllocationQuerier interface {
	QuerySummaryAllocation(start, end time.Time, opts *AllocationQueryOptions) (*SummaryAllocationSetRange, error)
}

SummaryAllocationQuerier interface defining api for requesting SummaryAllocation data

type SummaryAllocationSet

type SummaryAllocationSet struct {
	sync.RWMutex

	SummaryAllocations map[string]*SummaryAllocation `json:"allocations"`
	Window             Window                        `json:"window"`
	// contains filtered or unexported fields
}

SummaryAllocationSet stores a set of SummaryAllocations, each with a unique name, that share a window. An AllocationSet is mutable, so treat it like a threadsafe map.

func NewSummaryAllocationSet

func NewSummaryAllocationSet(as *AllocationSet, ffs, kfs []AllocationMatchFunc, reconcile, reconcileNetwork bool) *SummaryAllocationSet

NewSummaryAllocationSet converts an AllocationSet to a SummaryAllocationSet. Filter functions, keep functions, and reconciliation parameters are required for unfortunate reasons to do with performance and legacy order-of- operations details, as well as the fact that reconciliation has been pushed down to the conversion step between Allocation and SummaryAllocation.

func (*SummaryAllocationSet) Add

Add sums two SummaryAllocationSets, which Adds all SummaryAllocations in the given SummaryAllocationSet to thier counterparts in the receiving set. Add also expands the Window to include both constituent Windows, in the case that Add is being used from accumulating (as opposed to aggregating). For performance reasons, the function may return either a new set, or an unmodified original, so it should not be assumed that the original sets are safeuly usable after calling Add.

func (*SummaryAllocationSet) AggregateBy

func (sas *SummaryAllocationSet) AggregateBy(aggregateBy []string, options *AllocationAggregationOptions) error

AggregateBy aggregates the Allocations in the given AllocationSet by the given AllocationProperty. This will only be legal if the AllocationSet is divisible by the given AllocationProperty; e.g. Containers can be divided by Namespace, but not vice-a-versa.

func (*SummaryAllocationSet) Clone

Clone creates a deep copy of the SummaryAllocationSet

func (*SummaryAllocationSet) Delete

func (sas *SummaryAllocationSet) Delete(name string)

Delete removes the allocation with the given name from the set

func (*SummaryAllocationSet) Each

func (sas *SummaryAllocationSet) Each(f func(string, *SummaryAllocation))

Each invokes the given function for each SummaryAllocation in the set

func (*SummaryAllocationSet) Insert

func (sas *SummaryAllocationSet) Insert(sa *SummaryAllocation) error

Insert aggregates the current entry in the SummaryAllocationSet by the given Allocation, but only if the Allocation is valid, i.e. matches the SummaryAllocationSet's window. If there is no existing entry, one is created. Nil error response indicates success.

func (*SummaryAllocationSet) TotalCost

func (sas *SummaryAllocationSet) TotalCost() float64

type SummaryAllocationSetRange

type SummaryAllocationSetRange struct {
	sync.RWMutex
	Step                  time.Duration           `json:"step"`
	SummaryAllocationSets []*SummaryAllocationSet `json:"sets"`
	Window                Window                  `json:"window"`
	Message               string                  `json:"-"`
}

SummaryAllocationSetRange is a thread-safe slice of SummaryAllocationSets.

func NewSummaryAllocationSetRange

func NewSummaryAllocationSetRange(sass ...*SummaryAllocationSet) *SummaryAllocationSetRange

NewSummaryAllocationSetRange instantiates a new range composed of the given SummaryAllocationSets in the order provided. The expectations about the SummaryAllocationSets are as follows: - window durations are all equal - sets are consecutive (i.e. chronologically sorted) - there are no gaps between sets - sets do not have overlapping windows

func (*SummaryAllocationSetRange) Accumulate

func (sasr *SummaryAllocationSetRange) Accumulate() (*SummaryAllocationSet, error)

Accumulate sums each AllocationSet in the given range, returning a single cumulative AllocationSet for the entire range.

func (*SummaryAllocationSetRange) AggregateBy

func (sasr *SummaryAllocationSetRange) AggregateBy(aggregateBy []string, options *AllocationAggregationOptions) error

AggregateBy aggregates each AllocationSet in the range by the given properties and options.

func (*SummaryAllocationSetRange) Append

Append appends the given AllocationSet to the end of the range. It does not validate whether or not that violates window continuity.

func (*SummaryAllocationSetRange) Each

func (sasr *SummaryAllocationSetRange) Each(f func(int, *SummaryAllocationSet))

Each invokes the given function for each AllocationSet in the range

func (*SummaryAllocationSetRange) InsertExternalAllocations

func (sasr *SummaryAllocationSetRange) InsertExternalAllocations(that *AllocationSetRange) error

InsertExternalAllocations takes all allocations in the given AllocationSetRange (they should all be considered "external") and inserts them into the receiving SummaryAllocationSetRange. TODO:CLEANUP replace this with a better idea (or get rid of external allocations, as such, altogether)

func (*SummaryAllocationSetRange) Print

func (sasr *SummaryAllocationSetRange) Print(verbose bool)

TODO remove after testing

func (*SummaryAllocationSetRange) TotalCost

func (sasr *SummaryAllocationSetRange) TotalCost() float64

type TotalAudit added in v1.95.0

type TotalAudit struct {
	Status         AuditStatus
	Description    string
	LastRun        time.Time
	TotalByNode    map[string]*AuditFloatResult
	TotalByCluster map[string]*AuditFloatResult
	MissingValues  []*AuditMissingValue
}

TotalAudit records the differences between a total store and the totaled results of the store that it is based on keyed by cluster and node names

func (*TotalAudit) Clone added in v1.95.0

func (ta *TotalAudit) Clone() *TotalAudit

Clone returns a deep copy of the caller

func (*TotalAudit) MarshalBinary added in v1.95.0

func (target *TotalAudit) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this TotalAudit instance into a byte array

func (*TotalAudit) MarshalBinaryWithContext added in v1.95.0

func (target *TotalAudit) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this TotalAudit instance into a byte array leveraging a predefined context.

func (*TotalAudit) UnmarshalBinary added in v1.95.0

func (target *TotalAudit) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the TotalAudit type

func (*TotalAudit) UnmarshalBinaryWithContext added in v1.95.0

func (target *TotalAudit) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the TotalAudit type

type TotalsStore

type TotalsStore interface {
	AllocationTotalsStore
	AssetTotalsStore
}

TotalsStore acts as both an AllocationTotalsStore and an AssetTotalsStore.

type Window

type Window struct {
	// contains filtered or unexported fields
}

Window defines a period of time with a start and an end. If either start or end are nil it indicates an open time period.

func NewClosedWindow

func NewClosedWindow(start, end time.Time) Window

NewClosedWindow creates and returns a new Window instance from the given times, which cannot be nil, so they are value types.

func NewWindow

func NewWindow(start, end *time.Time) Window

NewWindow creates and returns a new Window instance from the given times

func ParseWindowUTC

func ParseWindowUTC(window string) (Window, error)

ParseWindowUTC attempts to parse the given string into a valid Window. It accepts several formats, returning an error if the given string does not match one of the following: - named intervals: "today", "yesterday", "week", "month", "lastweek", "lastmonth" - durations: "24h", "7d", etc. - date ranges: "2020-04-01T00:00:00Z,2020-04-03T00:00:00Z", etc. - timestamp ranges: "1586822400,1586908800", etc.

func ParseWindowWithOffset

func ParseWindowWithOffset(window string, offset time.Duration) (Window, error)

ParseWindowWithOffset parses the given window string within the context of the timezone defined by the UTC offset.

func ParseWindowWithOffsetString

func ParseWindowWithOffsetString(window string, offset string) (Window, error)

ParseWindowWithOffsetString parses the given window string within the context of the timezone defined by the UTC offset string of format -07:00, +01:30, etc.

func (Window) ApproximatelyEqual

func (w Window) ApproximatelyEqual(that Window, threshold time.Duration) bool

ApproximatelyEqual returns true if the start and end times of the two windows, respectively, are within the given threshold of each other.

func (Window) Clone

func (w Window) Clone() Window

func (Window) Contains

func (w Window) Contains(t time.Time) bool

func (Window) ContainsWindow

func (w Window) ContainsWindow(that Window) bool

func (Window) Contract

func (w Window) Contract(that Window) Window

func (Window) ContractEnd

func (w Window) ContractEnd(end time.Time) Window

func (Window) ContractStart

func (w Window) ContractStart(start time.Time) Window

func (Window) Duration

func (w Window) Duration() time.Duration

func (Window) DurationOffset

func (w Window) DurationOffset() (time.Duration, time.Duration, error)

DurationOffset returns durations representing the duration and offset of the given window

func (Window) DurationOffsetForPrometheus

func (w Window) DurationOffsetForPrometheus() (string, string, error)

DurationOffsetForPrometheus returns strings representing durations for the duration and offset of the given window, factoring in the Thanos offset if necessary. Whereas duration is a simple duration string (e.g. "1d"), the offset includes the word "offset" (e.g. " offset 2d") so that the values returned can be used directly in the formatting string "some_metric[%s]%s" to generate the query "some_metric[1d] offset 2d".

func (Window) DurationOffsetStrings

func (w Window) DurationOffsetStrings() (string, string)

DurationOffsetStrings returns formatted, Prometheus-compatible strings representing the duration and offset of the window in terms of days, hours, minutes, or seconds; e.g. ("7d", "1441m", "30m", "1s", "")

func (Window) End

func (w Window) End() *time.Time

func (Window) Equal

func (w Window) Equal(that Window) bool

func (Window) Expand

func (w Window) Expand(that Window) Window

func (Window) ExpandEnd

func (w Window) ExpandEnd(end time.Time) Window

func (Window) ExpandStart

func (w Window) ExpandStart(start time.Time) Window

func (Window) HasDuration added in v1.95.0

func (w Window) HasDuration() bool

HasDuration a Window has duration if neither start and end are not nil and not equal

func (Window) Hours

func (w Window) Hours() float64

func (Window) IsEmpty

func (w Window) IsEmpty() bool

IsEmpty a Window is empty if it does not have a start and an end

func (Window) IsNegative

func (w Window) IsNegative() bool

IsNegative a Window is negative if start and end are not null and end is before start

func (Window) IsOpen

func (w Window) IsOpen() bool

IsOpen a Window is open if it has a nil start or end

func (*Window) MarshalBinary

func (target *Window) MarshalBinary() (data []byte, err error)

MarshalBinary serializes the internal properties of this Window instance into a byte array

func (*Window) MarshalBinaryWithContext

func (target *Window) MarshalBinaryWithContext(ctx *EncodingContext) (err error)

MarshalBinaryWithContext serializes the internal properties of this Window instance into a byte array leveraging a predefined context.

func (Window) MarshalJSON

func (w Window) MarshalJSON() ([]byte, error)

TODO:CLEANUP make this unmarshalable (make Start and End public)

func (Window) Minutes

func (w Window) Minutes() float64

func (Window) Set

func (w Window) Set(start, end *time.Time)

func (Window) Shift

func (w Window) Shift(dur time.Duration) Window

Shift adds the given duration to both the start and end times of the window

func (Window) Start

func (w Window) Start() *time.Time

func (Window) String

func (w Window) String() string

func (*Window) UnmarshalBinary

func (target *Window) UnmarshalBinary(data []byte) error

UnmarshalBinary uses the data passed byte array to set all the internal properties of the Window type

func (*Window) UnmarshalBinaryWithContext

func (target *Window) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)

UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the Window type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL