Documentation
¶
Index ¶
- Constants
- func ComputeAllocationTotals(as *AllocationSet, prop string) map[string]*AllocationTotals
- func ComputeAssetTotals(as *AssetSet, byAsset bool) map[string]*AssetTotals
- func ComputeIdleCoefficients(shareSplit, key string, cpuCost, gpuCost, ramCost float64, ...) (float64, float64, float64)
- func ComputePercentages(toInsert *ProportionalAssetResourceCost)
- func DiffAsset(before, after *AssetSet, ratioCostChange float64) (map[string]Diff[Asset], error)
- func GetAssetKey(a Asset, aggregateBy []string) (string, error)
- func GetNodePoolName(provider string, labels map[string]string) string
- func NewAllocationAliasPass(config LabelConfig) transform.CompilerPass
- func NewAllocationMatchCompiler(labelConfig *LabelConfig) *matcher.MatchCompiler[*Allocation]
- func NewAssetMatchCompiler() *matcher.MatchCompiler[Asset]
- func NewCloudCostMatchCompiler() *matcher.MatchCompiler[*CloudCost]
- func ParseProperty(text string) (string, error)
- func ParseProvider(str string) string
- func QueryAllocationAsync(allocationQuerier AllocationQuerier, start, end time.Time, ...) (chan *AllocationSetRange, chan error)
- func QueryAssetAsync(assetQuerier AssetQuerier, start, end time.Time, opts *AssetQueryOptions) (chan *AssetSetRange, chan error)
- func QueryCloudUsageAsync(cloudUsageQuerier CloudUsageQuerier, start, end time.Time, ...) (chan *CloudUsageSetRange, chan error)
- func QuerySummaryAllocationAsync(summaryAllocationQuerier SummaryAllocationQuerier, start, end time.Time, ...) (chan *SummaryAllocationSetRange, chan error)
- func RoundBack(t time.Time, resolution time.Duration) time.Time
- func RoundForward(t time.Time, resolution time.Duration) time.Time
- type AccumulateOption
- type Allocation
- func (a *Allocation) Add(that *Allocation) (*Allocation, error)
- func (a *Allocation) CPUCores() float64
- func (a *Allocation) CPUEfficiency() float64
- func (a *Allocation) CPUTotalCost() float64
- func (a *Allocation) Clone() *Allocation
- func (a *Allocation) Equal(that *Allocation) bool
- func (a *Allocation) GPUTotalCost() float64
- func (a *Allocation) GPUs() float64
- func (a *Allocation) GetWindow() Window
- func (a *Allocation) IsAggregated() bool
- func (a *Allocation) IsExternal() bool
- func (a *Allocation) IsIdle() bool
- func (a *Allocation) IsUnallocated() bool
- func (a *Allocation) IsUnmounted() bool
- func (a *Allocation) LBTotalCost() float64
- func (a *Allocation) LoadBalancerTotalCost() float64
- func (target *Allocation) MarshalBinary() (data []byte, err error)
- func (target *Allocation) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (a *Allocation) MarshalJSON() ([]byte, error)
- func (a *Allocation) Minutes() float64
- func (a *Allocation) NetworkTotalCost() float64
- func (a *Allocation) PVByteHours() float64
- func (a *Allocation) PVBytes() float64
- func (a *Allocation) PVCost() float64
- func (a *Allocation) PVTotalCost() float64
- func (a *Allocation) RAMBytes() float64
- func (a *Allocation) RAMEfficiency() float64
- func (a *Allocation) RAMTotalCost() float64
- func (a *Allocation) ResetAdjustments()
- func (a *Allocation) Resolution() time.Duration
- func (a *Allocation) SanitizeNaN()
- func (a *Allocation) SetUnmountedPVCost() float64
- func (a *Allocation) Share(that *Allocation) (*Allocation, error)
- func (a *Allocation) SharedTotalCost() float64
- func (a *Allocation) String() string
- func (a *Allocation) StringMapProperty(property string) (map[string]string, error)
- func (a *Allocation) StringProperty(property string) (string, error)
- func (a *Allocation) StringSliceProperty(property string) ([]string, error)
- func (a *Allocation) TotalCost() float64
- func (a *Allocation) TotalEfficiency() float64
- func (target *Allocation) UnmarshalBinary(data []byte) error
- func (target *Allocation) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- func (a *Allocation) UnmarshalJSON(b []byte) error
- type AllocationAggregationOptions
- type AllocationAnnotations
- type AllocationJSON
- type AllocationLabels
- type AllocationMatchFunc
- type AllocationMatcher
- type AllocationProperties
- func (p *AllocationProperties) Clone() *AllocationProperties
- func (p *AllocationProperties) Equal(that *AllocationProperties) bool
- func (p *AllocationProperties) GenerateKey(aggregateBy []string, labelConfig *LabelConfig) string
- func (p *AllocationProperties) Intersection(that *AllocationProperties) *AllocationProperties
- func (target *AllocationProperties) MarshalBinary() (data []byte, err error)
- func (target *AllocationProperties) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (p *AllocationProperties) String() string
- func (target *AllocationProperties) UnmarshalBinary(data []byte) error
- func (target *AllocationProperties) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- type AllocationQuerier
- type AllocationQueryOptions
- type AllocationSet
- func GenerateMockAllocationSet(start time.Time) *AllocationSet
- func GenerateMockAllocationSetClusterIdle(start time.Time) *AllocationSet
- func GenerateMockAllocationSetNodeIdle(start time.Time) *AllocationSet
- func GenerateMockAllocationSetWithAssetProperties(start time.Time) *AllocationSet
- func NewAllocationSet(start, end time.Time, allocs ...*Allocation) *AllocationSet
- func (as *AllocationSet) Accumulate(that *AllocationSet) (*AllocationSet, error)
- func (as *AllocationSet) AggregateBy(aggregateBy []string, options *AllocationAggregationOptions) error
- func (as *AllocationSet) Clone() *AllocationSet
- func (as *AllocationSet) Delete(name string)
- func (as *AllocationSet) End() time.Time
- func (as *AllocationSet) ExternalAllocations() map[string]*Allocation
- func (as *AllocationSet) ExternalCost() float64
- func (as *AllocationSet) Get(key string) *Allocation
- func (as *AllocationSet) GetUnmountedPVCost() float64
- func (as *AllocationSet) GetWindow() Window
- func (as *AllocationSet) IdleAllocations() map[string]*Allocation
- func (as *AllocationSet) Insert(that *Allocation) error
- func (as *AllocationSet) IsEmpty() bool
- func (as *AllocationSet) Length() int
- func (target *AllocationSet) MarshalBinary() (data []byte, err error)
- func (target *AllocationSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (as *AllocationSet) MarshalJSON() ([]byte, error)
- func (as *AllocationSet) ResetAdjustments()
- func (as *AllocationSet) Resolution() time.Duration
- func (as *AllocationSet) SanitizeNaN()
- func (as *AllocationSet) Set(alloc *Allocation) error
- func (as *AllocationSet) SetUnmountedPVCost() float64
- func (as *AllocationSet) Start() time.Time
- func (as *AllocationSet) String() string
- func (as *AllocationSet) TotalCost() float64
- func (as *AllocationSet) UTCOffset() time.Duration
- func (target *AllocationSet) UnmarshalBinary(data []byte) error
- func (target *AllocationSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- type AllocationSetRange
- func (asr *AllocationSetRange) Accumulate(accumulateBy AccumulateOption) (*AllocationSetRange, error)
- func (asr *AllocationSetRange) AggregateBy(aggregateBy []string, options *AllocationAggregationOptions) error
- func (asr *AllocationSetRange) Append(that *AllocationSet)
- func (asr *AllocationSetRange) Clone() *AllocationSetRange
- func (asr *AllocationSetRange) End() (time.Time, error)
- func (asr *AllocationSetRange) Get(i int) (*AllocationSet, error)
- func (asr *AllocationSetRange) InsertRange(that *AllocationSetRange) error
- func (asr *AllocationSetRange) Length() int
- func (target *AllocationSetRange) MarshalBinary() (data []byte, err error)
- func (target *AllocationSetRange) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (asr *AllocationSetRange) MarshalJSON() ([]byte, error)
- func (asr *AllocationSetRange) Minutes() float64
- func (asr *AllocationSetRange) Slice() []*AllocationSet
- func (asr *AllocationSetRange) Start() (time.Time, error)
- func (asr *AllocationSetRange) StartAndEnd() (time.Time, time.Time, error)
- func (asr *AllocationSetRange) String() string
- func (asr *AllocationSetRange) TotalCost() float64
- func (asr *AllocationSetRange) UTCOffset() time.Duration
- func (target *AllocationSetRange) UnmarshalBinary(data []byte) error
- func (target *AllocationSetRange) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- func (asr *AllocationSetRange) Window() Window
- type AllocationTotals
- func (art *AllocationTotals) ClearAdjustments()
- func (art *AllocationTotals) Clone() *AllocationTotals
- func (arts *AllocationTotals) ToResponse() *AllocationTotalsResponse
- func (art *AllocationTotals) TotalCPUCost() float64
- func (art *AllocationTotals) TotalCost() float64
- func (art *AllocationTotals) TotalGPUCost() float64
- func (art *AllocationTotals) TotalLoadBalancerCost() float64
- func (art *AllocationTotals) TotalNetworkCost() float64
- func (art *AllocationTotals) TotalPersistentVolumeCost() float64
- func (art *AllocationTotals) TotalRAMCost() float64
- type AllocationTotalsResponse
- type AllocationTotalsResult
- type AllocationTotalsResultResponse
- type AllocationTotalsSet
- type AllocationTotalsStore
- type Any
- func (a *Any) Add(that Asset) Asset
- func (a *Any) Clone() Asset
- func (a *Any) Equal(that Asset) bool
- func (a *Any) ExpandWindow(window Window)
- func (a *Any) GetAdjustment() float64
- func (a *Any) GetEnd() time.Time
- func (a *Any) GetLabels() AssetLabels
- func (a *Any) GetProperties() *AssetProperties
- func (a *Any) GetStart() time.Time
- func (a *Any) GetWindow() Window
- func (a *Any) InterfaceToAny(itf interface{}) error
- func (target *Any) MarshalBinary() (data []byte, err error)
- func (target *Any) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (a *Any) MarshalJSON() ([]byte, error)
- func (a *Any) Minutes() float64
- func (a *Any) SanitizeNaN()
- func (a *Any) SetAdjustment(adj float64)
- func (a *Any) SetLabels(labels AssetLabels)
- func (a *Any) SetProperties(props *AssetProperties)
- func (a *Any) SetStartEnd(start, end time.Time)
- func (a *Any) SetWindow(window Window)
- func (a *Any) String() string
- func (a *Any) TotalCost() float64
- func (a *Any) Type() AssetType
- func (target *Any) UnmarshalBinary(data []byte) error
- func (target *Any) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- func (a *Any) UnmarshalJSON(b []byte) error
- type Asset
- type AssetAPIResponse
- type AssetAggregationOptions
- type AssetLabels
- type AssetMatcher
- type AssetProperties
- func (ap *AssetProperties) Clone() *AssetProperties
- func (ap *AssetProperties) Equal(that *AssetProperties) bool
- func (ap *AssetProperties) Keys(props []AssetProperty) []string
- func (target *AssetProperties) MarshalBinary() (data []byte, err error)
- func (target *AssetProperties) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (ap *AssetProperties) Merge(that *AssetProperties) *AssetProperties
- func (ap *AssetProperties) String() string
- func (target *AssetProperties) UnmarshalBinary(data []byte) error
- func (target *AssetProperties) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- type AssetProperty
- type AssetQuerier
- type AssetQueryOptions
- type AssetSet
- func (as *AssetSet) AggregateBy(aggregateBy []string, opts *AssetAggregationOptions) error
- func (as *AssetSet) Clone() *AssetSet
- func (as *AssetSet) End() time.Time
- func (as *AssetSet) FindMatch(query Asset, aggregateBy []string, labelConfig *LabelConfig) (Asset, error)
- func (as *AssetSet) Get(key string) (Asset, bool)
- func (as *AssetSet) GetWindow() Window
- func (as *AssetSet) Insert(asset Asset, labelConfig *LabelConfig) error
- func (as *AssetSet) IsEmpty() bool
- func (as *AssetSet) Length() int
- func (target *AssetSet) MarshalBinary() (data []byte, err error)
- func (target *AssetSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (as *AssetSet) MarshalJSON() ([]byte, error)
- func (as *AssetSet) ReconciliationMatch(query Asset) (Asset, bool, error)
- func (as *AssetSet) ReconciliationMatchMap() map[string]map[string]Asset
- func (as *AssetSet) Resolution() time.Duration
- func (as *AssetSet) SanitizeNaN()
- func (as *AssetSet) Set(asset Asset, aggregateBy []string, labelConfig *LabelConfig) error
- func (as *AssetSet) Start() time.Time
- func (as *AssetSet) TotalCost() float64
- func (as *AssetSet) UTCOffset() time.Duration
- func (target *AssetSet) UnmarshalBinary(data []byte) error
- func (target *AssetSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- type AssetSetRange
- func (asr *AssetSetRange) Accumulate(accumulateBy AccumulateOption) (*AssetSetRange, error)
- func (asr *AssetSetRange) AccumulateToAssetSet() (*AssetSet, error)
- func (asr *AssetSetRange) AggregateBy(aggregateBy []string, opts *AssetAggregationOptions) error
- func (asr *AssetSetRange) Append(that *AssetSet)
- func (asr *AssetSetRange) End() (time.Time, error)
- func (asr *AssetSetRange) Get(i int) (*AssetSet, error)
- func (asr *AssetSetRange) GetWarnings() []string
- func (asr *AssetSetRange) HasWarnings() bool
- func (asr *AssetSetRange) InsertRange(that *AssetSetRange) error
- func (asr *AssetSetRange) IsEmpty() bool
- func (asr *AssetSetRange) Length() int
- func (target *AssetSetRange) MarshalBinary() (data []byte, err error)
- func (target *AssetSetRange) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (asr *AssetSetRange) MarshalJSON() ([]byte, error)
- func (asr *AssetSetRange) Minutes() float64
- func (asr *AssetSetRange) Start() (time.Time, error)
- func (asr *AssetSetRange) StartAndEnd() (time.Time, time.Time, error)
- func (asr *AssetSetRange) TotalCost() float64
- func (asr *AssetSetRange) UTCOffset() time.Duration
- func (target *AssetSetRange) UnmarshalBinary(data []byte) error
- func (target *AssetSetRange) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- func (asr *AssetSetRange) Window() Window
- type AssetSetRangeResponse
- type AssetSetResponse
- type AssetTotals
- func (art *AssetTotals) ClearAdjustments()
- func (art *AssetTotals) Clone() *AssetTotals
- func (art *AssetTotals) TotalAttachedVolumeCost() float64
- func (art *AssetTotals) TotalCPUCost() float64
- func (art *AssetTotals) TotalClusterManagementCost() float64
- func (art *AssetTotals) TotalCost() float64
- func (art *AssetTotals) TotalGPUCost() float64
- func (art *AssetTotals) TotalLoadBalancerCost() float64
- func (art *AssetTotals) TotalPersistentVolumeCost() float64
- func (art *AssetTotals) TotalRAMCost() float64
- type AssetTotalsResult
- type AssetTotalsSet
- type AssetTotalsStore
- type AssetType
- type BinDecoder
- type BinEncoder
- type BoundaryError
- type Breakdown
- func (b *Breakdown) Clone() *Breakdown
- func (b *Breakdown) Equal(that *Breakdown) bool
- func (target *Breakdown) MarshalBinary() (data []byte, err error)
- func (target *Breakdown) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (b *Breakdown) SanitizeNaN()
- func (target *Breakdown) UnmarshalBinary(data []byte) error
- func (target *Breakdown) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- type Cloud
- func (ca *Cloud) Add(a Asset) Asset
- func (ca *Cloud) Clone() Asset
- func (ca *Cloud) Equal(a Asset) bool
- func (ca *Cloud) ExpandWindow(window Window)
- func (ca *Cloud) GetAdjustment() float64
- func (ca *Cloud) GetEnd() time.Time
- func (ca *Cloud) GetLabels() AssetLabels
- func (ca *Cloud) GetProperties() *AssetProperties
- func (ca *Cloud) GetStart() time.Time
- func (ca *Cloud) GetWindow() Window
- func (ca *Cloud) InterfaceToCloud(itf interface{}) error
- func (target *Cloud) MarshalBinary() (data []byte, err error)
- func (target *Cloud) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (ca *Cloud) MarshalJSON() ([]byte, error)
- func (ca *Cloud) Minutes() float64
- func (ca *Cloud) SanitizeNaN()
- func (ca *Cloud) SetAdjustment(adj float64)
- func (ca *Cloud) SetLabels(labels AssetLabels)
- func (ca *Cloud) SetProperties(props *AssetProperties)
- func (ca *Cloud) SetStartEnd(start, end time.Time)
- func (ca *Cloud) SetWindow(window Window)
- func (ca *Cloud) String() string
- func (ca *Cloud) TotalCost() float64
- func (ca *Cloud) Type() AssetType
- func (target *Cloud) UnmarshalBinary(data []byte) error
- func (target *Cloud) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- func (ca *Cloud) UnmarshalJSON(b []byte) error
- type CloudAssetStatus
- type CloudCost
- func (cc *CloudCost) Clone() *CloudCost
- func (cc *CloudCost) Equal(that *CloudCost) bool
- func (cc *CloudCost) GetCostMetric(costMetricName CostMetricName) (CostMetric, error)
- func (target *CloudCost) MarshalBinary() (data []byte, err error)
- func (target *CloudCost) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (cc *CloudCost) StringMapProperty(property string) (map[string]string, error)
- func (cc *CloudCost) StringProperty(prop string) (string, error)
- func (target *CloudCost) UnmarshalBinary(data []byte) error
- func (target *CloudCost) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- func (cc *CloudCost) WeightCostMetrics(weightedAverge float64)
- type CloudCostLabels
- type CloudCostMatcher
- type CloudCostProperties
- func (ccp *CloudCostProperties) Clone() *CloudCostProperties
- func (ccp *CloudCostProperties) Equal(that *CloudCostProperties) bool
- func (ccp *CloudCostProperties) GenerateKey(props []string) string
- func (ccp *CloudCostProperties) Intersection(that *CloudCostProperties) *CloudCostProperties
- func (target *CloudCostProperties) MarshalBinary() (data []byte, err error)
- func (target *CloudCostProperties) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (target *CloudCostProperties) UnmarshalBinary(data []byte) error
- func (target *CloudCostProperties) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- type CloudCostSet
- func (ccs *CloudCostSet) Accumulate(that *CloudCostSet) (*CloudCostSet, error)
- func (ccs *CloudCostSet) Aggregate(props []string) (*CloudCostSet, error)
- func (ccs *CloudCostSet) Clone() *CloudCostSet
- func (ccs *CloudCostSet) Equal(that *CloudCostSet) bool
- func (ccs *CloudCostSet) Filter(filters filter.Filter[*CloudCost]) *CloudCostSet
- func (ccs *CloudCostSet) Filter21(filters filter21.Filter) (*CloudCostSet, error)
- func (ccs *CloudCostSet) GetWindow() Window
- func (ccs *CloudCostSet) Insert(cc *CloudCost) error
- func (ccs *CloudCostSet) IsEmpty() bool
- func (ccs *CloudCostSet) Length() int
- func (target *CloudCostSet) MarshalBinary() (data []byte, err error)
- func (target *CloudCostSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (ccs *CloudCostSet) Merge(that *CloudCostSet) (*CloudCostSet, error)
- func (target *CloudCostSet) UnmarshalBinary(data []byte) error
- func (target *CloudCostSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- type CloudCostSetRange
- func (ccsr *CloudCostSetRange) Accumulate(accumulateBy AccumulateOption) (*CloudCostSetRange, error)
- func (ccsr *CloudCostSetRange) AccumulateAll() (*CloudCostSet, error)
- func (ccsr *CloudCostSetRange) Append(that *CloudCostSet)
- func (ccsr *CloudCostSetRange) Clone() *CloudCostSetRange
- func (ccsr *CloudCostSetRange) IsEmpty() bool
- func (ccsr *CloudCostSetRange) LoadCloudCost(cloudCost *CloudCost)
- func (target *CloudCostSetRange) MarshalBinary() (data []byte, err error)
- func (target *CloudCostSetRange) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (target *CloudCostSetRange) UnmarshalBinary(data []byte) error
- func (target *CloudCostSetRange) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- type CloudStatus
- type CloudUsage
- type CloudUsageAggregationOptions
- type CloudUsageFilter
- type CloudUsageQuerier
- type CloudUsageQueryOptions
- type CloudUsageSet
- type CloudUsageSetRange
- type ClusterManagement
- func (cm *ClusterManagement) Add(a Asset) Asset
- func (cm *ClusterManagement) Clone() Asset
- func (cm *ClusterManagement) Equal(a Asset) bool
- func (cm *ClusterManagement) ExpandWindow(window Window)
- func (cm *ClusterManagement) GetAdjustment() float64
- func (cm *ClusterManagement) GetEnd() time.Time
- func (cm *ClusterManagement) GetLabels() AssetLabels
- func (cm *ClusterManagement) GetProperties() *AssetProperties
- func (cm *ClusterManagement) GetStart() time.Time
- func (cm *ClusterManagement) GetWindow() Window
- func (cm *ClusterManagement) InterfaceToClusterManagement(itf interface{}) error
- func (target *ClusterManagement) MarshalBinary() (data []byte, err error)
- func (target *ClusterManagement) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (cm *ClusterManagement) MarshalJSON() ([]byte, error)
- func (cm *ClusterManagement) Minutes() float64
- func (cm *ClusterManagement) SanitizeNaN()
- func (cm *ClusterManagement) SetAdjustment(adj float64)
- func (cm *ClusterManagement) SetLabels(props AssetLabels)
- func (cm *ClusterManagement) SetProperties(props *AssetProperties)
- func (cm *ClusterManagement) SetStartEnd(start, end time.Time)
- func (cm *ClusterManagement) SetWindow(window Window)
- func (cm *ClusterManagement) String() string
- func (cm *ClusterManagement) TotalCost() float64
- func (cm *ClusterManagement) Type() AssetType
- func (target *ClusterManagement) UnmarshalBinary(data []byte) error
- func (target *ClusterManagement) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- func (cm *ClusterManagement) UnmarshalJSON(b []byte) error
- type CostMetric
- func (cm CostMetric) Clone() CostMetric
- func (cm CostMetric) Equal(that CostMetric) bool
- func (target *CostMetric) MarshalBinary() (data []byte, err error)
- func (target *CostMetric) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (target *CostMetric) UnmarshalBinary(data []byte) error
- func (target *CostMetric) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- type CostMetricName
- type Coverage
- func (c *Coverage) Clone() *Coverage
- func (c *Coverage) GetWindow() Window
- func (c *Coverage) IsEmpty() bool
- func (c *Coverage) Key() string
- func (target *Coverage) MarshalBinary() (data []byte, err error)
- func (target *Coverage) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (target *Coverage) UnmarshalBinary(data []byte) error
- func (target *Coverage) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- type CoverageSet
- func (cs *CoverageSet) Clone() *CoverageSet
- func (cs *CoverageSet) Filter(filters filter.Filter[*Coverage]) *CoverageSet
- func (cs *CoverageSet) GetWindow() Window
- func (cs *CoverageSet) Insert(coverage *Coverage)
- func (cs *CoverageSet) IsEmpty() bool
- func (target *CoverageSet) MarshalBinary() (data []byte, err error)
- func (target *CoverageSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (target *CoverageSet) UnmarshalBinary(data []byte) error
- func (target *CoverageSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- type DecodingContext
- type Diff
- type DiffKind
- type DirectoryStatus
- type Disk
- func (d *Disk) Add(a Asset) Asset
- func (d *Disk) Bytes() float64
- func (d *Disk) Clone() Asset
- func (d *Disk) Equal(a Asset) bool
- func (d *Disk) ExpandWindow(window Window)
- func (d *Disk) GetAdjustment() float64
- func (d *Disk) GetEnd() time.Time
- func (d *Disk) GetLabels() AssetLabels
- func (d *Disk) GetProperties() *AssetProperties
- func (d *Disk) GetStart() time.Time
- func (d *Disk) GetWindow() Window
- func (d *Disk) InterfaceToDisk(itf interface{}) error
- func (target *Disk) MarshalBinary() (data []byte, err error)
- func (target *Disk) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (d *Disk) MarshalJSON() ([]byte, error)
- func (d *Disk) Minutes() float64
- func (d *Disk) SanitizeNaN()
- func (d *Disk) SetAdjustment(adj float64)
- func (d *Disk) SetLabels(labels AssetLabels)
- func (d *Disk) SetProperties(props *AssetProperties)
- func (d *Disk) SetStartEnd(start, end time.Time)
- func (d *Disk) SetWindow(window Window)
- func (d *Disk) String() string
- func (d *Disk) TotalCost() float64
- func (d *Disk) Type() AssetType
- func (target *Disk) UnmarshalBinary(data []byte) error
- func (target *Disk) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- func (d *Disk) UnmarshalJSON(b []byte) error
- type ETLStatus
- type EncodingContext
- type FileStatus
- type LabelConfig
- type LbAllocation
- func (target *LbAllocation) MarshalBinary() (data []byte, err error)
- func (target *LbAllocation) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (lba *LbAllocation) SanitizeNaN()
- func (target *LbAllocation) UnmarshalBinary(data []byte) error
- func (target *LbAllocation) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- type LbAllocations
- type LoadBalancer
- func (lb *LoadBalancer) Add(a Asset) Asset
- func (lb *LoadBalancer) Clone() Asset
- func (lb *LoadBalancer) Equal(a Asset) bool
- func (lb *LoadBalancer) ExpandWindow(w Window)
- func (lb *LoadBalancer) GetAdjustment() float64
- func (lb *LoadBalancer) GetEnd() time.Time
- func (lb *LoadBalancer) GetLabels() AssetLabels
- func (lb *LoadBalancer) GetProperties() *AssetProperties
- func (lb *LoadBalancer) GetStart() time.Time
- func (lb *LoadBalancer) GetWindow() Window
- func (lb *LoadBalancer) InterfaceToLoadBalancer(itf interface{}) error
- func (target *LoadBalancer) MarshalBinary() (data []byte, err error)
- func (target *LoadBalancer) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (lb *LoadBalancer) MarshalJSON() ([]byte, error)
- func (lb *LoadBalancer) Minutes() float64
- func (lb *LoadBalancer) SanitizeNaN()
- func (lb *LoadBalancer) SetAdjustment(adj float64)
- func (lb *LoadBalancer) SetLabels(labels AssetLabels)
- func (lb *LoadBalancer) SetProperties(props *AssetProperties)
- func (lb *LoadBalancer) SetStartEnd(start, end time.Time)
- func (lb *LoadBalancer) SetWindow(window Window)
- func (lb *LoadBalancer) String() string
- func (lb *LoadBalancer) TotalCost() float64
- func (lb *LoadBalancer) Type() AssetType
- func (target *LoadBalancer) UnmarshalBinary(data []byte) error
- func (target *LoadBalancer) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- func (lb *LoadBalancer) UnmarshalJSON(b []byte) error
- type MemoryTotalsStore
- func (mts *MemoryTotalsStore) GetAllocationTotalsByCluster(start time.Time, end time.Time) (map[string]*AllocationTotals, bool)
- func (mts *MemoryTotalsStore) GetAllocationTotalsByNode(start time.Time, end time.Time) (map[string]*AllocationTotals, bool)
- func (mts *MemoryTotalsStore) GetAssetTotalsByCluster(start time.Time, end time.Time) (map[string]*AssetTotals, bool)
- func (mts *MemoryTotalsStore) GetAssetTotalsByNode(start time.Time, end time.Time) (map[string]*AssetTotals, bool)
- func (mts *MemoryTotalsStore) SetAllocationTotalsByCluster(start time.Time, end time.Time, arts map[string]*AllocationTotals)
- func (mts *MemoryTotalsStore) SetAllocationTotalsByNode(start time.Time, end time.Time, arts map[string]*AllocationTotals)
- func (mts *MemoryTotalsStore) SetAssetTotalsByCluster(start time.Time, end time.Time, arts map[string]*AssetTotals)
- func (mts *MemoryTotalsStore) SetAssetTotalsByNode(start time.Time, end time.Time, arts map[string]*AssetTotals)
- type Network
- func (n *Network) Add(a Asset) Asset
- func (n *Network) Clone() Asset
- func (n *Network) Equal(a Asset) bool
- func (n *Network) ExpandWindow(window Window)
- func (n *Network) GetAdjustment() float64
- func (n *Network) GetEnd() time.Time
- func (n *Network) GetLabels() AssetLabels
- func (n *Network) GetProperties() *AssetProperties
- func (n *Network) GetStart() time.Time
- func (n *Network) GetWindow() Window
- func (n *Network) InterfaceToNetwork(itf interface{}) error
- func (target *Network) MarshalBinary() (data []byte, err error)
- func (target *Network) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (n *Network) MarshalJSON() ([]byte, error)
- func (n *Network) Minutes() float64
- func (n *Network) SanitizeNaN()
- func (n *Network) SetAdjustment(adj float64)
- func (n *Network) SetLabels(labels AssetLabels)
- func (n *Network) SetProperties(props *AssetProperties)
- func (n *Network) SetStartEnd(start, end time.Time)
- func (n *Network) SetWindow(window Window)
- func (n *Network) String() string
- func (n *Network) TotalCost() float64
- func (n *Network) Type() AssetType
- func (target *Network) UnmarshalBinary(data []byte) error
- func (target *Network) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- func (n *Network) UnmarshalJSON(b []byte) error
- type Node
- func (n *Node) Add(a Asset) Asset
- func (n *Node) CPUCores() float64
- func (n *Node) Clone() Asset
- func (n *Node) Equal(a Asset) bool
- func (n *Node) ExpandWindow(window Window)
- func (n *Node) GPUs() float64
- func (n *Node) GetAdjustment() float64
- func (n *Node) GetEnd() time.Time
- func (n *Node) GetLabels() AssetLabels
- func (n *Node) GetProperties() *AssetProperties
- func (n *Node) GetStart() time.Time
- func (n *Node) GetWindow() Window
- func (n *Node) InterfaceToNode(itf interface{}) error
- func (n *Node) IsPreemptible() bool
- func (target *Node) MarshalBinary() (data []byte, err error)
- func (target *Node) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (n *Node) MarshalJSON() ([]byte, error)
- func (n *Node) Minutes() float64
- func (n *Node) RAMBytes() float64
- func (n *Node) SanitizeNaN()
- func (n *Node) SetAdjustment(adj float64)
- func (n *Node) SetLabels(labels AssetLabels)
- func (n *Node) SetProperties(props *AssetProperties)
- func (n *Node) SetStartEnd(start, end time.Time)
- func (n *Node) SetWindow(window Window)
- func (n *Node) String() string
- func (n *Node) TotalCost() float64
- func (n *Node) Type() AssetType
- func (target *Node) UnmarshalBinary(data []byte) error
- func (target *Node) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- func (n *Node) UnmarshalJSON(b []byte) error
- type NodeOverhead
- func (n *NodeOverhead) Clone() *NodeOverhead
- func (n *NodeOverhead) Equal(other *NodeOverhead) bool
- func (target *NodeOverhead) MarshalBinary() (data []byte, err error)
- func (target *NodeOverhead) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (n *NodeOverhead) SanitizeNaN()
- func (target *NodeOverhead) UnmarshalBinary(data []byte) error
- func (target *NodeOverhead) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- type PVAllocation
- func (pva *PVAllocation) Equal(that *PVAllocation) bool
- func (target *PVAllocation) MarshalBinary() (data []byte, err error)
- func (target *PVAllocation) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (pva *PVAllocation) SanitizeNaN()
- func (target *PVAllocation) UnmarshalBinary(data []byte) error
- func (target *PVAllocation) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- type PVAllocations
- type PVKey
- func (pvk *PVKey) FromString(key string) error
- func (target *PVKey) MarshalBinary() (data []byte, err error)
- func (target *PVKey) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (pvk PVKey) MarshalText() (text []byte, err error)
- func (pvk *PVKey) String() string
- func (target *PVKey) UnmarshalBinary(data []byte) error
- func (target *PVKey) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- func (pvk *PVKey) UnmarshalText(text []byte) error
- type Pair
- type ProportionalAssetResourceCost
- type ProportionalAssetResourceCosts
- func (parcs ProportionalAssetResourceCosts) Add(that ProportionalAssetResourceCosts)
- func (parcs ProportionalAssetResourceCosts) Clone() ProportionalAssetResourceCosts
- func (parcs ProportionalAssetResourceCosts) Insert(parc ProportionalAssetResourceCost, insertByName bool)
- func (parcs ProportionalAssetResourceCosts) SanitizeNaN()
- type Querier
- type RawAllocationOnlyData
- func (r *RawAllocationOnlyData) Clone() *RawAllocationOnlyData
- func (r *RawAllocationOnlyData) Equal(that *RawAllocationOnlyData) bool
- func (target *RawAllocationOnlyData) MarshalBinary() (data []byte, err error)
- func (target *RawAllocationOnlyData) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (r *RawAllocationOnlyData) SanitizeNaN()
- func (target *RawAllocationOnlyData) UnmarshalBinary(data []byte) error
- func (target *RawAllocationOnlyData) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- type ReconciliationStatus
- type SharedAsset
- func (sa *SharedAsset) Add(a Asset) Asset
- func (sa *SharedAsset) Clone() Asset
- func (sa *SharedAsset) Equal(a Asset) bool
- func (sa *SharedAsset) ExpandWindow(w Window)
- func (sa *SharedAsset) GetAdjustment() float64
- func (sa *SharedAsset) GetEnd() time.Time
- func (sa *SharedAsset) GetLabels() AssetLabels
- func (sa *SharedAsset) GetProperties() *AssetProperties
- func (sa *SharedAsset) GetStart() time.Time
- func (sa *SharedAsset) GetWindow() Window
- func (sa *SharedAsset) InterfaceToSharedAsset(itf interface{}) error
- func (target *SharedAsset) MarshalBinary() (data []byte, err error)
- func (target *SharedAsset) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (sa *SharedAsset) MarshalJSON() ([]byte, error)
- func (sa *SharedAsset) Minutes() float64
- func (sa *SharedAsset) SanitizeNaN()
- func (sa *SharedAsset) SetAdjustment(float64)
- func (sa *SharedAsset) SetLabels(labels AssetLabels)
- func (sa *SharedAsset) SetProperties(props *AssetProperties)
- func (sa *SharedAsset) SetStartEnd(start, end time.Time)
- func (sa *SharedAsset) SetWindow(window Window)
- func (sa *SharedAsset) String() string
- func (sa *SharedAsset) TotalCost() float64
- func (sa *SharedAsset) Type() AssetType
- func (target *SharedAsset) UnmarshalBinary(data []byte) error
- func (target *SharedAsset) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- func (sa *SharedAsset) UnmarshalJSON(b []byte) error
- type SharedCostBreakdown
- type SharedCostBreakdowns
- type StringTable
- type SummaryAllocation
- func (sa *SummaryAllocation) Add(that *SummaryAllocation) error
- func (sa *SummaryAllocation) CPUEfficiency() float64
- func (sa *SummaryAllocation) Clone() *SummaryAllocation
- func (sa *SummaryAllocation) Equal(that *SummaryAllocation) bool
- func (sa *SummaryAllocation) IsExternal() bool
- func (sa *SummaryAllocation) IsIdle() bool
- func (sa *SummaryAllocation) IsUnallocated() bool
- func (sa *SummaryAllocation) IsUnmounted() bool
- func (sa *SummaryAllocation) Minutes() float64
- func (sa *SummaryAllocation) RAMEfficiency() float64
- func (sa *SummaryAllocation) ToResponse() *SummaryAllocationResponse
- func (sa *SummaryAllocation) TotalCost() float64
- func (sa *SummaryAllocation) TotalEfficiency() float64
- type SummaryAllocationQuerier
- type SummaryAllocationResponse
- type SummaryAllocationSet
- func (sas *SummaryAllocationSet) Add(that *SummaryAllocationSet) (*SummaryAllocationSet, error)
- func (sas *SummaryAllocationSet) AggregateBy(aggregateBy []string, options *AllocationAggregationOptions) error
- func (sas *SummaryAllocationSet) CPUEfficiency() float64
- func (sas *SummaryAllocationSet) Clone() *SummaryAllocationSet
- func (sas *SummaryAllocationSet) Delete(name string)
- func (sas *SummaryAllocationSet) Each(f func(string, *SummaryAllocation))
- func (sas *SummaryAllocationSet) Equal(that *SummaryAllocationSet) bool
- func (sas *SummaryAllocationSet) GetUnmountedPVCost() float64
- func (sas *SummaryAllocationSet) Insert(sa *SummaryAllocation) error
- func (sas *SummaryAllocationSet) RAMEfficiency() float64
- func (sas *SummaryAllocationSet) ToResponse() *SummaryAllocationSetResponse
- func (sas *SummaryAllocationSet) TotalCost() float64
- func (sas *SummaryAllocationSet) TotalEfficiency() float64
- type SummaryAllocationSetRange
- func (sasr *SummaryAllocationSetRange) Accumulate(accumulateBy AccumulateOption) (*SummaryAllocationSetRange, error)
- func (sasr *SummaryAllocationSetRange) AggregateBy(aggregateBy []string, options *AllocationAggregationOptions) error
- func (sasr *SummaryAllocationSetRange) Append(sas *SummaryAllocationSet)
- func (sasr *SummaryAllocationSetRange) Clone() *SummaryAllocationSetRange
- func (sasr *SummaryAllocationSetRange) Each(f func(int, *SummaryAllocationSet))
- func (sasr *SummaryAllocationSetRange) InsertExternalAllocations(that *AllocationSetRange) error
- func (sasr *SummaryAllocationSetRange) Print(verbose bool)
- func (sasr *SummaryAllocationSetRange) ToResponse() *SummaryAllocationSetRangeResponse
- func (sasr *SummaryAllocationSetRange) TotalCost() float64
- type SummaryAllocationSetRangeResponse
- type SummaryAllocationSetResponse
- type TotalsStore
- type Window
- func GetWindows(start time.Time, end time.Time, windowSize time.Duration) ([]Window, error)
- func GetWindowsForQueryWindow(start time.Time, end time.Time, queryWindow time.Duration) ([]Window, error)
- func NewClosedWindow(start, end time.Time) Window
- func NewWindow(start, end *time.Time) Window
- func ParseWindowUTC(window string) (Window, error)
- func ParseWindowWithOffset(window string, offset time.Duration) (Window, error)
- func ParseWindowWithOffsetString(window string, offset string) (Window, error)
- func (w Window) ApproximatelyEqual(that Window, threshold time.Duration) bool
- func (w Window) Clone() Window
- func (w Window) Contains(t time.Time) bool
- func (w Window) ContainsWindow(that Window) bool
- func (w Window) Contract(that Window) Window
- func (w Window) ContractEnd(end time.Time) Window
- func (w Window) ContractStart(start time.Time) Window
- func (w Window) Duration() time.Duration
- func (w Window) DurationOffset() (time.Duration, time.Duration, error)
- func (w Window) DurationOffsetForPrometheus() (string, string, error)
- func (w Window) DurationOffsetStrings() (string, string)
- func (w Window) End() *time.Time
- func (w Window) Equal(that Window) bool
- func (w Window) Expand(that Window) Window
- func (w Window) ExpandEnd(end time.Time) Window
- func (w Window) ExpandStart(start time.Time) Window
- func (w Window) GetAccumulateWindow(accumOpt AccumulateOption) (Window, error)
- func (w Window) GetAccumulateWindows(accumOpt AccumulateOption) ([]Window, error)
- func (w Window) GetPercentInWindow(that Window) float64
- func (w Window) HasDuration() bool
- func (w Window) Hours() float64
- func (w Window) IsEmpty() bool
- func (w Window) IsNegative() bool
- func (w Window) IsOpen() bool
- func (target *Window) MarshalBinary() (data []byte, err error)
- func (target *Window) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
- func (w Window) MarshalJSON() ([]byte, error)
- func (w Window) Minutes() float64
- func (w *Window) Set(start, end *time.Time)
- func (w Window) Shift(dur time.Duration) Window
- func (w Window) Start() *time.Time
- func (w Window) String() string
- func (target *Window) UnmarshalBinary(data []byte) error
- func (target *Window) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
- func (w *Window) UnmarshalJSON(bs []byte) error
Constants ¶
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" )
const ( DiffAdded DiffKind = "added" DiffRemoved = "removed" DiffChanged = "changed" )
const ( CloudCostInvoiceEntityIDProp string = "invoiceEntityID" CloudCostAccountIDProp string = "accountID" CloudCostProviderProp string = "provider" CloudCostProviderIDProp string = "providerID" CloudCostCategoryProp string = "category" CloudCostServiceProp string = "service" CloudCostLabelProp string = "label" )
const ( // CloudCostClusterManagementCategory describes CloudCost representing Hosted Kubernetes Fees CloudCostClusterManagementCategory string = "Cluster Management" // CloudCostDiskCategory describes CloudCost representing Disk usage CloudCostDiskCategory string = "Disk" // CloudCostLoadBalancerCategory describes CloudCost representing Load Balancer usage CloudCostLoadBalancerCategory string = "Load Balancer" // CloudCostNetworkCategory describes CloudCost representing Network usage CloudCostNetworkCategory string = "Network" // CloudCostVirtualMachineCategory describes CloudCost representing VM usage CloudCostVirtualMachineCategory string = "Virtual Machine" // CloudCostOtherCategory describes CloudCost that do not belong to a defined category CloudCostOtherCategory string = "Other" )
const ( // DefaultCodecVersion is used for any resources listed in the Default version set DefaultCodecVersion uint8 = 17 // AssetsCodecVersion is used for any resources listed in the Assets version set AssetsCodecVersion uint8 = 21 // AllocationCodecVersion is used for any resources listed in the Allocation version set AllocationCodecVersion uint8 = 20 // CloudCostCodecVersion is used for any resources listed in the CloudCost version set CloudCostCodecVersion uint8 = 2 )
const AKSNodepoolLabel = "kubernetes.azure.com/agentpool"
describes how Azure labels nodepool nodes
const AWSProvider = "AWS"
AWSProvider describes the provider AWS
const AlibabaProvider = "Alibaba"
AlibabaProvider describes the provider for Alibaba Cloud
const AzureProvider = "Azure"
AzureProvider describes the provider Azure
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
const CSVProvider = "CSV"
CSVProvider describes the provider a CSV
const ComputeCategory = "Compute"
ComputeCategory signifies the Compute Category
const CustomProvider = "custom"
CustomProvider describes a custom provider
const EKSNodepoolLabel = "eks.amazonaws.com/nodegroup"
describes how AWS labels nodepool nodes
const ExternalSuffix = "__external__"
ExternalSuffix indicates an external allocation
const GCPProvider = "GCP"
GCPProvider describes the provider GCP
const GKENodePoolLabel = "cloud.google.com/gke-nodepool"
describes how nodepool nodes are labeled in GKE
const ( // GeneratorPackageName is the package the generator is targetting GeneratorPackageName string = "kubecost" )
const IdleSuffix = "__idle__"
IdleSuffix indicates an idle allocation property
const KubernetesService = "Kubernetes"
const LocalStorageClass = "__local__"
LocalStorageClass is used to assign storage class of local disks.
const ManagementCategory = "Management"
ManagementCategory signifies the Management Category
const NetworkCategory = "Network"
NetworkCategory signifies the Network Category
const NilProvider = "-"
NilProvider describes unknown provider
const OtherCategory = "Other"
OtherCategory signifies an unassigned Category
const ScalewayProvider = "Scaleway"
ScalewayProvider describes the provider Scaleway
ShareEven indicates that a shared resource should be shared evenly across all remaining allocations.
ShareNone indicates that a shareable resource should not be shared
ShareWeighted indicates that a shared resource should be shared as a proportion of the cost of the remaining allocations.
SharedCategory signifies an unassigned Category
SharedSuffix indicates an shared allocation property
const StorageCategory = "Storage"
StorageCategory signifies the Storage Category
const UnallocatedSuffix = "__unallocated__"
UnallocatedSuffix indicates an unallocated allocation property
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__"
const UnknownStorageClass = "__unknown__"
UnknownStorageClass is used to assign storage class of persistent volume whose information is unable to be traced.
const UnmountedSuffix = "__unmounted__"
UnmountedSuffix indicated allocation to an unmounted resource (PV or LB)
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, byAsset bool) 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 ComputePercentages ¶ added in v1.105.0
func ComputePercentages(toInsert *ProportionalAssetResourceCost)
func DiffAsset ¶
DiffAsset takes two AssetSets and returns a map of keys to Diffs by checking the keys of each AssetSet. If a key is not found or is found with a different total cost, a Diff is generated and added to the map. A found asset will only be added to the map if the new total cost is greater than ratioCostChange * the old total cost
func GetNodePoolName ¶ added in v1.104.0
func NewAllocationAliasPass ¶ added in v1.105.0
func NewAllocationAliasPass(config LabelConfig) transform.CompilerPass
NewAliasPass creates a compiler pass that converts alias nodes to logically-equivalent label/annotation nodes based on the label config.
Due to the special alias logic that combines label and annotation behavior when filtering on alias, an alias filter is logically equivalent to the following expression:
(or
(and (contains labels <parseraliaskey>) (<op> labels[<parseraliaskey>] <filtervalue>)) (and (not (contains labels <parseraliaskey>)) (and (contains annotations departmentkey) (<op> annotations[<parseraliaskey>] <filtervalue>))))
func NewAllocationMatchCompiler ¶ added in v1.105.0
func NewAllocationMatchCompiler(labelConfig *LabelConfig) *matcher.MatchCompiler[*Allocation]
NewAllocationMatchCompiler creates a new instance of a matcher.MatchCompiler[*Allocation] which can be used to compile filter.Filter ASTs into matcher.Matcher[*Allocation] implementations.
If the label config is nil, the compiler will fail to compile alias filters if any are present in the AST.
If storage interfaces every support querying natively by alias (e.g. if a data store contained a "product" attribute on an Allocation row), that should be handled by a purpose-built AST compiler.
func NewAssetMatchCompiler ¶ added in v1.105.0
func NewAssetMatchCompiler() *matcher.MatchCompiler[Asset]
NewAssetMatchCompiler creates a new instance of a matcher.MatchCompiler[Asset] which can be used to compile filter.Filter ASTs into matcher.Matcher[Asset] implementations.
If the label config is nil, the compiler will fail to compile alias filters if any are present in the AST.
If storage interfaces every support querying natively by alias (e.g. if a data store contained a "product" attribute on an Asset row), that should be handled by a purpose-built AST compiler.
func NewCloudCostMatchCompiler ¶ added in v1.107.0
func NewCloudCostMatchCompiler() *matcher.MatchCompiler[*CloudCost]
NewCloudCostMatchCompiler creates a new instance of a matcher.MatchCompiler[*CloudCost] which can be used to compile filter.Filter ASTs into matcher.Matcher[*CloudCost] implementations.
If storage interfaces every support querying natively by alias (e.g. if a data store contained a "product" attribute on an CloudCost row), that should be handled by a purpose-built AST compiler.
func ParseProperty ¶
func ParseProvider ¶
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
Types ¶
type AccumulateOption ¶ added in v1.102.0
type AccumulateOption string
const ( AccumulateOptionNone AccumulateOption = "" AccumulateOptionAll AccumulateOption = "all" AccumulateOptionHour AccumulateOption = "hour" AccumulateOptionDay AccumulateOption = "day" AccumulateOptionWeek AccumulateOption = "week" AccumulateOptionMonth AccumulateOption = "month" AccumulateOptionQuarter AccumulateOption = "quarter" )
func ParseAccumulate ¶ added in v1.108.0
func ParseAccumulate(acc string) AccumulateOption
ParseAccumulate converts a string to an AccumulateOption
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"` NetworkCrossZoneCost float64 `json:"networkCrossZoneCost"` // @bingen:field[version=16] NetworkCrossRegionCost float64 `json:"networkCrossRegionCost"` // @bingen:field[version=16] NetworkInternetCost float64 `json:"networkInternetCost"` // @bingen:field[version=16] NetworkCostAdjustment float64 `json:"networkCostAdjustment"` LoadBalancerCost float64 `json:"loadBalancerCost"` LoadBalancerCostAdjustment float64 `json:"loadBalancerCostAdjustment"` PVs PVAllocations `json:"pvs"` PVCostAdjustment float64 `json:"pvCostAdjustment"` RAMByteHours float64 `json:"ramByteHours"` RAMBytesRequestAverage float64 `json:"ramByteRequestAverage"` RAMBytesUsageAverage float64 `json:"ramByteUsageAverage"` RAMCost float64 `json:"ramCost"` RAMCostAdjustment float64 `json:"ramCostAdjustment"` 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"` // ProportionalAssetResourceCost represents the per-resource costs of the // allocation as a percentage of the per-resource total cost of the // asset on which the allocation was run. It is optionally computed // and appended to an Allocation, and so by default is is nil. ProportionalAssetResourceCosts ProportionalAssetResourceCosts `json:"proportionalAssetResourceCosts"` //@bingen:field[ignore] LoadBalancers LbAllocations `json:"LoadBalancers"` // @bingen:field[version=18] // UnmountedPVCost is used to track how much of the cost in PVs is for an // unmounted PV. It is not additive of PVCost() and need not be sent in API // responses. UnmountedPVCost float64 `json:"-"` }
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 TODO.
Cloud { TotalCost: 10.00, Labels{ "kubernetes_namespace":"monitoring", "env":"prod" } }
Given the following parameters, we expect to return:
single-prop full match aggregateBy = ["namespace"] => Allocation{Name: "monitoring", ExternalCost: 10.00, TotalCost: 10.00}, nil
multi-prop full match aggregateBy = ["namespace", "label:env"] allocationPropertyLabels = {"namespace":"kubernetes_namespace"} => Allocation{Name: "monitoring/env=prod", ExternalCost: 10.00, TotalCost: 10.00}, nil
multi-prop partial match aggregateBy = ["namespace", "label:foo"] => Allocation{Name: "monitoring/__unallocated__", ExternalCost: 10.00, TotalCost: 10.00}, nil
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:
single-prop full match aggregateBy = ["namespace"] allocationPropertyLabels = {"namespace":"kubernetes_namespace"} => Allocation{Name: "monitoring", ExternalCost: 10.00, TotalCost: 10.00}, nil
multi-prop full match aggregateBy = ["namespace", "label:env"] allocationPropertyLabels = {"namespace":"kubernetes_namespace"} => Allocation{Name: "monitoring/env=prod", ExternalCost: 10.00, TotalCost: 10.00}, nil
multi-prop partial match aggregateBy = ["namespace", "label:foo"] allocationPropertyLabels = {"namespace":"kubernetes_namespace"} => Allocation{Name: "monitoring/__unallocated__", ExternalCost: 10.00, TotalCost: 10.00}, nil
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) GetWindow ¶ added in v1.99.0
func (a *Allocation) GetWindow() Window
GetWindow returns the window of the struct
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) SanitizeNaN ¶ added in v1.106.0
func (a *Allocation) SanitizeNaN()
func (*Allocation) SetUnmountedPVCost ¶ added in v1.106.3
func (a *Allocation) SetUnmountedPVCost() float64
SetUnmountedPVCost determines if the Allocation is unmounted and, if so, it sets the UnmountedPVCost field appropriately.
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) StringMapProperty ¶ added in v1.99.0
func (a *Allocation) StringMapProperty(property string) (map[string]string, error)
func (*Allocation) StringProperty ¶ added in v1.99.0
func (a *Allocation) StringProperty(property string) (string, error)
func (*Allocation) StringSliceProperty ¶ added in v1.99.0
func (a *Allocation) StringSliceProperty(property string) ([]string, error)
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
func (*Allocation) UnmarshalJSON ¶ added in v1.97.0
func (a *Allocation) UnmarshalJSON(b []byte) error
UnmarshalJSON prevent nil pointer on PVAllocations
type AllocationAggregationOptions ¶
type AllocationAggregationOptions struct { AllocationTotalsStore AllocationTotalsStore Filter filter21.Filter IdleByNode bool IncludeProportionalAssetResourceCosts bool LabelConfig *LabelConfig MergeUnallocated bool Reconcile bool ReconcileNetwork bool SplitIdle bool IncludeAggregatedMetadata 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 ¶
AllocationAnnotations is a schema-free mapping of key/value pairs that can be attributed to an Allocation
type AllocationJSON ¶ added in v1.101.0
type AllocationJSON struct { Name string `json:"name"` Properties *AllocationProperties `json:"properties"` Window Window `json:"window"` Start string `json:"start"` End string `json:"end"` Minutes *float64 `json:"minutes"` CPUCores *float64 `json:"cpuCores"` CPUCoreRequestAverage *float64 `json:"cpuCoreRequestAverage"` CPUCoreUsageAverage *float64 `json:"cpuCoreUsageAverage"` CPUCoreHours *float64 `json:"cpuCoreHours"` CPUCost *float64 `json:"cpuCost"` CPUCostAdjustment *float64 `json:"cpuCostAdjustment"` CPUEfficiency *float64 `json:"cpuEfficiency"` GPUCount *float64 `json:"gpuCount"` GPUHours *float64 `json:"gpuHours"` GPUCost *float64 `json:"gpuCost"` GPUCostAdjustment *float64 `json:"gpuCostAdjustment"` NetworkTransferBytes *float64 `json:"networkTransferBytes"` NetworkReceiveBytes *float64 `json:"networkReceiveBytes"` NetworkCost *float64 `json:"networkCost"` NetworkCrossZoneCost *float64 `json:"networkCrossZoneCost"` NetworkCrossRegionCost *float64 `json:"networkCrossRegionCost"` NetworkInternetCost *float64 `json:"networkInternetCost"` NetworkCostAdjustment *float64 `json:"networkCostAdjustment"` LoadBalancerCost *float64 `json:"loadBalancerCost"` LoadBalancerCostAdjustment *float64 `json:"loadBalancerCostAdjustment"` PVBytes *float64 `json:"pvBytes"` PVByteHours *float64 `json:"pvByteHours"` PVCost *float64 `json:"pvCost"` PVs PVAllocations `json:"pvs"` PVCostAdjustment *float64 `json:"pvCostAdjustment"` RAMBytes *float64 `json:"ramBytes"` RAMByteRequestAverage *float64 `json:"ramByteRequestAverage"` RAMByteUsageAverage *float64 `json:"ramByteUsageAverage"` RAMByteHours *float64 `json:"ramByteHours"` RAMCost *float64 `json:"ramCost"` RAMCostAdjustment *float64 `json:"ramCostAdjustment"` RAMEfficiency *float64 `json:"ramEfficiency"` ExternalCost *float64 `json:"externalCost"` TotalCost *float64 `json:"totalCost"` TotalEfficiency *float64 `json:"totalEfficiency"` RawAllocationOnly *RawAllocationOnlyData `json:"rawAllocationOnly,omitempty"` ProportionalAssetResourceCosts *ProportionalAssetResourceCosts `json:"proportionalAssetResourceCosts,omitempty"` LoadBalancers LbAllocations `json:"lbAllocations"` }
AllocationJSON exists because there are expected JSON response fields that are calculated values from methods on an annotation
func (*AllocationJSON) BuildFromAllocation ¶ added in v1.101.0
func (aj *AllocationJSON) BuildFromAllocation(a *Allocation)
type AllocationLabels ¶
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 AllocationMatcher ¶ added in v1.105.0
type AllocationMatcher matcher.Matcher[*Allocation]
AllocationMatcher is a matcher implementation for Allocation instances, compiled using the matcher.MatchCompiler for allocations.
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"` NamespaceLabels AllocationLabels `json:"namespaceLabels,omitempty"` // @bingen:field[version=17] NamespaceAnnotations AllocationAnnotations `json:"namespaceAnnotations,omitempty"` // @bingen:field[version=17] // When set to true, maintain the intersection of all labels + annotations // in the aggregated AllocationProperties object AggregatedMetadata bool `json:"-"` //@bingen:field[ignore] }
AllocationProperties describes a set of Kubernetes objects.
func (*AllocationProperties) Clone ¶
func (p *AllocationProperties) Clone() *AllocationProperties
func (*AllocationProperties) Equal ¶
func (p *AllocationProperties) Equal(that *AllocationProperties) bool
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 ¶
func (p *AllocationProperties) Intersection(that *AllocationProperties) *AllocationProperties
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 AccumulateOption AggregateBy []string Compute bool DisableAggregatedStores bool Filter filter21.Filter IdleByNode bool IncludeExternal bool IncludeIdle bool LabelConfig *LabelConfig MergeUnallocated bool Reconcile bool ReconcileNetwork bool SplitIdle bool Step time.Duration }
AllocationQueryOptions defines optional parameters for querying an Allocation Store
type AllocationSet ¶
type AllocationSet struct { Allocations map[string]*Allocation ExternalKeys map[string]bool IdleKeys map[string]bool FromSource string // stores the name of the source used to compute the data Window Window Warnings []string Errors []string }
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) Accumulate ¶ added in v1.98.0
func (as *AllocationSet) Accumulate(that *AllocationSet) (*AllocationSet, error)
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) 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) GetUnmountedPVCost ¶ added in v1.106.3
func (as *AllocationSet) GetUnmountedPVCost() float64
GetUnmountedPVCost returns the sum of all UnmountedPVCost fields across all allocations in the set.
func (*AllocationSet) GetWindow ¶ added in v1.98.0
func (as *AllocationSet) GetWindow() Window
GetWindow returns the AllocationSet's window
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) 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) SanitizeNaN ¶ added in v1.106.0
func (as *AllocationSet) SanitizeNaN()
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) SetUnmountedPVCost ¶ added in v1.106.3
func (as *AllocationSet) SetUnmountedPVCost() float64
SetUnmountedPVCost sets the UnmountedPVCost field for all allocations in the set.
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 { Allocations []*AllocationSet FromStore string // stores the name of the store used to retrieve the data }
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(accumulateBy AccumulateOption) (*AllocationSetRange, error)
Accumulate sums AllocationSets based on the AccumulateOption (calendar week or calendar month). The accumulated set is determined by the start of the window of the allocation set.
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) Clone ¶ added in v1.102.0
func (asr *AllocationSetRange) Clone() *AllocationSetRange
Clone returns a new AllocationSetRange cloned from the existing ASR
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 safely 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 assets 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) StartAndEnd ¶ added in v1.97.0
StartAndEnd iterates over all AssetSets in the AssetSetRange and returns the earliest start and latest end over the entire range
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"` // UnmountedPVCost is used to track how much of the cost in // PersistentVolumeCost is for an unmounted PV. It is not additive of that // field, and need not be sent in API responses. UnmountedPVCost float64 `json:"-"` }
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) ToResponse ¶ added in v1.106.3
func (arts *AllocationTotals) ToResponse() *AllocationTotalsResponse
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 AllocationTotalsResponse ¶ added in v1.106.3
type AllocationTotalsResponse 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"` TotalCost *float64 `json:"totalCost"` }
type AllocationTotalsResult ¶ added in v1.106.3
type AllocationTotalsResult struct { Cluster map[string]*AllocationTotals `json:"cluster"` Node map[string]*AllocationTotals `json:"node"` }
func (*AllocationTotalsResult) ToResponse ¶ added in v1.106.3
func (atr *AllocationTotalsResult) ToResponse() *AllocationTotalsResultResponse
type AllocationTotalsResultResponse ¶ added in v1.106.3
type AllocationTotalsResultResponse struct { Cluster map[string]*AllocationTotalsResponse `json:"cluster"` Node map[string]*AllocationTotalsResponse `json:"node"` }
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 { Labels AssetLabels Properties *AssetProperties Start time.Time End time.Time Window Window Adjustment float64 Cost float64 }
Any is the most general Asset, which is usually created as a result of adding two Assets of different types.
func (*Any) Add ¶
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) ExpandWindow ¶
ExpandWindow expands the Asset's window by the given window
func (*Any) GetAdjustment ¶ added in v1.97.0
Adjustment returns the Asset's cost adjustment
func (*Any) GetLabels ¶ added in v1.97.0
func (a *Any) GetLabels() AssetLabels
Labels returns the Asset's labels
func (*Any) GetProperties ¶ added in v1.97.0
func (a *Any) GetProperties() *AssetProperties
Properties returns the Asset's Properties
func (*Any) InterfaceToAny ¶
Converts interface{} to Any, carrying over relevant fields
func (*Any) MarshalBinary ¶
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 ¶
MarshalJSON implements json.Marshaler
func (*Any) SanitizeNaN ¶ added in v1.106.0
func (a *Any) SanitizeNaN()
func (*Any) SetAdjustment ¶
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 ¶
SetStartEnd sets the Asset's Start and End fields
func (*Any) UnmarshalBinary ¶
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 ¶
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 // GetProperties are a map of predefined traits, which may or may not exist, // but must conform to the AssetProperty schema GetProperties() *AssetProperties SetProperties(*AssetProperties) // GetLabels are a map of undefined string-to-string values GetLabels() AssetLabels SetLabels(AssetLabels) // Monetary values GetAdjustment() float64 SetAdjustment(float64) TotalCost() float64 // Temporal values GetStart() time.Time GetEnd() time.Time SetStartEnd(time.Time, time.Time) GetWindow() Window SetWindow(Window) ExpandWindow(Window) Minutes() float64 // Operations and comparisons Add(Asset) Asset Clone() Asset Equal(Asset) bool SanitizeNaN() // 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_json.go can unmarshal a json directly from an Assets API query
type AssetAggregationOptions ¶
type AssetAggregationOptions struct { Filter filter21.Filter LabelConfig *LabelConfig }
type AssetLabels ¶
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 AssetMatcher ¶ added in v1.105.0
AssetMatcher is a matcher implementation for Asset instances, compiled using the matcher.MatchCompiler.
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 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 ¶
func (ap *AssetProperties) Merge(that *AssetProperties) *AssetProperties
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" // AssetDepartmentProp describes the department of the Asset AssetDepartmentProp AssetProperty = "department" // AssetEnvironmentProp describes the environment of the Asset AssetEnvironmentProp AssetProperty = "environment" // AssetOwnerProp describes the owner of the Asset AssetOwnerProp AssetProperty = "owner" // AssetProductProp describes the product of the Asset AssetProductProp AssetProperty = "product" // AssetTeamProp describes the team of the Asset AssetTeamProp AssetProperty = "team" )
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 Filter filter21.Filter IncludeCloud bool Step time.Duration LabelConfig *LabelConfig }
AssetQueryOptions defines optional parameters for querying an Asset Store
type AssetSet ¶
type AssetSet struct { AggregationKeys []string Assets map[string]Asset Any map[string]*Any //@bingen:field[ignore] Cloud map[string]*Cloud //@bingen:field[ignore] ClusterManagement map[string]*ClusterManagement //@bingen:field[ignore] Disks map[string]*Disk //@bingen:field[ignore] Network map[string]*Network //@bingen:field[ignore] Nodes map[string]*Node //@bingen:field[ignore] LoadBalancers map[string]*LoadBalancer //@bingen:field[ignore] FromSource string // stores the name of the source used to compute the data Window Window Warnings []string Errors []string }
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 ¶
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 ¶
GenerateMockAssetSets creates generic AssetSets
func NewAssetSet ¶
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 ¶
Clone returns a new AssetSet with a deep copy of the given AssetSet's assets.
func (*AssetSet) FindMatch ¶
func (as *AssetSet) FindMatch(query Asset, aggregateBy []string, labelConfig *LabelConfig) (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 ¶
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, labelConfig *LabelConfig) 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 ¶
IsEmpty returns true if the AssetSet is nil, or if it contains zero assets.
func (*AssetSet) MarshalBinary ¶
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 ¶
MarshalJSON JSON-encodes the AssetSet
func (*AssetSet) ReconciliationMatch ¶
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 ¶
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 ¶
Resolution returns the AssetSet's window duration
func (*AssetSet) SanitizeNaN ¶ added in v1.106.0
func (as *AssetSet) SanitizeNaN()
func (*AssetSet) Set ¶
func (as *AssetSet) Set(asset Asset, aggregateBy []string, labelConfig *LabelConfig) error
func (*AssetSet) UnmarshalBinary ¶
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 { Assets []*AssetSet FromStore string // stores the name of the store used to retrieve the data }
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(accumulateBy AccumulateOption) (*AssetSetRange, error)
func (*AssetSetRange) AccumulateToAssetSet ¶ added in v1.102.0
func (asr *AssetSetRange) AccumulateToAssetSet() (*AssetSet, error)
func (*AssetSetRange) AggregateBy ¶
func (asr *AssetSetRange) AggregateBy(aggregateBy []string, opts *AssetAggregationOptions) error
func (*AssetSetRange) Append ¶
func (asr *AssetSetRange) Append(that *AssetSet)
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)
Get provides bounds checked access into the AssetSetRange's AssetSets.
func (*AssetSetRange) GetWarnings ¶ added in v1.101.0
func (asr *AssetSetRange) GetWarnings() []string
func (*AssetSetRange) HasWarnings ¶ added in v1.101.0
func (asr *AssetSetRange) HasWarnings() bool
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
Length returns the total number of AssetSets in the range.
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) StartAndEnd ¶ added in v1.97.0
Each iterates over all AssetSets in the AssetSetRange and returns the start and end over the entire range
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 ¶
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"` PrivateLoadBalancer bool `json:"privateLoadBalancer"` }
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 AssetTotalsResult ¶ added in v1.106.3
type AssetTotalsResult struct { Cluster map[string]*AssetTotals `json:"cluster"` Node map[string]*AssetTotals `json:"node"` }
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 )
func ParseAssetType ¶
ParseAssetType attempts to parse the given string into an AssetType
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 ¶
func NewBoundaryError ¶
func NewBoundaryError(req, sup Window, msg string) *BoundaryError
func (*BoundaryError) Error ¶
func (be *BoundaryError) Error() string
func (*BoundaryError) Is ¶ added in v1.107.0
func (be *BoundaryError) Is(target error) bool
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) MarshalBinary ¶
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) SanitizeNaN ¶ added in v1.106.0
func (b *Breakdown) SanitizeNaN()
func (*Breakdown) UnmarshalBinary ¶
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 { Labels AssetLabels Properties *AssetProperties Start time.Time End time.Time Window Window Adjustment float64 Cost float64 Credit float64 // Credit is a negative value representing dollars credited back to a given line-item }
Cloud describes a cloud asset
func (*Cloud) Add ¶
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) ExpandWindow ¶
ExpandWindow expands the Asset's window by the given window
func (*Cloud) GetAdjustment ¶ added in v1.97.0
Adjustment returns the Asset's adjustment value
func (*Cloud) GetLabels ¶ added in v1.97.0
func (ca *Cloud) GetLabels() AssetLabels
Labels returns the AssetLabels
func (*Cloud) GetProperties ¶ added in v1.97.0
func (ca *Cloud) GetProperties() *AssetProperties
Properties returns the AssetProperties
func (*Cloud) GetStart ¶ added in v1.97.0
Start returns the Asset's precise start time within the window
func (*Cloud) InterfaceToCloud ¶
Converts interface{} to Cloud, carrying over relevant fields
func (*Cloud) MarshalBinary ¶
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 ¶
MarshalJSON implements json.Marshaler
func (*Cloud) SanitizeNaN ¶ added in v1.106.0
func (ca *Cloud) SanitizeNaN()
func (*Cloud) SetAdjustment ¶
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 ¶
SetStartEnd sets the Asset's Start and End fields
func (*Cloud) UnmarshalBinary ¶
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 ¶
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 CloudCost ¶ added in v1.103.0
type CloudCost struct { Properties *CloudCostProperties `json:"properties"` Window Window `json:"window"` ListCost CostMetric `json:"listCost"` NetCost CostMetric `json:"netCost"` AmortizedNetCost CostMetric `json:"amortizedNetCost"` InvoicedCost CostMetric `json:"invoicedCost"` AmortizedCost CostMetric `json:"amortizedCost"` }
CloudCost represents a CUR line item, identifying a cloud resource and its cost over some period of time.
func NewCloudCost ¶ added in v1.103.0
func NewCloudCost(start, end time.Time, ccProperties *CloudCostProperties, kubernetesPercent, listCost, netCost, amortizedNetCost, invoicedCost, amortizedCost float64) *CloudCost
NewCloudCost instantiates a new CloudCost
func (*CloudCost) GetCostMetric ¶ added in v1.103.0
func (cc *CloudCost) GetCostMetric(costMetricName CostMetricName) (CostMetric, error)
func (*CloudCost) MarshalBinary ¶ added in v1.103.0
MarshalBinary serializes the internal properties of this CloudCost instance into a byte array
func (*CloudCost) MarshalBinaryWithContext ¶ added in v1.103.0
func (target *CloudCost) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
MarshalBinaryWithContext serializes the internal properties of this CloudCost instance into a byte array leveraging a predefined context.
func (*CloudCost) StringMapProperty ¶ added in v1.103.0
func (*CloudCost) StringProperty ¶ added in v1.103.0
func (*CloudCost) UnmarshalBinary ¶ added in v1.103.0
UnmarshalBinary uses the data passed byte array to set all the internal properties of the CloudCost type
func (*CloudCost) UnmarshalBinaryWithContext ¶ added in v1.103.0
func (target *CloudCost) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the CloudCost type
func (*CloudCost) WeightCostMetrics ¶ added in v1.106.3
WeightCostMetrics weights all the cost metrics with the given weightedAverage
type CloudCostLabels ¶ added in v1.103.0
func (CloudCostLabels) Clone ¶ added in v1.103.0
func (ccl CloudCostLabels) Clone() CloudCostLabels
func (CloudCostLabels) Equal ¶ added in v1.103.0
func (ccl CloudCostLabels) Equal(that CloudCostLabels) bool
func (CloudCostLabels) Intersection ¶ added in v1.103.0
func (ccl CloudCostLabels) Intersection(that CloudCostLabels) CloudCostLabels
Intersection returns the set of labels that have the same key and value in the receiver and arg
type CloudCostMatcher ¶ added in v1.107.0
CloudCostMatcher is a matcher implementation for CloudCost instances, compiled using the matcher.MatchCompiler for cloud costs.
type CloudCostProperties ¶ added in v1.103.0
type CloudCostProperties struct { ProviderID string `json:"providerID,omitempty"` Provider string `json:"provider,omitempty"` AccountID string `json:"accountID,omitempty"` InvoiceEntityID string `json:"invoiceEntityID,omitempty"` Service string `json:"service,omitempty"` Category string `json:"category,omitempty"` Labels CloudCostLabels `json:"labels,omitempty"` }
func (*CloudCostProperties) Clone ¶ added in v1.103.0
func (ccp *CloudCostProperties) Clone() *CloudCostProperties
func (*CloudCostProperties) Equal ¶ added in v1.103.0
func (ccp *CloudCostProperties) Equal(that *CloudCostProperties) bool
func (*CloudCostProperties) GenerateKey ¶ added in v1.103.0
func (ccp *CloudCostProperties) GenerateKey(props []string) string
GenerateKey takes a list of properties and creates a "/" seperated key based on the values of the requested properties. Invalid values are ignored with a warning. A nil input returns the default key, while an empty slice returns the empty string
func (*CloudCostProperties) Intersection ¶ added in v1.103.0
func (ccp *CloudCostProperties) Intersection(that *CloudCostProperties) *CloudCostProperties
Intersection ensure the values of two CloudCostAggregateProperties are maintain only if they are equal
func (*CloudCostProperties) MarshalBinary ¶ added in v1.103.0
func (target *CloudCostProperties) MarshalBinary() (data []byte, err error)
MarshalBinary serializes the internal properties of this CloudCostProperties instance into a byte array
func (*CloudCostProperties) MarshalBinaryWithContext ¶ added in v1.103.0
func (target *CloudCostProperties) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
MarshalBinaryWithContext serializes the internal properties of this CloudCostProperties instance into a byte array leveraging a predefined context.
func (*CloudCostProperties) UnmarshalBinary ¶ added in v1.103.0
func (target *CloudCostProperties) UnmarshalBinary(data []byte) error
UnmarshalBinary uses the data passed byte array to set all the internal properties of the CloudCostProperties type
func (*CloudCostProperties) UnmarshalBinaryWithContext ¶ added in v1.103.0
func (target *CloudCostProperties) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the CloudCostProperties type
type CloudCostSet ¶ added in v1.103.0
type CloudCostSet struct { CloudCosts map[string]*CloudCost `json:"cloudCosts"` Window Window `json:"window"` Integration string `json:"-"` AggregationProperties []string `json:"aggregationProperties"` }
CloudCostSet follows the established set pattern of windowed data types. It has addition metadata types that can be used to preserve data consistency and be used for validation. - Integration is the ID for the integration that a CloudCostSet was sourced from, this value is cleared if when a set is joined with another with a different key - AggregationProperties is set by the Aggregate function and ensures that any additional inserts are keyed correctly
func NewCloudCostSet ¶ added in v1.103.0
func NewCloudCostSet(start, end time.Time, cloudCosts ...*CloudCost) *CloudCostSet
NewCloudCostSet instantiates a new CloudCostSet and, optionally, inserts the given list of CloudCosts
func (*CloudCostSet) Accumulate ¶ added in v1.103.0
func (ccs *CloudCostSet) Accumulate(that *CloudCostSet) (*CloudCostSet, error)
func (*CloudCostSet) Aggregate ¶ added in v1.103.0
func (ccs *CloudCostSet) Aggregate(props []string) (*CloudCostSet, error)
func (*CloudCostSet) Clone ¶ added in v1.103.0
func (ccs *CloudCostSet) Clone() *CloudCostSet
func (*CloudCostSet) Equal ¶ added in v1.103.0
func (ccs *CloudCostSet) Equal(that *CloudCostSet) bool
func (*CloudCostSet) Filter ¶ added in v1.103.0
func (ccs *CloudCostSet) Filter(filters filter.Filter[*CloudCost]) *CloudCostSet
func (*CloudCostSet) Filter21 ¶ added in v1.107.0
func (ccs *CloudCostSet) Filter21(filters filter21.Filter) (*CloudCostSet, error)
func (*CloudCostSet) GetWindow ¶ added in v1.103.0
func (ccs *CloudCostSet) GetWindow() Window
func (*CloudCostSet) Insert ¶ added in v1.103.0
func (ccs *CloudCostSet) Insert(cc *CloudCost) error
Insert adds a CloudCost to a CloudCostSet using its AggregationProperties and LabelConfig to determine the key where it will be inserted
func (*CloudCostSet) IsEmpty ¶ added in v1.103.0
func (ccs *CloudCostSet) IsEmpty() bool
func (*CloudCostSet) Length ¶ added in v1.103.0
func (ccs *CloudCostSet) Length() int
func (*CloudCostSet) MarshalBinary ¶ added in v1.103.0
func (target *CloudCostSet) MarshalBinary() (data []byte, err error)
MarshalBinary serializes the internal properties of this CloudCostSet instance into a byte array
func (*CloudCostSet) MarshalBinaryWithContext ¶ added in v1.103.0
func (target *CloudCostSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
MarshalBinaryWithContext serializes the internal properties of this CloudCostSet instance into a byte array leveraging a predefined context.
func (*CloudCostSet) Merge ¶ added in v1.103.0
func (ccs *CloudCostSet) Merge(that *CloudCostSet) (*CloudCostSet, error)
func (*CloudCostSet) UnmarshalBinary ¶ added in v1.103.0
func (target *CloudCostSet) UnmarshalBinary(data []byte) error
UnmarshalBinary uses the data passed byte array to set all the internal properties of the CloudCostSet type
func (*CloudCostSet) UnmarshalBinaryWithContext ¶ added in v1.103.0
func (target *CloudCostSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the CloudCostSet type
type CloudCostSetRange ¶ added in v1.103.0
type CloudCostSetRange struct { CloudCostSets []*CloudCostSet `json:"sets"` Window Window `json:"window"` }
func NewCloudCostSetRange ¶ added in v1.103.0
func NewCloudCostSetRange(start time.Time, end time.Time, accumOpt AccumulateOption, integration string) (*CloudCostSetRange, error)
NewCloudCostSetRange create a CloudCostSetRange containing CloudCostSets with windows of equal duration the duration between start and end must be divisible by the window duration argument
func (*CloudCostSetRange) Accumulate ¶ added in v1.103.0
func (ccsr *CloudCostSetRange) Accumulate(accumulateBy AccumulateOption) (*CloudCostSetRange, error)
Accumulate sums CloudCostSets based on the AccumulateOption (calendar week or calendar month). The accumulated set is determined by the start of the window of the allocation set.
func (*CloudCostSetRange) AccumulateAll ¶ added in v1.108.0
func (ccsr *CloudCostSetRange) AccumulateAll() (*CloudCostSet, error)
accumulate sums each CloudCostSet in the given range, returning a single cumulative CloudCostSet for the entire range.
func (*CloudCostSetRange) Append ¶ added in v1.108.0
func (ccsr *CloudCostSetRange) Append(that *CloudCostSet)
Append appends the given CloudCostSet to the end of the range. It does not validate whether or not that violates window continuity.
func (*CloudCostSetRange) Clone ¶ added in v1.103.0
func (ccsr *CloudCostSetRange) Clone() *CloudCostSetRange
func (*CloudCostSetRange) IsEmpty ¶ added in v1.103.0
func (ccsr *CloudCostSetRange) IsEmpty() bool
func (*CloudCostSetRange) LoadCloudCost ¶ added in v1.103.0
func (ccsr *CloudCostSetRange) LoadCloudCost(cloudCost *CloudCost)
LoadCloudCost loads CloudCosts into existing CloudCostSets of the CloudCostSetRange. This function service to aggregate and distribute costs over predefined windows are accumulated here so that the resulting CloudCost with the 1d window has the correct price for the entire day. If all or a portion of the window of the CloudCost is outside of the windows of the existing CloudCostSets, that portion of the CloudCost's cost will not be inserted
func (*CloudCostSetRange) MarshalBinary ¶ added in v1.103.0
func (target *CloudCostSetRange) MarshalBinary() (data []byte, err error)
MarshalBinary serializes the internal properties of this CloudCostSetRange instance into a byte array
func (*CloudCostSetRange) MarshalBinaryWithContext ¶ added in v1.103.0
func (target *CloudCostSetRange) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
MarshalBinaryWithContext serializes the internal properties of this CloudCostSetRange instance into a byte array leveraging a predefined context.
func (*CloudCostSetRange) UnmarshalBinary ¶ added in v1.103.0
func (target *CloudCostSetRange) UnmarshalBinary(data []byte) error
UnmarshalBinary uses the data passed byte array to set all the internal properties of the CloudCostSetRange type
func (*CloudCostSetRange) UnmarshalBinaryWithContext ¶ added in v1.103.0
func (target *CloudCostSetRange) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the CloudCostSetRange type
type CloudStatus ¶
type CloudStatus struct { ConnectionStatus 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 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 Filter filter21.Filter FilterValues CloudUsageFilter LabelConfig *LabelConfig }
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 { Labels AssetLabels Properties *AssetProperties Window Window Cost float64 Adjustment float64 // @bingen:field[version=16] }
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) Clone ¶
func (cm *ClusterManagement) Clone() Asset
Clone returns a cloned instance of the Asset
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) GetAdjustment ¶ added in v1.97.0
func (cm *ClusterManagement) GetAdjustment() float64
Adjustment does not apply to ClusterManagement
func (*ClusterManagement) GetEnd ¶ added in v1.97.0
func (cm *ClusterManagement) GetEnd() time.Time
End returns the Asset's precise end time within the window
func (*ClusterManagement) GetLabels ¶ added in v1.97.0
func (cm *ClusterManagement) GetLabels() AssetLabels
Labels returns the Asset's labels
func (*ClusterManagement) GetProperties ¶ added in v1.97.0
func (cm *ClusterManagement) GetProperties() *AssetProperties
Properties returns the Asset's Properties
func (*ClusterManagement) GetStart ¶ added in v1.97.0
func (cm *ClusterManagement) GetStart() time.Time
Start returns the Asset's precise start time within the window
func (*ClusterManagement) GetWindow ¶ added in v1.97.0
func (cm *ClusterManagement) GetWindow() Window
Window return the Asset's window
func (*ClusterManagement) InterfaceToClusterManagement ¶
func (cm *ClusterManagement) InterfaceToClusterManagement(itf interface{}) error
Converts interface{} to ClusterManagement, carrying over relevant fields
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) SanitizeNaN ¶ added in v1.106.0
func (cm *ClusterManagement) SanitizeNaN()
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) SetWindow ¶ added in v1.97.0
func (cm *ClusterManagement) SetWindow(window 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
type CostMetric ¶ added in v1.103.0
type CostMetric struct { Cost float64 `json:"cost"` KubernetesPercent float64 `json:"kubernetesPercent"` }
CostMetric is a container for values associated with a specific accounting method
func (CostMetric) Clone ¶ added in v1.103.0
func (cm CostMetric) Clone() CostMetric
func (CostMetric) Equal ¶ added in v1.103.0
func (cm CostMetric) Equal(that CostMetric) bool
func (*CostMetric) MarshalBinary ¶ added in v1.103.0
func (target *CostMetric) MarshalBinary() (data []byte, err error)
MarshalBinary serializes the internal properties of this CostMetric instance into a byte array
func (*CostMetric) MarshalBinaryWithContext ¶ added in v1.103.0
func (target *CostMetric) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
MarshalBinaryWithContext serializes the internal properties of this CostMetric instance into a byte array leveraging a predefined context.
func (*CostMetric) UnmarshalBinary ¶ added in v1.103.0
func (target *CostMetric) UnmarshalBinary(data []byte) error
UnmarshalBinary uses the data passed byte array to set all the internal properties of the CostMetric type
func (*CostMetric) UnmarshalBinaryWithContext ¶ added in v1.103.0
func (target *CostMetric) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the CostMetric type
type CostMetricName ¶ added in v1.108.0
type CostMetricName string
CostMetricName a string type that acts as an enumeration of possible CostMetric options
const ( CostMetricNone CostMetricName = "" CostMetricListCost CostMetricName = "listCost" CostMetricNetCost CostMetricName = "netCost" CostMetricAmortizedNetCost CostMetricName = "amortizedNetCost" CostMetricInvoicedCost CostMetricName = "invoicedCost" CostMetricAmortizedCost CostMetricName = "amortizedCost" )
func ParseCostMetricName ¶ added in v1.108.0
func ParseCostMetricName(costMetric string) (CostMetricName, error)
ParseCostMetricName provides a resilient way to parse one of the enumerated CostMetricName types from a string or throws an error if it is not able to.
type Coverage ¶ added in v1.99.0
type Coverage struct { Window Window `json:"window"` Type string `json:"type"` Count int `json:"count"` Updated time.Time `json:"updated"` Errors []string `json:"errors"` Warnings []string `json:"warnings"` }
Coverage This is a placeholder struct which can be replaced by a more specific implementation later
func (*Coverage) MarshalBinary ¶ added in v1.99.0
MarshalBinary serializes the internal properties of this Coverage instance into a byte array
func (*Coverage) MarshalBinaryWithContext ¶ added in v1.99.0
func (target *Coverage) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
MarshalBinaryWithContext serializes the internal properties of this Coverage instance into a byte array leveraging a predefined context.
func (*Coverage) UnmarshalBinary ¶ added in v1.99.0
UnmarshalBinary uses the data passed byte array to set all the internal properties of the Coverage type
func (*Coverage) UnmarshalBinaryWithContext ¶ added in v1.99.0
func (target *Coverage) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the Coverage type
type CoverageSet ¶ added in v1.99.0
Coverage This is a placeholder struct which can be replaced by a more specific implementation later
func NewCoverageSet ¶ added in v1.99.0
func NewCoverageSet(start, end time.Time) *CoverageSet
func (*CoverageSet) Clone ¶ added in v1.99.0
func (cs *CoverageSet) Clone() *CoverageSet
func (*CoverageSet) Filter ¶ added in v1.99.0
func (cs *CoverageSet) Filter(filters filter.Filter[*Coverage]) *CoverageSet
func (*CoverageSet) GetWindow ¶ added in v1.99.0
func (cs *CoverageSet) GetWindow() Window
func (*CoverageSet) Insert ¶ added in v1.99.0
func (cs *CoverageSet) Insert(coverage *Coverage)
func (*CoverageSet) IsEmpty ¶ added in v1.99.0
func (cs *CoverageSet) IsEmpty() bool
func (*CoverageSet) MarshalBinary ¶ added in v1.99.0
func (target *CoverageSet) MarshalBinary() (data []byte, err error)
MarshalBinary serializes the internal properties of this CoverageSet instance into a byte array
func (*CoverageSet) MarshalBinaryWithContext ¶ added in v1.99.0
func (target *CoverageSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
MarshalBinaryWithContext serializes the internal properties of this CoverageSet instance into a byte array leveraging a predefined context.
func (*CoverageSet) UnmarshalBinary ¶ added in v1.99.0
func (target *CoverageSet) UnmarshalBinary(data []byte) error
UnmarshalBinary uses the data passed byte array to set all the internal properties of the CoverageSet type
func (*CoverageSet) UnmarshalBinaryWithContext ¶ added in v1.99.0
func (target *CoverageSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the CoverageSet type
type DecodingContext ¶
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 ¶
Diff stores an object and a string that denotes whether that object was added or removed from a set of those objects
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 { Labels AssetLabels Properties *AssetProperties Start time.Time End time.Time Window Window Adjustment float64 Cost float64 ByteHours float64 Local float64 Breakdown *Breakdown StorageClass string // @bingen:field[version=17] ByteHoursUsed *float64 // @bingen:field[version=18] ByteUsageMax *float64 // @bingen:field[version=18] VolumeName string // @bingen:field[version=18] ClaimName string // @bingen:field[version=18] ClaimNamespace string // @bingen:field[version=18] }
Disk represents an in-cluster disk Asset
func (*Disk) Add ¶
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) Bytes ¶
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) ExpandWindow ¶
ExpandWindow expands the Asset's window by the given window
func (*Disk) GetAdjustment ¶ added in v1.97.0
Adjustment returns the Asset's cost adjustment
func (*Disk) GetEnd ¶ added in v1.97.0
End returns the precise start time of the Asset within the window
func (*Disk) GetLabels ¶ added in v1.97.0
func (d *Disk) GetLabels() AssetLabels
Labels returns the Asset's labels
func (*Disk) GetProperties ¶ added in v1.97.0
func (d *Disk) GetProperties() *AssetProperties
Properties returns the Asset's Properties
func (*Disk) GetStart ¶ added in v1.97.0
Start returns the precise start time of the Asset within the window
func (*Disk) InterfaceToDisk ¶
Converts interface{} to Disk, carrying over relevant fields
func (*Disk) MarshalBinary ¶
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 ¶
MarshalJSON implements the json.Marshaler interface
func (*Disk) SanitizeNaN ¶ added in v1.106.0
func (d *Disk) SanitizeNaN()
func (*Disk) SetAdjustment ¶
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 ¶
SetStartEnd sets the Asset's Start and End fields
func (*Disk) UnmarshalBinary ¶
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 ¶
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 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 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 LbAllocation ¶ added in v1.105.0
type LbAllocation struct { Service string `json:"service"` Cost float64 `json:"cost"` Private bool `json:"private"` Ip string `json:"ip"` //@bingen:field[version=19] }
func (*LbAllocation) MarshalBinary ¶ added in v1.105.0
func (target *LbAllocation) MarshalBinary() (data []byte, err error)
MarshalBinary serializes the internal properties of this LbAllocation instance into a byte array
func (*LbAllocation) MarshalBinaryWithContext ¶ added in v1.105.0
func (target *LbAllocation) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
MarshalBinaryWithContext serializes the internal properties of this LbAllocation instance into a byte array leveraging a predefined context.
func (*LbAllocation) SanitizeNaN ¶ added in v1.106.0
func (lba *LbAllocation) SanitizeNaN()
func (*LbAllocation) UnmarshalBinary ¶ added in v1.105.0
func (target *LbAllocation) UnmarshalBinary(data []byte) error
UnmarshalBinary uses the data passed byte array to set all the internal properties of the LbAllocation type
func (*LbAllocation) UnmarshalBinaryWithContext ¶ added in v1.105.0
func (target *LbAllocation) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the LbAllocation type
type LbAllocations ¶ added in v1.105.0
type LbAllocations map[string]*LbAllocation
func (LbAllocations) Add ¶ added in v1.105.0
func (thisLbAllocs LbAllocations) Add(thatLbAllocs LbAllocations) LbAllocations
func (LbAllocations) Clone ¶ added in v1.105.0
func (orig LbAllocations) Clone() LbAllocations
func (LbAllocations) SanitizeNaN ¶ added in v1.106.0
func (thisLbAllocs LbAllocations) SanitizeNaN()
type LoadBalancer ¶
type LoadBalancer struct { Properties *AssetProperties Labels AssetLabels Start time.Time End time.Time Window Window Adjustment float64 Cost float64 Private bool // @bingen:field[version=20] Ip string // @bingen:field[version=21] }
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, private bool, ip string) *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) Clone ¶
func (lb *LoadBalancer) Clone() Asset
Clone returns a cloned instance of the given Asset
func (*LoadBalancer) Equal ¶
func (lb *LoadBalancer) Equal(a Asset) bool
Equal returns true if the two Assets match precisely
func (*LoadBalancer) ExpandWindow ¶
func (lb *LoadBalancer) ExpandWindow(w Window)
ExpandWindow expands the Asset's window by the given window
func (*LoadBalancer) GetAdjustment ¶ added in v1.97.0
func (lb *LoadBalancer) GetAdjustment() float64
Adjustment returns the Asset's cost adjustment
func (*LoadBalancer) GetEnd ¶ added in v1.97.0
func (lb *LoadBalancer) GetEnd() time.Time
End returns the preceise end point of the Asset within the window
func (*LoadBalancer) GetLabels ¶ added in v1.97.0
func (lb *LoadBalancer) GetLabels() AssetLabels
Labels returns the Asset's labels
func (*LoadBalancer) GetProperties ¶ added in v1.97.0
func (lb *LoadBalancer) GetProperties() *AssetProperties
Properties returns the Asset's Properties
func (*LoadBalancer) GetStart ¶ added in v1.97.0
func (lb *LoadBalancer) GetStart() time.Time
Start returns the preceise start point of the Asset within the window
func (*LoadBalancer) GetWindow ¶ added in v1.97.0
func (lb *LoadBalancer) GetWindow() Window
Window returns the window within which the Asset ran
func (*LoadBalancer) InterfaceToLoadBalancer ¶
func (lb *LoadBalancer) InterfaceToLoadBalancer(itf interface{}) error
Converts interface{} to LoadBalancer, carrying over relevant fields
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) SanitizeNaN ¶ added in v1.106.0
func (lb *LoadBalancer) SanitizeNaN()
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) SetWindow ¶ added in v1.97.0
func (lb *LoadBalancer) SetWindow(window 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
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 { Properties *AssetProperties Labels AssetLabels Start time.Time End time.Time Window Window Adjustment float64 Cost float64 }
Network is an Asset representing a single node's network costs
func NewNetwork ¶
NewNetwork creates and returns a new Network Asset
func (*Network) Add ¶
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) ExpandWindow ¶
ExpandWindow expands the Asset's window by the given window
func (*Network) GetAdjustment ¶ added in v1.97.0
Adjustment returns the Asset's cost adjustment
func (*Network) GetEnd ¶ added in v1.97.0
End returns the precise end time of the Asset within the window
func (*Network) GetLabels ¶ added in v1.97.0
func (n *Network) GetLabels() AssetLabels
Labels returns the Asset's labels
func (*Network) GetProperties ¶ added in v1.97.0
func (n *Network) GetProperties() *AssetProperties
Properties returns the Asset's Properties
func (*Network) GetStart ¶ added in v1.97.0
Start returns the precise start time of the Asset within the window
func (*Network) InterfaceToNetwork ¶
Converts interface{} to Network, carrying over relevant fields
func (*Network) MarshalBinary ¶
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 ¶
MarshalJSON implements json.Marshal interface
func (*Network) SanitizeNaN ¶ added in v1.106.0
func (n *Network) SanitizeNaN()
func (*Network) SetAdjustment ¶
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 ¶
SetStartEnd sets the Asset's Start and End fields
func (*Network) UnmarshalBinary ¶
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 ¶
type Node ¶
type Node struct { Properties *AssetProperties Labels AssetLabels Start time.Time End time.Time Window Window Adjustment float64 NodeType string CPUCoreHours float64 RAMByteHours float64 GPUHours float64 CPUBreakdown *Breakdown RAMBreakdown *Breakdown CPUCost float64 GPUCost float64 GPUCount float64 RAMCost float64 Discount float64 Preemptible float64 Overhead *NodeOverhead // @bingen:field[version=19] }
Node is an Asset representing a single node in a cluster
func (*Node) Add ¶
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) CPUCores ¶
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) ExpandWindow ¶
ExpandWindow expands the Asset's window by the given window
func (*Node) GPUs ¶
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) GetAdjustment ¶ added in v1.97.0
Adjustment returns the Asset's cost adjustment
func (*Node) GetEnd ¶ added in v1.97.0
End returns the precise end time of the Asset within the window
func (*Node) GetLabels ¶ added in v1.97.0
func (n *Node) GetLabels() AssetLabels
Labels returns the Asset's labels
func (*Node) GetProperties ¶ added in v1.97.0
func (n *Node) GetProperties() *AssetProperties
Properties returns the Asset's Properties
func (*Node) GetStart ¶ added in v1.97.0
Start returns the precise start time of the Asset within the window
func (*Node) InterfaceToNode ¶
Converts interface{} to Node, carrying over relevant fields
func (*Node) IsPreemptible ¶
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) MarshalBinary ¶
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 ¶
MarshalJSON implements json.Marshal interface
func (*Node) RAMBytes ¶
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) SanitizeNaN ¶ added in v1.106.0
func (n *Node) SanitizeNaN()
func (*Node) SetAdjustment ¶
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 ¶
SetStartEnd sets the Asset's Start and End fields
func (*Node) UnmarshalBinary ¶
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 ¶
type NodeOverhead ¶ added in v1.104.0
type NodeOverhead struct { CpuOverheadFraction float64 RamOverheadFraction float64 OverheadCostFraction float64 }
NodeOverhead represents the delta between the allocatable resources of the node and the node nameplate capacity
func (*NodeOverhead) Clone ¶ added in v1.107.0
func (n *NodeOverhead) Clone() *NodeOverhead
func (*NodeOverhead) Equal ¶ added in v1.107.0
func (n *NodeOverhead) Equal(other *NodeOverhead) bool
func (*NodeOverhead) MarshalBinary ¶ added in v1.104.0
func (target *NodeOverhead) MarshalBinary() (data []byte, err error)
MarshalBinary serializes the internal properties of this NodeOverhead instance into a byte array
func (*NodeOverhead) MarshalBinaryWithContext ¶ added in v1.104.0
func (target *NodeOverhead) MarshalBinaryWithContext(ctx *EncodingContext) (err error)
MarshalBinaryWithContext serializes the internal properties of this NodeOverhead instance into a byte array leveraging a predefined context.
func (*NodeOverhead) SanitizeNaN ¶ added in v1.106.0
func (n *NodeOverhead) SanitizeNaN()
func (*NodeOverhead) UnmarshalBinary ¶ added in v1.104.0
func (target *NodeOverhead) UnmarshalBinary(data []byte) error
UnmarshalBinary uses the data passed byte array to set all the internal properties of the NodeOverhead type
func (*NodeOverhead) UnmarshalBinaryWithContext ¶ added in v1.104.0
func (target *NodeOverhead) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error)
UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of the NodeOverhead type
type PVAllocation ¶
type PVAllocation struct { ByteHours float64 `json:"byteHours"` Cost float64 `json:"cost"` ProviderID string `json:"providerID"` // @bingen:field[version=20] }
PVAllocation contains the byte hour usage and cost of an Allocation for a single PV
func (*PVAllocation) Equal ¶ added in v1.97.0
func (pva *PVAllocation) Equal(that *PVAllocation) bool
Equal returns true if the two PVAllocation instances contain approximately the same values.
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) SanitizeNaN ¶ added in v1.106.0
func (pva *PVAllocation) SanitizeNaN()
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 ¶
func (pv PVAllocations) Add(that PVAllocations) PVAllocations
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
func (PVAllocations) Equal ¶ added in v1.97.0
func (this PVAllocations) Equal(that PVAllocations) bool
Equal returns true if the two PVAllocations are equal in length and contain the same keys and values.
func (PVAllocations) MarshalJSON ¶ added in v1.97.0
func (pv PVAllocations) MarshalJSON() (b []byte, err error)
MarshalJSON marshals PVAllocation as map[*PVKey]*PVAllocation this allows PVKey to retain its values through marshalling
func (PVAllocations) SanitizeNaN ¶ added in v1.106.0
func (pvs PVAllocations) SanitizeNaN()
type PVKey ¶
PVKey for identifying Disk type assets
func (*PVKey) FromString ¶ added in v1.97.0
FromString populates PVKey fields from string
func (*PVKey) MarshalBinary ¶
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) MarshalText ¶ added in v1.97.0
MarshalText converts PVKey to string to make it compatible with JSON Marshaller as an Object key this function is required to have a value caller for the actual values to be saved
func (*PVKey) UnmarshalBinary ¶
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
func (*PVKey) UnmarshalText ¶ added in v1.97.0
UnmarshalText converts JSON key string to PVKey it compatible with JSON Unmarshaller from an Object key this function is required to have a pointer caller for values to be pulled into marshalling struct
type Pair ¶
Pair is a generic struct containing a pair of instances, one of each type similar to std::pair
type ProportionalAssetResourceCost ¶ added in v1.103.0
type ProportionalAssetResourceCost struct { Cluster string `json:"cluster"` Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` ProviderID string `json:"providerID,omitempty"` CPUPercentage float64 `json:"cpuPercentage"` GPUPercentage float64 `json:"gpuPercentage"` RAMPercentage float64 `json:"ramPercentage"` LoadBalancerPercentage float64 `json:"loadBalancerPercentage"` PVPercentage float64 `json:"pvPercentage"` NodeResourceCostPercentage float64 `json:"nodeResourceCostPercentage"` GPUTotalCost float64 `json:"-"` GPUProportionalCost float64 `json:"-"` CPUTotalCost float64 `json:"-"` CPUProportionalCost float64 `json:"-"` RAMTotalCost float64 `json:"-"` RAMProportionalCost float64 `json:"-"` LoadBalancerProportionalCost float64 `json:"-"` LoadBalancerTotalCost float64 `json:"-"` PVProportionalCost float64 `json:"-"` PVTotalCost float64 `json:"-"` }
func (ProportionalAssetResourceCost) Key ¶ added in v1.103.0
func (parc ProportionalAssetResourceCost) Key(insertByName bool) string
type ProportionalAssetResourceCosts ¶ added in v1.103.0
type ProportionalAssetResourceCosts map[string]ProportionalAssetResourceCost
func (ProportionalAssetResourceCosts) Add ¶ added in v1.103.0
func (parcs ProportionalAssetResourceCosts) Add(that ProportionalAssetResourceCosts)
func (ProportionalAssetResourceCosts) Clone ¶ added in v1.104.0
func (parcs ProportionalAssetResourceCosts) Clone() ProportionalAssetResourceCosts
func (ProportionalAssetResourceCosts) Insert ¶ added in v1.103.0
func (parcs ProportionalAssetResourceCosts) Insert(parc ProportionalAssetResourceCost, insertByName bool)
func (ProportionalAssetResourceCosts) SanitizeNaN ¶ added in v1.106.0
func (parcs ProportionalAssetResourceCosts) SanitizeNaN()
type Querier ¶
type Querier interface { AllocationQuerier SummaryAllocationQuerier AssetQuerier CloudUsageQuerier }
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 ¶
func (r *RawAllocationOnlyData) Clone() *RawAllocationOnlyData
Clone returns a deep copy of the given RawAllocationOnlyData
func (*RawAllocationOnlyData) Equal ¶ added in v1.97.0
func (r *RawAllocationOnlyData) Equal(that *RawAllocationOnlyData) bool
Equal returns true if the RawAllocationOnlyData is approximately equal
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) SanitizeNaN ¶ added in v1.106.0
func (r *RawAllocationOnlyData) SanitizeNaN()
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 SharedAsset ¶
type SharedAsset struct {}
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) Clone ¶
func (sa *SharedAsset) Clone() Asset
Clone returns a deep copy of the given SharedAsset
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) GetAdjustment ¶ added in v1.97.0
func (sa *SharedAsset) GetAdjustment() float64
Adjustment is not relevant to SharedAsset, but required to implement Asset
func (*SharedAsset) GetEnd ¶ added in v1.97.0
func (sa *SharedAsset) GetEnd() time.Time
End returns the end time of the Asset
func (*SharedAsset) GetLabels ¶ added in v1.97.0
func (sa *SharedAsset) GetLabels() AssetLabels
Labels returns the Asset's labels
func (*SharedAsset) GetProperties ¶ added in v1.97.0
func (sa *SharedAsset) GetProperties() *AssetProperties
Properties returns the Asset's Properties
func (*SharedAsset) GetStart ¶ added in v1.97.0
func (sa *SharedAsset) GetStart() time.Time
Start returns the start time of the Asset
func (*SharedAsset) GetWindow ¶ added in v1.97.0
func (sa *SharedAsset) GetWindow() Window
Window returns the window within the SharedAsset ran
func (*SharedAsset) InterfaceToSharedAsset ¶
func (sa *SharedAsset) InterfaceToSharedAsset(itf interface{}) error
Converts interface{} to SharedAsset, carrying over relevant fields
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) SanitizeNaN ¶ added in v1.106.0
func (sa *SharedAsset) SanitizeNaN()
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) SetWindow ¶ added in v1.97.0
func (sa *SharedAsset) SetWindow(window Window)
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
type SharedCostBreakdown ¶ added in v1.104.0
type SharedCostBreakdown struct {}
type SharedCostBreakdowns ¶ added in v1.104.0
type SharedCostBreakdowns map[string]SharedCostBreakdown
func (SharedCostBreakdowns) Add ¶ added in v1.104.0
func (scbs SharedCostBreakdowns) Add(that SharedCostBreakdowns)
func (SharedCostBreakdowns) Clone ¶ added in v1.104.0
func (scbs SharedCostBreakdowns) Clone() SharedCostBreakdowns
func (SharedCostBreakdowns) Insert ¶ added in v1.104.0
func (scbs SharedCostBreakdowns) Insert(scb SharedCostBreakdown)
func (SharedCostBreakdowns) SanitizeNaN ¶ added in v1.106.0
func (scbs SharedCostBreakdowns) SanitizeNaN()
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"` ExternalCost float64 `json:"externalCost"` UnmountedPVCost float64 `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 NewMockUnitSummaryAllocation ¶ added in v1.102.0
func NewMockUnitSummaryAllocation(name string, start time.Time, resolution time.Duration, props *AllocationProperties) *SummaryAllocation
NewMockUnitSummaryAllocation creates an *SummaryAllocation with all of its float64 values set to 1 and generic properties if not provided in arg
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) Equal ¶ added in v1.102.0
func (sa *SummaryAllocation) Equal(that *SummaryAllocation) bool
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) ToResponse ¶ added in v1.102.0
func (sa *SummaryAllocation) ToResponse() *SummaryAllocationResponse
ToResponse converts a SummaryAllocation to a SummaryAllocationResponse, protecting against NaN and null values.
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 SummaryAllocationResponse ¶ added in v1.102.0
type SummaryAllocationResponse struct { Name string `json:"name"` 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"` ExternalCost *float64 `json:"externalCost"` TotalEfficiency *float64 `json:"totalEfficiency"` TotalCost *float64 `json:"totalCost"` }
SummaryAllocationResponse is a sanitized version of SummaryAllocation, which formats fields and protects against issues like mashaling NaNs.
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 NewMockUnitSummaryAllocationSet ¶ added in v1.102.0
func NewMockUnitSummaryAllocationSet(start time.Time, resolution time.Duration) *SummaryAllocationSet
NewMockUnitSummaryAllocationSet creates an *SummaryAllocationSet
func NewSummaryAllocationSet ¶
func NewSummaryAllocationSet(as *AllocationSet, filter, keep AllocationMatcher, 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.
This filter is an AllocationMatcher, not an AST, because at this point we already have the data and want to make sure that the filter has already gone through a compile step to deal with things like aliases.
func (*SummaryAllocationSet) Add ¶
func (sas *SummaryAllocationSet) Add(that *SummaryAllocationSet) (*SummaryAllocationSet, error)
Add sums two SummaryAllocationSets, which Adds all SummaryAllocations in the given SummaryAllocationSet to their 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) CPUEfficiency ¶ added in v1.98.0
func (sas *SummaryAllocationSet) CPUEfficiency() float64
CPUEfficiency func to calculate average CPU efficiency over SummaryAllocationSet
func (*SummaryAllocationSet) Clone ¶
func (sas *SummaryAllocationSet) Clone() *SummaryAllocationSet
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) Equal ¶ added in v1.102.0
func (sas *SummaryAllocationSet) Equal(that *SummaryAllocationSet) bool
func (*SummaryAllocationSet) GetUnmountedPVCost ¶ added in v1.106.3
func (sas *SummaryAllocationSet) GetUnmountedPVCost() float64
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) RAMEfficiency ¶ added in v1.98.0
func (sas *SummaryAllocationSet) RAMEfficiency() float64
RAMEfficiency func to calculate average RAM efficiency over SummaryAllocationSet
func (*SummaryAllocationSet) ToResponse ¶ added in v1.102.0
func (sas *SummaryAllocationSet) ToResponse() *SummaryAllocationSetResponse
ToResponse converts a SummaryAllocationSet to a SummaryAllocationSetResponse, protecting against NaN and null values.
func (*SummaryAllocationSet) TotalCost ¶
func (sas *SummaryAllocationSet) TotalCost() float64
func (*SummaryAllocationSet) TotalEfficiency ¶ added in v1.98.0
func (sas *SummaryAllocationSet) TotalEfficiency() float64
TotalEfficiency func to calculate average Total efficiency over SummaryAllocationSet
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(accumulateBy AccumulateOption) (*SummaryAllocationSetRange, error)
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 ¶
func (sasr *SummaryAllocationSetRange) Append(sas *SummaryAllocationSet)
Append appends the given AllocationSet to the end of the range. It does not validate whether or not that violates window continuity.
func (*SummaryAllocationSetRange) Clone ¶ added in v1.102.0
func (sasr *SummaryAllocationSetRange) Clone() *SummaryAllocationSetRange
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) ToResponse ¶ added in v1.102.0
func (sasr *SummaryAllocationSetRange) ToResponse() *SummaryAllocationSetRangeResponse
ToResponse converts a SummaryAllocationSet to a SummaryAllocationSetResponse, protecting against NaN and null values.
func (*SummaryAllocationSetRange) TotalCost ¶
func (sasr *SummaryAllocationSetRange) TotalCost() float64
type SummaryAllocationSetRangeResponse ¶ added in v1.102.0
type SummaryAllocationSetRangeResponse struct { Step time.Duration `json:"step"` SummaryAllocationSets []*SummaryAllocationSetResponse `json:"sets"` Window Window `json:"window"` }
SummaryAllocationSetRangeResponse is a sanitized version of SummaryAllocationSetRange, which formats fields and protects against issues like marshaling NaNs.
func EmptySummaryAllocationSetRangeResponse ¶ added in v1.102.0
func EmptySummaryAllocationSetRangeResponse() *SummaryAllocationSetRangeResponse
type SummaryAllocationSetResponse ¶ added in v1.102.0
type SummaryAllocationSetResponse struct { SummaryAllocations map[string]*SummaryAllocationResponse `json:"allocations"` Window Window `json:"window"` }
SummaryAllocationSetResponse is a sanitized version of SummaryAllocationSet, which formats fields and protects against issues like marshaling NaNs.
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 GetWindows ¶ added in v1.99.0
GetWindows returns a slice of Window with equal size between the given start and end. If windowSize does not evenly divide the period between start and end, the last window is not added Deprecated: in v1.107 use Window.GetWindows() instead
func GetWindowsForQueryWindow ¶ added in v1.99.0
func GetWindowsForQueryWindow(start time.Time, end time.Time, queryWindow time.Duration) ([]Window, error)
GetWindowsForQueryWindow breaks up a window into an array of windows with a max size of queryWindow
func NewClosedWindow ¶
NewClosedWindow creates and returns a new Window instance from the given times, which cannot be nil, so they are value types.
func ParseWindowUTC ¶
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 ¶
ParseWindowWithOffset parses the given window string within the context of the timezone defined by the UTC offset.
func ParseWindowWithOffsetString ¶
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 ¶
ApproximatelyEqual returns true if the start and end times of the two windows, respectively, are within the given threshold of each other.
func (Window) ContainsWindow ¶
func (Window) DurationOffset ¶
DurationOffset returns durations representing the duration and offset of the given window
func (Window) DurationOffsetForPrometheus ¶
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 ¶
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) GetAccumulateWindow ¶ added in v1.108.0
func (w Window) GetAccumulateWindow(accumOpt AccumulateOption) (Window, error)
GetAccumulateWindow rounds the start and end of the window to the given accumulation option
func (Window) GetAccumulateWindows ¶ added in v1.108.0
func (w Window) GetAccumulateWindows(accumOpt AccumulateOption) ([]Window, error)
GetAccumulateWindows breaks provided window into a []Window with each window having the resolution of the provided AccumulateOption
func (Window) GetPercentInWindow ¶ added in v1.99.0
GetPercentInWindow Determine pct of item time contained the window. determined by the overlap of the start/end with the given window, which will be negative if there is no overlap. If there is positive overlap, compare it with the total mins.
e.g. here are the two possible scenarios as simplidied 10m windows with dashes representing item's time running:
item falls entirely within one CloudCostSet window | ---- | | | totalMins = 4.0 pct := 4.0 / 4.0 = 1.0 for window 1 pct := 0.0 / 4.0 = 0.0 for window 2 pct := 0.0 / 4.0 = 0.0 for window 3
item overlaps multiple CloudCostSet windows | ----|----------|-- | totalMins = 16.0 pct := 4.0 / 16.0 = 0.250 for window 1 pct := 10.0 / 16.0 = 0.625 for window 2 pct := 2.0 / 16.0 = 0.125 for window 3
func (Window) HasDuration ¶
HasDuration a Window has duration if neither start and end are not nil and not equal
func (Window) IsNegative ¶
IsNegative a Window is negative if start and end are not null and end is before start
func (*Window) MarshalBinary ¶
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 (*Window) UnmarshalBinary ¶
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
func (*Window) UnmarshalJSON ¶ added in v1.102.0
Source Files
¶
- allocation.go
- allocation_json.go
- allocationmatcher.go
- allocationprops.go
- asset.go
- asset_json.go
- assetmatcher.go
- assetprops.go
- bingen.go
- cloudcost.go
- cloudcostmatcher.go
- cloudcostprops.go
- cloudusage.go
- common.go
- config.go
- costmetric.go
- coverage.go
- json.go
- kubecost_codecs.go
- mock.go
- query.go
- status.go
- summaryallocation.go
- summaryallocation_json.go
- totals.go
- totals_json.go
- window.go