Documentation
¶
Index ¶
- Constants
- func ValidateQueryRequest(request *QueryRequest) error
- type AggregationType
- type BaseConsumptionTags
- type Bucket
- type ChargeDetail
- type Charges
- type Client
- type Consumption
- type ConsumptionGroup
- type ConsumptionPeriod
- type ConsumptionQuery
- type CopyOrgRequest
- type CustomIngressConsumptionTags
- type GetBucketRequest
- type InjectConsumptionRequest
- type InjectConsumptionResponse
- type LoadBalancerConsumptionTags
- type Mk8sClusterConsumptionTags
- type MoveOrgRequest
- type Org
- type QueryRequest
- type QueryResult
- type QueryResultAggregator
- type ScrubOrgRequest
- type TagValuesQueryRequest
- type TagValuesQueryResult
- type VolumeSetConsumptionTags
- type VolumeSetSnapshotConsumptionTags
- type WorkloadConsumptionTags
Constants ¶
View Source
const ( AggregateByTimeStep = "timeStep" GroupByConsumptionQuery = "consumptionQuery" )
Variables ¶
This section is empty.
Functions ¶
func ValidateQueryRequest ¶
func ValidateQueryRequest(request *QueryRequest) error
Types ¶
type AggregationType ¶
type AggregationType string
type BaseConsumptionTags ¶
type BaseConsumptionTags struct {
Feature string `json:"feature"` //VolumeSets, Workloads, Ingress, SpiceDb, etc.
Metric string `json:"metric"` //Required. CPU, Memory, Egress, StorageCapacity, etc.
Org string `json:"org"` //Required. Everything lives in an org
Gvc string `json:"gvc,omitempty"` //Optional. Not all resources are gvc-scoped
Name string `json:"name"` //Required. All metered entities have a name.
Location string `json:"location,omitempty"` //Optional. It's possible that some objects will be global
LocationType string `json:"locationType"`
}
type Bucket ¶
type Bucket struct {
Id int64 `json:"id"`
PartitionsEnding time.Time `json:"partitionsEnding" gorm:"type:timestamptz"`
Created time.Time `json:"created" gorm:"type:timestamptz;default:now()"`
Orgs []*Org `json:"orgs,omitempty"`
}
func (*Bucket) CheckpointName ¶
func (*Bucket) SchemaName ¶
type ChargeDetail ¶
type ChargeDetail struct {
Charge math.Float64 `json:"amount"`
Units math.Float64 `json:"units"`
Rate math.Float64 `json:"rate"`
RatePlanItem string `json:"ratePlanItem"`
ChargeableItemId string `json:"chargeableItemId"`
From math.Float64 `json:"from"`
To math.Float64 `json:"to"`
}
func (ChargeDetail) Add ¶
func (c ChargeDetail) Add(other ChargeDetail) ChargeDetail
type Charges ¶
type Charges struct {
Charge math.Float64 `json:"total"`
Currency string `json:"currency,omitempty"`
RatePlan []string `json:"ratePlans"`
Details []ChargeDetail `json:"details,omitempty" gorm:"type:jsonb"`
// contains filtered or unexported fields
}
func (*Charges) ExtractDetailsFromMap ¶
func (c *Charges) ExtractDetailsFromMap()
type Client ¶
type Client interface {
SetProfiling(enabled bool)
QueryTagValues(token string, org string, query *TagValuesQueryRequest) (*TagValuesQueryResult, error)
QueryByOrg(token string, org string, query *QueryRequest) (*QueryResult, error)
Query(token string, query *QueryRequest) (*QueryResult, error)
/*
DecomposeAndQueryByOrg and DecomposeAndQuery ensure that the given query is executed (at least) once for each
subSegment. If the subSegments are not aligned with query.TimeStep, the query will be decomposed into smaller
TimeSteps, given by decomposeInto.
Decomposition will fail if the query.TimeSegment is not aligned with the
smallest value in decomposeInto. e.g. if you give a query with a TimeSegment of
2023-01-01T00:01:01 - 2023-01-02T00:00:00, decomposition will fail because the start time is not aligned with the
smallest possible TimeStep (TimeStepHour)
*/
DecomposeAndQueryByOrg(token string, org string, query *QueryRequest, boundaryTimes []time.Time, decomposeInto []timeUtils.TimeStep) ([]*QueryResult, error)
DecomposeAndQuery(token string, query *QueryRequest, boundaryTimes []time.Time, decomposeInto []timeUtils.TimeStep) ([]*QueryResult, error)
GroupQueryResults(results []*QueryResult, aggregationPeriod timeUtils.TimeSegment, timeStep timeUtils.TimeStep, aggregateByTimeStep bool) (*QueryResult, error)
AdminListCheckpoints(token string) (*checkpoints.ListCheckpointsResult, error)
AdminResetCheckpoints(token string, request *checkpoints.ResetCheckpointsRequest) error
AdminQueryCheckpoints(token string, request *checkpoints.QueryCheckpointsRequest) (*checkpoints.QueryCheckpointsResult, error)
GetBucket(token string, request *GetBucketRequest) (*Bucket, error)
ListBuckets(token string) ([]*Bucket, error)
InjectConsumption(token string, org string, req *InjectConsumptionRequest) (*InjectConsumptionResponse, error)
}
type Consumption ¶
type Consumption struct {
*Charges `gorm:"-"`
ProjectedCharge math.Float64 `json:"projectedTotal,omitempty" gorm:"-"`
Value math.Float64 `json:"value"`
ProjectedValue math.Float64 `json:"projectedValue,omitempty" gorm:"-"`
Job string `json:"job,omitempty"`
Tags any `json:"tags" gorm:"type:jsonb"`
// contains filtered or unexported fields
}
func (*Consumption) Add ¶
func (c *Consumption) Add(other *Consumption) (*Consumption, error)
func (*Consumption) FingerprintTags ¶
func (c *Consumption) FingerprintTags() string
func (*Consumption) GetQueryIndex ¶
func (c *Consumption) GetQueryIndex() int
func (*Consumption) SetQueryIndex ¶
func (c *Consumption) SetQueryIndex(i int)
type ConsumptionGroup ¶
type ConsumptionGroup struct {
Key map[string]any `json:"key"`
Consumptions []*Consumption `json:"consumptions"`
}
type ConsumptionPeriod ¶
type ConsumptionPeriod struct {
StartTime time.Time `json:"startTime"`
EndTime time.Time `json:"endTime"`
TotalSeconds math.Float64 `json:"totalSeconds"`
ElapsedSeconds math.Float64 `json:"elapsedSeconds,omitempty"`
ConsumptionCount int `json:"consumptionCount"`
Groups []*ConsumptionGroup `json:"groups"`
}
func (*ConsumptionPeriod) TimeSegment ¶
func (p *ConsumptionPeriod) TimeSegment() timeUtils.TimeSegment
type ConsumptionQuery ¶
type ConsumptionQuery struct {
FilterBy map[string]string `json:"filterBy"`
AggregateBy []string `json:"aggregateBy,omitempty"`
ChargeableItems []string `json:"chargeableItems,omitempty"`
Jobs []string `json:"jobs,omitempty"`
}
func (*ConsumptionQuery) AggregatesByTimeStep ¶
func (q *ConsumptionQuery) AggregatesByTimeStep() bool
func (*ConsumptionQuery) Clone ¶
func (q *ConsumptionQuery) Clone() *ConsumptionQuery
func (*ConsumptionQuery) DoesAggregateBy ¶
func (q *ConsumptionQuery) DoesAggregateBy(field string) bool
func (*ConsumptionQuery) EnsureAggregatesBy ¶
func (q *ConsumptionQuery) EnsureAggregatesBy(field string)
func (*ConsumptionQuery) EnsureDoesNotAggregateBy ¶
func (q *ConsumptionQuery) EnsureDoesNotAggregateBy(field string)
type CopyOrgRequest ¶
type CustomIngressConsumptionTags ¶ added in v1.1.23
type CustomIngressConsumptionTags struct {
BaseConsumptionTags
CustomIngress string `json:"customIngress"`
}
type GetBucketRequest ¶
type GetBucketRequest struct {
Id int64 `json:"id"`
}
type InjectConsumptionRequest ¶ added in v1.1.23
type InjectConsumptionRequest struct {
ChargeableItem string `json:"chargeableItem"`
Value float64 `json:"value"`
StartTime time.Time `json:"startTime"`
Tags map[string]any `json:"tags"`
}
InjectConsumptionRequest is the payload for the metering usage-injection endpoint (POST /org/{org}/-inject). It mirrors the server-side type in metering/pkg/types. StartTime must be hour-aligned and must not be in the future; Tags must be non-nil.
type InjectConsumptionResponse ¶ added in v1.1.23
type InjectConsumptionResponse struct {
Success bool `json:"success"`
Delta float64 `json:"delta"`
PreviousValue float64 `json:"previousValue"`
NewValue float64 `json:"newValue"`
}
InjectConsumptionResponse is the metering response for an injection.
type LoadBalancerConsumptionTags ¶ added in v1.1.23
type LoadBalancerConsumptionTags struct {
CustomIngressConsumptionTags
Workload string `json:"workload,omitempty"`
LoadBalancerKind string `json:"loadBalancerKind,omitempty"`
LoadBalancerId string `json:"loadBalancerId"`
}
LoadBalancerConsumptionTags identifies one cloud load balancer. LoadBalancerId is what cost data is keyed by, so it is the tag a cost job reads back to see what it has already billed.
type Mk8sClusterConsumptionTags ¶ added in v1.1.23
type Mk8sClusterConsumptionTags struct {
BaseConsumptionTags
Mk8sCluster string `json:"mk8sCluster"`
}
type MoveOrgRequest ¶
type Org ¶
type QueryRequest ¶
type QueryRequest struct {
StartTime time.Time `json:"startTime"`
EndTime time.Time `json:"endTime"`
TimeStep timeUtils.TimeStep `json:"timeStep"`
GroupBy []string `json:"groupBy,omitempty"`
AggregateByTimeStep bool `json:"aggregateByTimeStep"`
ConsumptionQueries []*ConsumptionQuery `json:"consumptionQueries"`
}
func (*QueryRequest) Clone ¶
func (q *QueryRequest) Clone() *QueryRequest
func (*QueryRequest) SetTimeSegment ¶
func (q *QueryRequest) SetTimeSegment(t timeUtils.TimeSegment) error
func (*QueryRequest) TimeSegment ¶
func (q *QueryRequest) TimeSegment() timeUtils.TimeSegment
type QueryResult ¶
type QueryResult struct {
Periods []*ConsumptionPeriod `json:"periods"`
ConsumptionCount int `json:"consumptionCount"`
}
func (*QueryResult) AllConsumptions ¶
func (q *QueryResult) AllConsumptions() []*Consumption
func (*QueryResult) Merge ¶
func (q *QueryResult) Merge(other *QueryResult)
type QueryResultAggregator ¶
type QueryResultAggregator struct {
TimeStep timeUtils.TimeStep
timeUtils.TimeSegment
AggregateByTimeStep bool
// contains filtered or unexported fields
}
func NewQueryResultAggregator ¶
func NewQueryResultAggregator(aggregationPeriod timeUtils.TimeSegment, timeStep timeUtils.TimeStep, aggregateByTimeStep bool) QueryResultAggregator
func (QueryResultAggregator) AggregateQueryResults ¶
func (q QueryResultAggregator) AggregateQueryResults(results ...*QueryResult) error
func (QueryResultAggregator) QueryResult ¶
func (q QueryResultAggregator) QueryResult(timeStep timeUtils.TimeStep) (*QueryResult, error)
type ScrubOrgRequest ¶
type TagValuesQueryRequest ¶
type TagValuesQueryRequest struct {
StartTime time.Time `json:"startTime"`
EndTime time.Time `json:"endTime"`
Tag string `json:"tag"`
FilterBy map[string]string `json:"filterBy"`
}
func (*TagValuesQueryRequest) TimeSegment ¶
func (r *TagValuesQueryRequest) TimeSegment() timeUtils.TimeSegment
func (*TagValuesQueryRequest) Validate ¶
func (r *TagValuesQueryRequest) Validate() error
type TagValuesQueryResult ¶
type TagValuesQueryResult struct {
*TagValuesQueryRequest
TagValues []string `json:"tagValues"`
}
type VolumeSetConsumptionTags ¶
type VolumeSetConsumptionTags struct {
WorkloadConsumptionTags
VolumeIndex int `json:"volumeIndex"`
VolumeSet string `json:"volumeSet"`
Driver string `json:"driver"`
PerformanceClass string `json:"performanceClass"`
}
type VolumeSetSnapshotConsumptionTags ¶
type VolumeSetSnapshotConsumptionTags struct {
VolumeSetConsumptionTags
SnapshotName string `json:"snapshotName"`
// The cloud provider's own id for the snapshot. omitempty keeps capacity-metered rows
// byte-identical to what they were before cost metering existed, so row identity holds.
SnapshotId string `json:"snapshotId,omitempty"`
}
type WorkloadConsumptionTags ¶
type WorkloadConsumptionTags struct {
BaseConsumptionTags
Workload string `json:"workload"`
WorkloadType string `json:"workloadType"`
}
Click to show internal directories.
Click to hide internal directories.