Documentation ¶
Index ¶
- Constants
- Variables
- func AggregateCostData(costData map[string]*CostData, field string, subfields []string, ...) map[string]*Aggregation
- func ClusterDisks(client prometheus.Client, provider models.Provider, start, end time.Time) (map[DiskIdentifier]*Disk, error)
- func ClusterLoadBalancers(client prometheus.Client, start, end time.Time) (map[LoadBalancerIdentifier]*LoadBalancer, error)
- func ClusterNodes(cp models.Provider, client prometheus.Client, start, end time.Time) (map[NodeIdentifier]*Node, error)
- func CostDataRangeFromSQL(field string, value string, window string, start string, end string) (map[string]*CostData, error)
- func FilterCostData(data map[string]*CostData, retains []FilterFunc, filters []FilterFunc) (map[string]*CostData, int, map[string]int)
- func GenerateAggKey(window kubecost.Window, field string, subfields []string, ...) string
- func GetContainerMetricVector(qrs []*prom.QueryResult, normalize bool, normalizationValue float64, ...) (map[string][]*util.Vector, error)
- func GetContainerMetricVectors(qrs []*prom.QueryResult, defaultClusterID string) (map[string][]*util.Vector, error)
- func GetDeploymentMatchLabelsMetrics(qrs []*prom.QueryResult, defaultClusterID string) (map[string]map[string]string, error)
- func GetNamespaceAnnotationsMetrics(qrs []*prom.QueryResult, defaultClusterID string) (map[string]map[string]string, error)
- func GetNamespaceLabelsMetrics(qrs []*prom.QueryResult, defaultClusterID string) (map[string]map[string]string, error)
- func GetNetworkCost(usage *NetworkUsageData, cloud costAnalyzerCloud.Provider) ([]*util.Vector, error)
- func GetNetworkUsageData(zr []*prom.QueryResult, rr []*prom.QueryResult, ir []*prom.QueryResult, ...) (map[string]*NetworkUsageData, error)
- func GetNormalizedContainerMetricVectors(qrs []*prom.QueryResult, normalizationValues []*util.Vector, ...) (map[string][]*util.Vector, error)
- func GetPVAllocationMetrics(qrs []*prom.QueryResult, defaultClusterID string) (map[string][]*PersistentVolumeClaimData, error)
- func GetPVCost(pv *costAnalyzerCloud.PV, kpv *v1.PersistentVolume, ...) error
- func GetPVCostMetrics(qrs []*prom.QueryResult, defaultClusterID string) (map[string]*costAnalyzerCloud.PV, error)
- func GetPVInfo(qrs []*prom.QueryResult, defaultClusterID string) (map[string]*PersistentVolumeClaimData, error)
- func GetPVInfoLocal(cache clustercache.ClusterCache, defaultClusterID string) (map[string]*PersistentVolumeClaimData, error)
- func GetPodAnnotationsMetrics(qrs []*prom.QueryResult, defaultClusterID string) (map[string]map[string]string, error)
- func GetPodDaemonsetsWithMetrics(qrs []*prom.QueryResult, defaultClusterID string) (map[string]string, error)
- func GetPodJobsWithMetrics(qrs []*prom.QueryResult, defaultClusterID string) (map[string]string, error)
- func GetPodLabelsMetrics(qrs []*prom.QueryResult, defaultClusterID string) (map[string]map[string]string, error)
- func GetServiceSelectorLabelsMetrics(qrs []*prom.QueryResult, defaultClusterID string) (map[string]map[string]string, error)
- func GetStatefulsetMatchLabelsMetrics(qrs []*prom.QueryResult, defaultClusterID string) (map[string]map[string]string, error)
- func GetTotalContainerCost(costData map[string]*CostData, rate string, cp models.Provider, ...) float64
- func NewClusterInfoWriteOnRequest(clusterInfo clusters.ClusterInfoProvider, config *config.ConfigFile) clusters.ClusterInfoProvider
- func NewConfiguredClusterInfoProvider(config *config.ConfigFile) clusters.ClusterInfoProvider
- func NewLocalClusterInfoProvider(k8s kubernetes.Interface, cloud cloudProvider.Provider) clusters.ClusterInfoProvider
- func ParseAggregationProperties(aggregations []string) ([]string, error)
- func ParsePercentString(percentStr string) (float64, error)
- func ScaleAggregationTimeSeries(aggregation *Aggregation, resolutionHours float64)
- func ScaleHourlyCostData(data map[string]*CostData, resolutionHours float64) map[string]*CostData
- func UpdateCSV(ctx context.Context, fileManager filemanager.FileManager, ...) error
- func WrapData(data interface{}, err error) []byte
- func WrapDataWithMessage(data interface{}, err error, message string) []byte
- func WrapDataWithMessageAndWarning(data interface{}, err error, message, warning string) []byte
- func WrapDataWithWarning(data interface{}, err error, warning string) []byte
- func WriteError(w http.ResponseWriter, err Error)
- type Accesses
- func (a *Accesses) AddServiceKey(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) AggregateCostModelHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) ClusterCosts(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) ClusterCostsFromCacheHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) ClusterCostsOverTime(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) ClusterInfo(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) ComputeAggregateCostModel(promClient prometheusClient.Client, window kubecost.Window, field string, ...) (map[string]*Aggregation, string, error)
- func (a *Accesses) ComputeAllocationHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) ComputeAllocationHandlerSummary(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) ComputeAssetsHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) ComputeClusterCosts(client prometheus.Client, provider models.Provider, ...) (map[string]*ClusterCosts, error)
- func (a *Accesses) ComputeIdleCoefficient(costData map[string]*CostData, cli prometheusClient.Client, cp models.Provider, ...) (map[string]float64, error)
- func (a *Accesses) CostDataModel(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) CostDataModelRange(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) GetAllDaemonSets(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) GetAllDeployments(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) GetAllNamespaces(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) GetAllNodePricing(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) GetAllNodes(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) GetAllPersistentVolumes(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) GetAllPods(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) GetAllStatefulSets(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) GetAllStorageClasses(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) GetCacheExpiration(dur time.Duration) time.Duration
- func (a *Accesses) GetCacheRefresh(dur time.Duration) time.Duration
- func (a *Accesses) GetClusterInfoMap(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) GetConfigs(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) GetHelmValues(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) GetInstallInfo(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (a *Accesses) GetInstallNamespace(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (a *Accesses) GetLogLevel(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (a *Accesses) GetOrphanedPods(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) GetPod(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) GetPodLogs(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) GetPricingSourceCounts(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
- func (a *Accesses) GetPricingSourceStatus(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
- func (a *Accesses) GetPricingSourceSummary(w http.ResponseWriter, r *http.Request, p httprouter.Params)
- func (a *Accesses) GetPrometheusClient(remote bool) prometheus.Client
- func (a *Accesses) GetPrometheusMetadata(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
- func (a *Accesses) GetPrometheusMetrics(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
- func (a *Accesses) GetPrometheusQueueState(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
- func (a *Accesses) GetServiceAccountStatus(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
- func (a *Accesses) InitializeSettingsPubSub()
- func (a *Accesses) ManagementPlatform(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) PrometheusConfig(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (a *Accesses) PrometheusQuery(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (a *Accesses) PrometheusQueryRange(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (a *Accesses) PrometheusRecordingRules(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (a *Accesses) PrometheusTargets(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (a *Accesses) RefreshPricingData(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) SetLogLevel(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) Status(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (a *Accesses) SubscribeToCustomPricingChanges(ch chan string)
- func (a *Accesses) SubscribeToDiscountChanges(ch chan string)
- func (a *Accesses) ThanosQuery(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (a *Accesses) ThanosQueryRange(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (a *Accesses) UpdateAthenaInfoConfigs(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) UpdateAzureStorageConfigs(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) UpdateBigQueryInfoConfigs(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) UpdateConfigByKey(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (a *Accesses) UpdateSpotInfoConfigs(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- type AggregateQueryOpts
- type Aggregation
- type AggregationOptions
- type Aggregator
- type AllocationModel
- type ClusterCosts
- type ClusterCostsBreakdown
- type ClusterInfoCollector
- type ClusterInfoMetric
- type CoefficientComponent
- type ContainerInfo
- type ContainerMetric
- func NewContainerMetricFromKey(key string) (*ContainerMetric, error)
- func NewContainerMetricFromPrometheus(metrics map[string]interface{}, defaultClusterID string) (*ContainerMetric, error)
- func NewContainerMetricFromValues(ns, podName, containerName, nodeName, clusterId string) *ContainerMetric
- func NewContainerMetricsFromPod(pod *v1.Pod, clusterID string) ([]*ContainerMetric, error)
- type CostData
- type CostModel
- func (cm *CostModel) CanCompute(start, end time.Time) bool
- func (cm *CostModel) ClusterDisks(start, end time.Time) (map[DiskIdentifier]*Disk, error)
- func (cm *CostModel) ClusterLoadBalancers(start, end time.Time) (map[LoadBalancerIdentifier]*LoadBalancer, error)
- func (cm *CostModel) ClusterNodes(start, end time.Time) (map[NodeIdentifier]*Node, error)
- func (cm *CostModel) ComputeAllocation(start, end time.Time, resolution time.Duration) (*kubecost.AllocationSet, error)
- func (cm *CostModel) ComputeAssets(start, end time.Time) (*kubecost.AssetSet, error)
- func (cm *CostModel) ComputeCostData(cli prometheusClient.Client, cp costAnalyzerCloud.Provider, window string, ...) (map[string]*CostData, error)
- func (cm *CostModel) ComputeCostDataRange(cli prometheusClient.Client, cp costAnalyzerCloud.Provider, ...) (map[string]*CostData, error)
- func (cm *CostModel) DateRange() (time.Time, time.Time, error)
- func (cm *CostModel) GetLBCost(cp costAnalyzerCloud.Provider) (map[serviceKey]*costAnalyzerCloud.LoadBalancer, error)
- func (cm *CostModel) GetNodeCost(cp costAnalyzerCloud.Provider) (map[string]*costAnalyzerCloud.Node, error)
- func (cm *CostModel) GetPricingSourceCounts() (*costAnalyzerCloud.PricingMatchMetadata, error)
- func (cm *CostModel) Name() string
- func (cm *CostModel) PropertiesFromCluster(props *kubecost.AssetProperties)
- func (cm *CostModel) QueryAllocation(window kubecost.Window, resolution, step time.Duration, aggregate []string, ...) (*kubecost.AllocationSetRange, error)
- type CostModelMetricsEmitter
- type Disk
- type DiskIdentifier
- type EmptyDataError
- type Error
- type FilterFunc
- type InstallInfo
- type IntervalPoint
- type IntervalPoints
- type KeyTuple
- type LoadBalancer
- type LoadBalancerIdentifier
- type LogLevelRequestResponse
- type NetworkUsageData
- type NetworkUsageVector
- type Node
- type NodeCostAverages
- type NodeIdentifier
- type NodeOverhead
- type PersistentVolumeClaimData
- type Response
- type SharedCostInfo
- type SharedResourceInfo
- type Totals
Constants ¶
const ( // SplitTypeWeighted signals that shared costs should be shared // proportionally, rather than evenly SplitTypeWeighted = "weighted" // UnallocatedSubfield indicates an allocation datum that does not have the // chosen Aggregator; e.g. during aggregation by some label, there may be // cost data that do not have the given label. UnallocatedSubfield = "__unallocated__" )
const ( RFC3339Milli = "2006-01-02T15:04:05.000Z" CustomPricingSetting = "CustomPricing" DiscountSetting = "Discount" LogSeparator = "+-------------------------------------------------------------------------------------" )
const CPU_SANITY_LIMIT = 512
This is a bit of a hack to work around garbage data from cadvisor Ideally you cap each pod to the max CPU on its node, but that involves a bit more complexity, as it it would need to be done when allocations joins with asset data.
const GiB = 1024.0 * MiB
const KiB = 1024.0
Sanity Limit for PV usage, set to 10 PB, in bytes for now
const MiB = 1024.0 * KiB
const PV_USAGE_SANITY_LIMIT_BYTES = 10.0 * PiB
const PiB = 1024.0 * TiB
const TiB = 1024.0 * GiB
Variables ¶
var ( // Static KeyTuple Errors NewKeyTupleErr = errors.New("NewKeyTuple() Provided key not containing exactly 3 components.") // Static Errors for ContainerMetric creation InvalidKeyErr error = errors.New("Not a valid key") NoContainerErr error = errors.New("Prometheus vector does not have container name") NoContainerNameErr error = errors.New("Prometheus vector does not have string container name") NoPodErr error = errors.New("Prometheus vector does not have pod name") NoPodNameErr error = errors.New("Prometheus vector does not have string pod name") NoNamespaceErr error = errors.New("Prometheus vector does not have namespace") NoNamespaceNameErr error = errors.New("Prometheus vector does not have string namespace") NoNodeNameErr error = errors.New("Prometheus vector does not have string node") NoClusterIDErr error = errors.New("Prometheus vector does not have string cluster id") )
var ( // ANSIRegex matches ANSI escape and colors https://en.wikipedia.org/wiki/ANSI_escape_code ANSIRegex = regexp.MustCompile("\x1b\\[[0-9;]*m") )
Functions ¶
func AggregateCostData ¶
func AggregateCostData(costData map[string]*CostData, field string, subfields []string, cp models.Provider, opts *AggregationOptions) map[string]*Aggregation
AggregateCostData aggregates raw cost data by field; e.g. namespace, cluster, service, or label. In the case of label, callers must pass a slice of subfields indicating the labels by which to group. Provider is used to define custom resource pricing. See AggregationOptions for optional parameters.
func ClusterDisks ¶
func ClusterDisks(client prometheus.Client, provider models.Provider, start, end time.Time) (map[DiskIdentifier]*Disk, error)
func ClusterLoadBalancers ¶
func ClusterLoadBalancers(client prometheus.Client, start, end time.Time) (map[LoadBalancerIdentifier]*LoadBalancer, error)
func ClusterNodes ¶
func ClusterNodes(cp models.Provider, client prometheus.Client, start, end time.Time) (map[NodeIdentifier]*Node, error)
func CostDataRangeFromSQL ¶
func FilterCostData ¶
func FilterCostData(data map[string]*CostData, retains []FilterFunc, filters []FilterFunc) (map[string]*CostData, int, map[string]int)
FilterCostData allows through only CostData that matches all the given filter functions
func GenerateAggKey ¶
func GenerateAggKey(window kubecost.Window, field string, subfields []string, opts *AggregateQueryOpts) string
GenerateAggKey generates a parameter-unique key for caching the aggregate cost model
func GetNetworkCost ¶
func GetNetworkCost(usage *NetworkUsageData, cloud costAnalyzerCloud.Provider) ([]*util.Vector, error)
GetNetworkCost computes the actual cost for NetworkUsageData based on data provided by the Provider.
func GetNetworkUsageData ¶
func GetNetworkUsageData(zr []*prom.QueryResult, rr []*prom.QueryResult, ir []*prom.QueryResult, defaultClusterID string) (map[string]*NetworkUsageData, error)
GetNetworkUsageData performs a join of the the results of zone, region, and internet usage queries to return a single map containing network costs for each namespace+pod
func GetPVAllocationMetrics ¶
func GetPVAllocationMetrics(qrs []*prom.QueryResult, defaultClusterID string) (map[string][]*PersistentVolumeClaimData, error)
func GetPVCost ¶
func GetPVCost(pv *costAnalyzerCloud.PV, kpv *v1.PersistentVolume, cp costAnalyzerCloud.Provider, defaultRegion string) error
func GetPVCostMetrics ¶
func GetPVCostMetrics(qrs []*prom.QueryResult, defaultClusterID string) (map[string]*costAnalyzerCloud.PV, error)
func GetPVInfo ¶
func GetPVInfo(qrs []*prom.QueryResult, defaultClusterID string) (map[string]*PersistentVolumeClaimData, error)
func GetPVInfoLocal ¶
func GetPVInfoLocal(cache clustercache.ClusterCache, defaultClusterID string) (map[string]*PersistentVolumeClaimData, error)
func GetPodJobsWithMetrics ¶
func GetPodLabelsMetrics ¶
func GetTotalContainerCost ¶
func NewClusterInfoWriteOnRequest ¶
func NewClusterInfoWriteOnRequest(clusterInfo clusters.ClusterInfoProvider, config *config.ConfigFile) clusters.ClusterInfoProvider
NewClusterInfoWriteOnRequest instantiates and returns a cluster info provider which writes the cluster info to a configuration before each request.
func NewConfiguredClusterInfoProvider ¶
func NewConfiguredClusterInfoProvider(config *config.ConfigFile) clusters.ClusterInfoProvider
NewConfiguredClusterInfoProvider instantiates and returns a cluster info provider which loads cluster info from a config file.
func NewLocalClusterInfoProvider ¶
func NewLocalClusterInfoProvider(k8s kubernetes.Interface, cloud cloudProvider.Provider) clusters.ClusterInfoProvider
NewLocalClusterInfoProvider creates a new clusters.LocalClusterInfoProvider implementation for providing local cluster information
func ParseAggregationProperties ¶
ParseAggregationProperties attempts to parse and return aggregation properties encoded under the given key. If none exist, or if parsing fails, an error is returned with empty AllocationProperties.
func ParsePercentString ¶
ParsePercentString takes a string of expected format "N%" and returns a floating point 0.0N. If the "%" symbol is missing, it just returns 0.0N. Empty string is interpreted as "0%" and return 0.0.
func ScaleAggregationTimeSeries ¶
func ScaleAggregationTimeSeries(aggregation *Aggregation, resolutionHours float64)
ScaleAggregationTimeSeries reverses the scaling done by ScaleHourlyCostData, returning the aggregation's time series to hourly data.
func ScaleHourlyCostData ¶
ScaleHourlyCostData converts per-hour cost data to per-resolution data. If the target resolution is higher (i.e. < 1.0h) then we can do simple multiplication by the fraction-of-an-hour and retain accuracy. If the target resolution is lower (i.e. > 1.0h) then we sum groups of hourly data by resolution to maintain fidelity. e.g. (100 hours of per-hour hourly data, resolutionHours=10) => 10 data points, grouped and summed by 10-hour window e.g. (20 minutes of per-minute hourly data, resolutionHours=1/60) => 20 data points, scaled down by a factor of 60
func UpdateCSV ¶
func UpdateCSV(ctx context.Context, fileManager filemanager.FileManager, model AllocationModel, labelsAll bool, labels []string) error
func WrapDataWithMessage ¶
func WrapDataWithWarning ¶
func WriteError ¶
func WriteError(w http.ResponseWriter, err Error)
Types ¶
type Accesses ¶
type Accesses struct { Router *httprouter.Router PrometheusClient prometheus.Client ThanosClient prometheus.Client KubeClientSet kubernetes.Interface ClusterCache clustercache.ClusterCache ClusterMap clusters.ClusterMap CloudProvider models.Provider ConfigFileManager *config.ConfigFileManager ClusterInfoProvider clusters.ClusterInfoProvider Model *CostModel MetricsEmitter *CostModelMetricsEmitter OutOfClusterCache *cache.Cache AggregateCache *cache.Cache CostDataCache *cache.Cache ClusterCostsCache *cache.Cache CacheExpiration map[time.Duration]time.Duration AggAPI Aggregator // SettingsCache stores current state of app settings SettingsCache *cache.Cache // contains filtered or unexported fields }
Accesses defines a singleton application instance, providing access to Prometheus, Kubernetes, the cloud provider, and caches.
func Initialize ¶
func Initialize(additionalConfigWatchers ...*watcher.ConfigMapWatcher) *Accesses
func (*Accesses) AddServiceKey ¶
func (a *Accesses) AddServiceKey(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) AggregateCostModelHandler ¶
func (a *Accesses) AggregateCostModelHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
AggregateCostModelHandler handles requests to the aggregated cost model API. See ComputeAggregateCostModel for details.
func (*Accesses) ClusterCosts ¶
func (a *Accesses) ClusterCosts(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) ClusterCostsFromCacheHandler ¶
func (a *Accesses) ClusterCostsFromCacheHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) ClusterCostsOverTime ¶
func (a *Accesses) ClusterCostsOverTime(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) ClusterInfo ¶
func (a *Accesses) ClusterInfo(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) ComputeAggregateCostModel ¶
func (a *Accesses) ComputeAggregateCostModel(promClient prometheusClient.Client, window kubecost.Window, field string, subfields []string, opts *AggregateQueryOpts) (map[string]*Aggregation, string, error)
ComputeAggregateCostModel computes cost data for the given window, then aggregates it by the given fields. Data is cached on two levels: the aggregation is cached as well as the underlying cost data.
func (*Accesses) ComputeAllocationHandler ¶
func (a *Accesses) ComputeAllocationHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ComputeAllocationHandler computes an AllocationSetRange from the CostModel.
func (*Accesses) ComputeAllocationHandlerSummary ¶
func (a *Accesses) ComputeAllocationHandlerSummary(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) ComputeAssetsHandler ¶
func (a *Accesses) ComputeAssetsHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ComputeAllocationHandler returns the assets from the CostModel.
func (*Accesses) ComputeClusterCosts ¶
func (a *Accesses) ComputeClusterCosts(client prometheus.Client, provider models.Provider, window, offset time.Duration, withBreakdown bool) (map[string]*ClusterCosts, error)
ComputeClusterCosts gives the cumulative and monthly-rate cluster costs over a window of time for all clusters.
func (*Accesses) ComputeIdleCoefficient ¶
func (*Accesses) CostDataModel ¶
func (a *Accesses) CostDataModel(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) CostDataModelRange ¶
func (a *Accesses) CostDataModelRange(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) GetAllDaemonSets ¶
func (a *Accesses) GetAllDaemonSets(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) GetAllDeployments ¶
func (a *Accesses) GetAllDeployments(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) GetAllNamespaces ¶
func (a *Accesses) GetAllNamespaces(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) GetAllNodePricing ¶
func (a *Accesses) GetAllNodePricing(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) GetAllNodes ¶
func (a *Accesses) GetAllNodes(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) GetAllPersistentVolumes ¶
func (a *Accesses) GetAllPersistentVolumes(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) GetAllPods ¶
func (a *Accesses) GetAllPods(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) GetAllStatefulSets ¶
func (a *Accesses) GetAllStatefulSets(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) GetAllStorageClasses ¶
func (a *Accesses) GetAllStorageClasses(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) GetCacheExpiration ¶
GetCacheExpiration looks up and returns custom cache expiration for the given duration. If one does not exists, it returns the default cache expiration, which is defined by the particular cache.
func (*Accesses) GetCacheRefresh ¶
GetCacheRefresh determines how long to wait before refreshing the cache for the given duration, which is done 1 minute before we expect the cache to expire, or 1 minute if expiration is not found or is less than 2 minutes.
func (*Accesses) GetClusterInfoMap ¶
func (a *Accesses) GetClusterInfoMap(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) GetConfigs ¶
func (a *Accesses) GetConfigs(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) GetHelmValues ¶
func (a *Accesses) GetHelmValues(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) GetInstallInfo ¶
func (a *Accesses) GetInstallInfo(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Accesses) GetInstallNamespace ¶
func (a *Accesses) GetInstallNamespace(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Accesses) GetLogLevel ¶
func (a *Accesses) GetLogLevel(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Accesses) GetOrphanedPods ¶
func (a *Accesses) GetOrphanedPods(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) GetPod ¶
func (a *Accesses) GetPod(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) GetPodLogs ¶
func (a *Accesses) GetPodLogs(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) GetPricingSourceCounts ¶
func (a *Accesses) GetPricingSourceCounts(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
func (*Accesses) GetPricingSourceStatus ¶
func (a *Accesses) GetPricingSourceStatus(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
func (*Accesses) GetPricingSourceSummary ¶
func (a *Accesses) GetPricingSourceSummary(w http.ResponseWriter, r *http.Request, p httprouter.Params)
func (*Accesses) GetPrometheusClient ¶
func (a *Accesses) GetPrometheusClient(remote bool) prometheus.Client
GetPrometheusClient decides whether the default Prometheus client or the Thanos client should be used.
func (*Accesses) GetPrometheusMetadata ¶
func (a *Accesses) GetPrometheusMetadata(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
func (*Accesses) GetPrometheusMetrics ¶
func (a *Accesses) GetPrometheusMetrics(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
GetPrometheusMetrics retrieves availability of Prometheus and Thanos metrics
func (*Accesses) GetPrometheusQueueState ¶
func (a *Accesses) GetPrometheusQueueState(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
func (*Accesses) GetServiceAccountStatus ¶
func (a *Accesses) GetServiceAccountStatus(w http.ResponseWriter, _ *http.Request, _ httprouter.Params)
func (*Accesses) InitializeSettingsPubSub ¶
func (a *Accesses) InitializeSettingsPubSub()
InitializeSettingsPubSub sets up the pub/sub mechanisms and kicks of routines to detect and publish changes, as well as some routines that subscribe and take actions.
func (*Accesses) ManagementPlatform ¶
func (a *Accesses) ManagementPlatform(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) PrometheusConfig ¶
func (a *Accesses) PrometheusConfig(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Accesses) PrometheusQuery ¶
func (a *Accesses) PrometheusQuery(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Accesses) PrometheusQueryRange ¶
func (a *Accesses) PrometheusQueryRange(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Accesses) PrometheusRecordingRules ¶
func (a *Accesses) PrometheusRecordingRules(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Accesses) PrometheusTargets ¶
func (a *Accesses) PrometheusTargets(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Accesses) RefreshPricingData ¶
func (a *Accesses) RefreshPricingData(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
RefreshPricingData needs to be called when a new node joins the fleet, since we cache the relevant subsets of pricing data to avoid storing the whole thing.
func (*Accesses) SetLogLevel ¶
func (a *Accesses) SetLogLevel(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) Status ¶
func (a *Accesses) Status(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Accesses) SubscribeToCustomPricingChanges ¶
SubscribeToCustomPricingChanges subscribes the given channel to receive custom pricing changes.
func (*Accesses) SubscribeToDiscountChanges ¶
SubscribeToDiscountChanges subscribes the given channel to receive discount changes.
func (*Accesses) ThanosQuery ¶
func (a *Accesses) ThanosQuery(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Accesses) ThanosQueryRange ¶
func (a *Accesses) ThanosQueryRange(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Accesses) UpdateAthenaInfoConfigs ¶
func (a *Accesses) UpdateAthenaInfoConfigs(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) UpdateAzureStorageConfigs ¶
func (a *Accesses) UpdateAzureStorageConfigs(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) UpdateBigQueryInfoConfigs ¶
func (a *Accesses) UpdateBigQueryInfoConfigs(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) UpdateConfigByKey ¶
func (a *Accesses) UpdateConfigByKey(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*Accesses) UpdateSpotInfoConfigs ¶
func (a *Accesses) UpdateSpotInfoConfigs(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
type AggregateQueryOpts ¶
type AggregateQueryOpts struct { Rate string Filters map[string]string AllocateIdle bool IncludeTimeSeries bool IncludeEfficiency bool DisableAggregateCostModelCache bool ClearCache bool NoCache bool NoExpireCache bool RemoteEnabled bool UseETLAdapter bool }
func DefaultAggregateQueryOpts ¶
func DefaultAggregateQueryOpts() *AggregateQueryOpts
type Aggregation ¶
type Aggregation struct { Aggregator string `json:"aggregation"` Subfields []string `json:"subfields,omitempty"` Environment string `json:"environment"` Cluster string `json:"cluster,omitempty"` Properties *kubecost.AllocationProperties `json:"-"` Start time.Time `json:"-"` End time.Time `json:"-"` CPUAllocationHourlyAverage float64 `json:"cpuAllocationAverage"` CPUAllocationVectors []*util.Vector `json:"-"` CPUAllocationTotal float64 `json:"-"` CPUCost float64 `json:"cpuCost"` CPUCostVector []*util.Vector `json:"cpuCostVector,omitempty"` CPUEfficiency float64 `json:"cpuEfficiency"` CPURequestedVectors []*util.Vector `json:"-"` CPUUsedVectors []*util.Vector `json:"-"` Efficiency float64 `json:"efficiency"` GPUAllocationHourlyAverage float64 `json:"gpuAllocationAverage"` GPUAllocationVectors []*util.Vector `json:"-"` GPUCost float64 `json:"gpuCost"` GPUCostVector []*util.Vector `json:"gpuCostVector,omitempty"` GPUAllocationTotal float64 `json:"-"` RAMAllocationHourlyAverage float64 `json:"ramAllocationAverage"` RAMAllocationVectors []*util.Vector `json:"-"` RAMAllocationTotal float64 `json:"-"` RAMCost float64 `json:"ramCost"` RAMCostVector []*util.Vector `json:"ramCostVector,omitempty"` RAMEfficiency float64 `json:"ramEfficiency"` RAMRequestedVectors []*util.Vector `json:"-"` RAMUsedVectors []*util.Vector `json:"-"` PVAllocationHourlyAverage float64 `json:"pvAllocationAverage"` PVAllocationVectors []*util.Vector `json:"-"` PVAllocationTotal float64 `json:"-"` PVCost float64 `json:"pvCost"` PVCostVector []*util.Vector `json:"pvCostVector,omitempty"` NetworkCost float64 `json:"networkCost"` NetworkCostVector []*util.Vector `json:"networkCostVector,omitempty"` TotalCost float64 `json:"totalCost"` TotalCostVector []*util.Vector `json:"totalCostVector,omitempty"` }
Aggregation describes aggregated cost data, containing cumulative cost and allocation data per resource, vectors of rate data per resource, efficiency data, and metadata describing the type of aggregation operation.
func (*Aggregation) RateCoefficient ¶
func (a *Aggregation) RateCoefficient(rateStr string, resolutionHours float64) float64
RateCoefficient computes the coefficient by which the total cost needs to be multiplied in order to convert totals costs into per-rate costs.
func (*Aggregation) TotalHours ¶
func (a *Aggregation) TotalHours(resolutionHours float64) float64
TotalHours determines the amount of hours the Aggregation covers, as a function of the cost vectors and the resolution of those vectors' data
type AggregationOptions ¶
type AggregationOptions struct { Discount float64 // percent by which to discount CPU, RAM, and GPU cost CustomDiscount float64 // additional custom discount applied to all prices IdleCoefficients map[string]float64 // scales costs by amount of idle resources on a per-cluster basis IncludeEfficiency bool // set to true to receive efficiency/usage data IncludeTimeSeries bool // set to true to receive time series data Rate string // set to "hourly", "daily", or "monthly" to receive cost rate, rather than cumulative cost ResolutionHours float64 FilteredContainerCount int FilteredEnvironments map[string]int TotalContainerCost float64 }
AggregationOptions provides optional parameters to AggregateCostData, allowing callers to perform more complex operations
type Aggregator ¶
type Aggregator interface {
ComputeAggregateCostModel(promClient prometheusClient.Client, window kubecost.Window, field string, subfields []string, opts *AggregateQueryOpts) (map[string]*Aggregation, string, error)
}
Aggregator is capable of computing the aggregated cost model. This is a brutal interface, which should be cleaned up, but it's necessary for being able to swap in an ETL-backed implementation.
type AllocationModel ¶
type ClusterCosts ¶
type ClusterCosts struct { Start *time.Time `json:"startTime"` End *time.Time `json:"endTime"` CPUCumulative float64 `json:"cpuCumulativeCost"` CPUMonthly float64 `json:"cpuMonthlyCost"` CPUBreakdown *ClusterCostsBreakdown `json:"cpuBreakdown"` GPUCumulative float64 `json:"gpuCumulativeCost"` GPUMonthly float64 `json:"gpuMonthlyCost"` RAMCumulative float64 `json:"ramCumulativeCost"` RAMMonthly float64 `json:"ramMonthlyCost"` RAMBreakdown *ClusterCostsBreakdown `json:"ramBreakdown"` StorageCumulative float64 `json:"storageCumulativeCost"` StorageMonthly float64 `json:"storageMonthlyCost"` StorageBreakdown *ClusterCostsBreakdown `json:"storageBreakdown"` TotalCumulative float64 `json:"totalCumulativeCost"` TotalMonthly float64 `json:"totalMonthlyCost"` DataMinutes float64 }
Costs represents cumulative and monthly cluster costs over a given duration. Costs are broken down by cores, memory, and storage.
func NewClusterCostsFromCumulative ¶
func NewClusterCostsFromCumulative(cpu, gpu, ram, storage float64, window, offset time.Duration, dataHours float64) (*ClusterCosts, error)
NewClusterCostsFromCumulative takes cumulative cost data over a given time range, computes the associated monthly rate data, and returns the Costs.
type ClusterCostsBreakdown ¶
type ClusterCostsBreakdown struct { Idle float64 `json:"idle"` Other float64 `json:"other"` System float64 `json:"system"` User float64 `json:"user"` }
ClusterCostsBreakdown provides percentage-based breakdown of a resource by categories: user for user-space (i.e. non-system) usage, system, and idle.
type ClusterInfoCollector ¶
type ClusterInfoCollector struct { ClusterInfo clusters.ClusterInfoProvider // contains filtered or unexported fields }
ClusterInfoCollector is a prometheus collector that generates ClusterInfoMetrics
func (ClusterInfoCollector) Collect ¶
func (cic ClusterInfoCollector) Collect(ch chan<- prometheus.Metric)
Collect is called by the Prometheus registry when collecting metrics.
func (ClusterInfoCollector) Describe ¶
func (cic ClusterInfoCollector) Describe(ch chan<- *prometheus.Desc)
Describe sends the super-set of all possible descriptors of metrics collected by this Collector.
type ClusterInfoMetric ¶
type ClusterInfoMetric struct {
// contains filtered or unexported fields
}
ClusterInfoMetric is a prometheus.Metric used to encode the local cluster info
func (ClusterInfoMetric) Desc ¶
func (cim ClusterInfoMetric) Desc() *prometheus.Desc
Desc returns the descriptor for the Metric. This method idempotently returns the same descriptor throughout the lifetime of the Metric.
type CoefficientComponent ¶
CoefficientComponent is a representative struct holding two fields which describe an interval as part of a single number cost coefficient calculation: 1. Proportion: The division of cost based on how many pods were running between those points 2. Time: The ratio of the time between those points to the total time that pod was running
type ContainerInfo ¶
type ContainerMetric ¶
type ContainerMetric struct { Namespace string PodName string ContainerName string NodeName string ClusterID string // contains filtered or unexported fields }
ContainerMetric contains a set of identifiers specific to a kubernetes container including a unique string key
func NewContainerMetricFromKey ¶
func NewContainerMetricFromKey(key string) (*ContainerMetric, error)
NewContainerMetricFromKey creates a new ContainerMetric instance using a provided comma delimitted string key.
func NewContainerMetricFromPrometheus ¶
func NewContainerMetricFromPrometheus(metrics map[string]interface{}, defaultClusterID string) (*ContainerMetric, error)
NewContainerMetricFromPrometheus accepts the metrics map from a QueryResult and returns a new ContainerMetric instance
func NewContainerMetricFromValues ¶
func NewContainerMetricFromValues(ns, podName, containerName, nodeName, clusterId string) *ContainerMetric
NewContainerMetricFromValues creates a new ContainerMetric instance using the provided string parameters.
func NewContainerMetricsFromPod ¶
func NewContainerMetricsFromPod(pod *v1.Pod, clusterID string) ([]*ContainerMetric, error)
NewContainerMetricsFromPod creates a slice of ContainerMetric instances for each container in the provided Pod.
func (*ContainerMetric) Key ¶
func (c *ContainerMetric) Key() string
Key returns a unique string key that can be used in map[string]interface{}
type CostData ¶
type CostData struct { Name string `json:"name,omitempty"` PodName string `json:"podName,omitempty"` NodeName string `json:"nodeName,omitempty"` NodeData *costAnalyzerCloud.Node `json:"node,omitempty"` Namespace string `json:"namespace,omitempty"` Deployments []string `json:"deployments,omitempty"` Services []string `json:"services,omitempty"` Daemonsets []string `json:"daemonsets,omitempty"` Statefulsets []string `json:"statefulsets,omitempty"` Jobs []string `json:"jobs,omitempty"` RAMReq []*util.Vector `json:"ramreq,omitempty"` RAMUsed []*util.Vector `json:"ramused,omitempty"` RAMAllocation []*util.Vector `json:"ramallocated,omitempty"` CPUReq []*util.Vector `json:"cpureq,omitempty"` CPUUsed []*util.Vector `json:"cpuused,omitempty"` CPUAllocation []*util.Vector `json:"cpuallocated,omitempty"` GPUReq []*util.Vector `json:"gpureq,omitempty"` PVCData []*PersistentVolumeClaimData `json:"pvcData,omitempty"` NetworkData []*util.Vector `json:"network,omitempty"` Annotations map[string]string `json:"annotations,omitempty"` Labels map[string]string `json:"labels,omitempty"` NamespaceLabels map[string]string `json:"namespaceLabels,omitempty"` ClusterID string `json:"clusterId"` ClusterName string `json:"clusterName"` }
func (*CostData) GetController ¶
type CostModel ¶
type CostModel struct { Cache clustercache.ClusterCache ClusterMap clusters.ClusterMap MaxPrometheusQueryDuration time.Duration RequestGroup *singleflight.Group ScrapeInterval time.Duration PrometheusClient prometheus.Client Provider costAnalyzerCloud.Provider // contains filtered or unexported fields }
func NewCostModel ¶
func NewCostModel(client prometheus.Client, provider costAnalyzerCloud.Provider, cache clustercache.ClusterCache, clusterMap clusters.ClusterMap, scrapeInterval time.Duration) *CostModel
func (*CostModel) CanCompute ¶
CanCompute should return true if CostModel can act as a valid source for the given time range. In the case of CostModel we want to attempt to compute as long as the range starts in the past. If the CostModel ends up not having data to match, that's okay, and should be communicated with an error response from ComputeAllocation.
func (*CostModel) ClusterDisks ¶
func (*CostModel) ClusterLoadBalancers ¶
func (cm *CostModel) ClusterLoadBalancers(start, end time.Time) (map[LoadBalancerIdentifier]*LoadBalancer, error)
func (*CostModel) ClusterNodes ¶
func (*CostModel) ComputeAllocation ¶
func (cm *CostModel) ComputeAllocation(start, end time.Time, resolution time.Duration) (*kubecost.AllocationSet, error)
ComputeAllocation uses the CostModel instance to compute an AllocationSet for the window defined by the given start and end times. The Allocations returned are unaggregated (i.e. down to the container level).
func (*CostModel) ComputeAssets ¶
func (*CostModel) ComputeCostData ¶
func (*CostModel) ComputeCostDataRange ¶
func (cm *CostModel) ComputeCostDataRange(cli prometheusClient.Client, cp costAnalyzerCloud.Provider, window kubecost.Window, resolution time.Duration, filterNamespace string, filterCluster string, remoteEnabled bool) (map[string]*CostData, error)
ComputeCostDataRange executes a range query for cost data. Note that "offset" represents the time between the function call and "endString", and is also passed for convenience
func (*CostModel) DateRange ¶
DateRange checks the data (up to 90 days in the past), and returns the oldest and newest sample timestamp from openghg scraping metric it supposed to be a good indicator of available allocation data
func (*CostModel) GetLBCost ¶
func (cm *CostModel) GetLBCost(cp costAnalyzerCloud.Provider) (map[serviceKey]*costAnalyzerCloud.LoadBalancer, error)
TODO: drop some logs
func (*CostModel) GetNodeCost ¶
func (cm *CostModel) GetNodeCost(cp costAnalyzerCloud.Provider) (map[string]*costAnalyzerCloud.Node, error)
func (*CostModel) GetPricingSourceCounts ¶
func (cm *CostModel) GetPricingSourceCounts() (*costAnalyzerCloud.PricingMatchMetadata, error)
func (*CostModel) PropertiesFromCluster ¶
func (cm *CostModel) PropertiesFromCluster(props *kubecost.AssetProperties)
propertiesFromCluster populates static cluster properties to individual asset properties
func (*CostModel) QueryAllocation ¶
func (cm *CostModel) QueryAllocation(window kubecost.Window, resolution, step time.Duration, aggregate []string, includeIdle, idleByNode, includeProportionalAssetResourceCosts, includeAggregatedMetadata, sharedLoadBalancer bool, accumulateBy kubecost.AccumulateOption) (*kubecost.AllocationSetRange, error)
type CostModelMetricsEmitter ¶
type CostModelMetricsEmitter struct { PrometheusClient promclient.Client KubeClusterCache clustercache.ClusterCache CloudProvider models.Provider Model *CostModel // Metrics CPUPriceRecorder *prometheus.GaugeVec RAMPriceRecorder *prometheus.GaugeVec PersistentVolumePriceRecorder *prometheus.GaugeVec GPUPriceRecorder *prometheus.GaugeVec GPUCountRecorder *prometheus.GaugeVec PVAllocationRecorder *prometheus.GaugeVec NodeSpotRecorder *prometheus.GaugeVec NodeTotalPriceRecorder *prometheus.GaugeVec RAMAllocationRecorder *prometheus.GaugeVec CPUAllocationRecorder *prometheus.GaugeVec GPUAllocationRecorder *prometheus.GaugeVec ClusterManagementCostRecorder *prometheus.GaugeVec LBCostRecorder *prometheus.GaugeVec NetworkZoneEgressRecorder prometheus.Gauge NetworkRegionEgressRecorder prometheus.Gauge NetworkInternetEgressRecorder prometheus.Gauge // contains filtered or unexported fields }
CostModelMetricsEmitter emits all cost-model specific metrics calculated by the CostModel.ComputeCostData() method.
func NewCostModelMetricsEmitter ¶
func NewCostModelMetricsEmitter(promClient promclient.Client, clusterCache clustercache.ClusterCache, provider models.Provider, clusterInfo clusters.ClusterInfoProvider, model *CostModel) *CostModelMetricsEmitter
NewCostModelMetricsEmitter creates a new cost-model metrics emitter. Use Start() to begin metric emission.
func (*CostModelMetricsEmitter) IsRunning ¶
func (cmme *CostModelMetricsEmitter) IsRunning() bool
IsRunning returns true if metric recording is running.
func (*CostModelMetricsEmitter) Start ¶
func (cmme *CostModelMetricsEmitter) Start() bool
StartCostModelMetricRecording starts the go routine that emits metrics used to determine cluster costs.
func (*CostModelMetricsEmitter) Stop ¶
func (cmme *CostModelMetricsEmitter) Stop()
Stop halts the metrics emission loop after the current emission is completed or if the emission is paused.
type Disk ¶
type Disk struct { Cluster string Name string ProviderID string StorageClass string VolumeName string ClaimName string ClaimNamespace string Cost float64 Bytes float64 // These two fields may not be available at all times because they rely on // a new set of metrics that may or may not be available. Thus, they must // be nilable to represent the complete absence of the data. // // In other words, nilability here lets us distinguish between // "metric is not available" and "metric is available but is 0". // // They end in "Ptr" to distinguish from an earlier version in order to // ensure that all usages are checked for nil. BytesUsedAvgPtr *float64 BytesUsedMaxPtr *float64 Local bool Start time.Time End time.Time Minutes float64 Breakdown *ClusterCostsBreakdown }
type DiskIdentifier ¶
type EmptyDataError ¶
type EmptyDataError struct {
// contains filtered or unexported fields
}
EmptyDataError describes an error caused by empty cost data for some defined interval
func (*EmptyDataError) Error ¶
func (ede *EmptyDataError) Error() string
Error implements the error interface
type FilterFunc ¶
FilterFunc is a filter that returns true iff the given CostData should be filtered out, and the environment that was used as the filter criteria, if it was an aggregate
type InstallInfo ¶
type InstallInfo struct { Containers []ContainerInfo `json:"containers"` ClusterInfo map[string]string `json:"clusterInfo"` Version string `json:"version"` }
type IntervalPoint ¶
IntervalPoint describes a start or end of a window of time Currently, this used in PVC-pod relations to detect/calculate coefficients for PV cost when a PVC is shared between pods.
func NewIntervalPoint ¶
func NewIntervalPoint(time time.Time, pointType string, key podKey) IntervalPoint
NewIntervalPoint creates and returns a new IntervalPoint instance with given parameters.
type IntervalPoints ¶
type IntervalPoints []IntervalPoint
IntervalPoints describes a slice of IntervalPoint structs
func (IntervalPoints) Len ¶
func (ips IntervalPoints) Len() int
Requisite functions for implementing sort.Sort for IntervalPointList
func (IntervalPoints) Less ¶
func (ips IntervalPoints) Less(i, j int) bool
func (IntervalPoints) Swap ¶
func (ips IntervalPoints) Swap(i, j int)
type KeyTuple ¶
type KeyTuple struct {
// contains filtered or unexported fields
}
KeyTuple contains is a utility which parses Namespace, Key, and ClusterID from a comma delimitted string.
func NewKeyTuple ¶
NewKeyTuple creates a new KeyTuple instance by determining the exact indices of each tuple entry. When each component is requested, a string slice is returned using the boundaries.
type LoadBalancer ¶
type LoadBalancerIdentifier ¶
type LogLevelRequestResponse ¶
type LogLevelRequestResponse struct {
Level string `json:"level"`
}
type NetworkUsageData ¶
type NetworkUsageData struct { ClusterID string PodName string Namespace string NetworkZoneEgress []*util.Vector NetworkRegionEgress []*util.Vector NetworkInternetEgress []*util.Vector }
NetworkUsageVNetworkUsageDataector contains the network usage values for egress network traffic
type NetworkUsageVector ¶
type NetworkUsageVector struct { ClusterID string PodName string Namespace string Values []*util.Vector }
NetworkUsageVector contains a network usage vector for egress network traffic
type Node ¶
type Node struct { Cluster string Name string ProviderID string NodeType string CPUCost float64 CPUCores float64 GPUCost float64 GPUCount float64 RAMCost float64 RAMBytes float64 Discount float64 Preemptible bool CPUBreakdown *ClusterCostsBreakdown RAMBreakdown *ClusterCostsBreakdown Start time.Time End time.Time Minutes float64 Labels map[string]string CostPerCPUHr float64 CostPerRAMGiBHr float64 CostPerGPUHr float64 Overhead *NodeOverhead }
type NodeCostAverages ¶
type NodeCostAverages struct { CpuCostAverage float64 RamCostAverage float64 NumCpuDataPoints float64 NumRamDataPoints float64 }
NodeCostAverages tracks a running average of a node's cost attributes. The averages are used to detect and discard spurrious outliers.
type NodeIdentifier ¶
type NodeOverhead ¶
type PersistentVolumeClaimData ¶
type PersistentVolumeClaimData struct { Class string `json:"class"` Claim string `json:"claim"` Namespace string `json:"namespace"` ClusterID string `json:"clusterId"` TimesClaimed int `json:"timesClaimed"` VolumeName string `json:"volumeName"` Volume *costAnalyzerCloud.PV `json:"persistentVolume"` Values []*util.Vector `json:"values"` }
type SharedCostInfo ¶
type SharedCostInfo struct {}
type SharedResourceInfo ¶
type SharedResourceInfo struct {}
func NewSharedResourceInfo ¶
func NewSharedResourceInfo(shareResources bool, sharedNamespaces []string, labelNames []string, labelValues []string) *SharedResourceInfo
func (*SharedResourceInfo) IsSharedResource ¶
func (s *SharedResourceInfo) IsSharedResource(costDatum *CostData) bool
func (*SharedResourceInfo) String ¶
func (s *SharedResourceInfo) String() string
String returns a string representation of the encapsulated shared resources, which can be used to uniquely identify a set of shared resources. Sorting sets of shared resources ensures that strings representing permutations of the same combination match.