Documentation ¶
Index ¶
- Variables
- type Collector
- func (c *Collector) CheckReadiness() bool
- func (c *Collector) Collect(ch chan<- prometheus.Metric) error
- func (c *Collector) CollectMetrics(ch chan<- prometheus.Metric) float64
- func (c *Collector) Describe(ch chan<- *prometheus.Desc) error
- func (c *Collector) Name() string
- func (c *Collector) Register(registry provider.Registry) error
- type Config
- type FamilyPricing
- type MachineSpec
- type ParsedSkuData
- type PriceTier
- type PriceTiers
- type Prices
- type Resource
- type StoragePricing
- type StructuredPricingMap
Constants ¶
This section is empty.
Variables ¶
var ( NextScrapeDesc = prometheus.NewDesc( prometheus.BuildFQName(cloudcost_exporter.ExporterName, subsystem, "next_scrape"), "Next time GCP's compute submodule pricing map will be refreshed as unix timestamp", nil, nil, ) InstanceCPUHourlyCostDesc = prometheus.NewDesc( prometheus.BuildFQName(cloudcost_exporter.MetricPrefix, subsystem, "instance_cpu_usd_per_core_hour"), "The cpu cost a GCP Compute Instance in USD/(core*h)", []string{"instance", "region", "family", "machine_type", "project", "price_tier"}, nil, ) InstanceMemoryHourlyCostDesc = prometheus.NewDesc( prometheus.BuildFQName(cloudcost_exporter.MetricPrefix, subsystem, "instance_ram_usd_per_gib_hour"), "The memory cost of a GCP Compute Instance in USD/(GiB*h)", []string{"instance", "region", "family", "machine_type", "project", "price_tier"}, nil, ) )
var ( GkeClusterLabel = "goog-k8s-cluster-name" GkeRegionLabel = "goog-k8s-cluster-location" )
var ( SkuNotFound = errors.New("no sku was interested in us") SkuIsNil = errors.New("sku is nil") SkuNotParsable = errors.New("can't parse sku") SkuNotRelevant = errors.New("sku isn't relevant for the current use cases") PricingDataIsOff = errors.New("pricing data in sku isn't parsable") RegionNotFound = errors.New("region wasn't found in pricing map") FamilyTypeNotFound = errors.New("family wasn't found in pricing map for this region") )
var (
ListInstancesError = errors.New("no list price was found for the sku")
)
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector struct { PricingMap *StructuredPricingMap Projects []string NextScrape time.Time // contains filtered or unexported fields }
Collector implements the Collector interface for compute services in Compute.
func New ¶
func New(config *Config, computeService *compute.Service, billingService *billingv1.CloudCatalogClient) *Collector
New is a helper method to properly set up a compute.Collector struct.
func (*Collector) CheckReadiness ¶ added in v0.3.0
func (*Collector) CollectMetrics ¶
func (c *Collector) CollectMetrics(ch chan<- prometheus.Metric) float64
type FamilyPricing ¶
type FamilyPricing struct {
Family map[string]*PriceTiers
}
FamilyPricing is a map where the key is the family and the value is the price tiers
func NewMachineTypePricing ¶
func NewMachineTypePricing() *FamilyPricing
type MachineSpec ¶
type MachineSpec struct { Instance string Zone string Region string Family string MachineType string SpotInstance bool Labels map[string]string PriceTier string }
MachineSpec is a slimmed down representation of a google compute.Instance struct
func ListInstancesInZone ¶
func ListInstancesInZone(projectID, zone string, c *compute.Service) ([]*MachineSpec, error)
ListInstancesInZone will list all instances in a given zone and return a slice of MachineSpecs
func NewMachineSpec ¶
func NewMachineSpec(instance *compute.Instance) *MachineSpec
NewMachineSpec will create a new MachineSpec from compute.Instance objects. It's responsible for determining the machine family and region that it operates in
func (*MachineSpec) GetClusterName ¶
func (m *MachineSpec) GetClusterName() string
type ParsedSkuData ¶
type ParsedSkuData struct { Region string PriceTier PriceTier Price int32 Description string ComputeResource Resource }
func NewParsedSkuData ¶
type PriceTiers ¶
func NewPriceTiers ¶
func NewPriceTiers() *PriceTiers
type StoragePricing ¶
StoragePricing is a map where the key is the storage type and the value is the price
func NewStoragePricing ¶
func NewStoragePricing() *StoragePricing
type StructuredPricingMap ¶
type StructuredPricingMap struct { Compute map[string]*FamilyPricing Storage map[string]*StoragePricing }
StructuredPricingMap is a map of regions to a map of family to price tiers
func GeneratePricingMap ¶
func GeneratePricingMap(skus []*billingpb.Sku) (*StructuredPricingMap, error)
func NewStructuredPricingMap ¶
func NewStructuredPricingMap() *StructuredPricingMap
NewStructuredPricingMap returns a new StructuredPricingMap in a way that can be used afterwards.
func (*StructuredPricingMap) CheckReadiness ¶ added in v0.3.0
func (spm *StructuredPricingMap) CheckReadiness() bool
func (StructuredPricingMap) GetCostOfInstance ¶
func (m StructuredPricingMap) GetCostOfInstance(instance *MachineSpec) (float64, float64, error)
func (StructuredPricingMap) GetCostOfStorage ¶
func (m StructuredPricingMap) GetCostOfStorage(region, storageClass string) (float64, error)