Documentation ¶
Index ¶
- Variables
- func ClusterNameFromInstance(instance types.Instance) string
- func ListComputeInstances(ctx context.Context, client ec2.EC2) ([]types.Reservation, error)
- func ListEBSVolumes(ctx context.Context, client ec2.EC2) ([]types.Volume, error)
- func ListOnDemandPrices(ctx context.Context, region string, client pricingClient.Pricing) ([]string, error)
- func ListSpotPrices(ctx context.Context, client ec2client.EC2) ([]ec2Types.SpotPrice, error)
- func ListStoragePrices(ctx context.Context, region string, client pricingClient.Pricing) ([]string, error)
- func NameFromVolume(volume types.Volume) string
- type Collector
- type ComputePricingMap
- func (cpm *ComputePricingMap) AddInstanceDetails(attributes InstanceAttributes)
- func (cpm *ComputePricingMap) AddToComputePricingMap(price float64, attribute InstanceAttributes) error
- func (cpm *ComputePricingMap) GenerateComputePricingMap(ondemandPrices []string, spotPrices []ec2Types.SpotPrice) error
- func (cpm *ComputePricingMap) GetPriceForInstanceType(region string, instanceType string) (*Prices, error)
- type Config
- type FamilyPricing
- type InstanceAttributes
- type Prices
- type StoragePricing
- type StoragePricingMap
Constants ¶
This section is empty.
Variables ¶
var ( ErrClientNotFound = errors.New("no client found") ErrGeneratePricingMap = errors.New("error generating pricing map") )
var ( InstanceCPUHourlyCostDesc = utils.GenerateDesc( cloudcostexporter.MetricPrefix, subsystem, utils.InstanceCPUCostSuffix, "The cpu cost a ec2 instance in USD/(core*h)", []string{"instance", "instance_id", "region", "family", "machine_type", "cluster_name", "price_tier", "architecture"}, ) InstanceMemoryHourlyCostDesc = utils.GenerateDesc( cloudcostexporter.MetricPrefix, subsystem, utils.InstanceMemoryCostSuffix, "The memory cost of a ec2 instance in USD/(GiB*h)", []string{"instance", "instance_id", "region", "family", "machine_type", "cluster_name", "price_tier", "architecture"}, ) InstanceTotalHourlyCostDesc = utils.GenerateDesc( cloudcostexporter.MetricPrefix, subsystem, utils.InstanceTotalCostSuffix, "The total cost of the ec2 instance in USD/h", []string{"instance", "instance_id", "region", "family", "machine_type", "cluster_name", "price_tier", "architecture"}, ) PersistentVolumeHourlyCostDesc = utils.GenerateDesc( cloudcostexporter.MetricPrefix, subsystem, utils.PersistentVolumeCostSuffix, "The cost of an AWS EBS Volume in USD/h.", []string{"persistentvolume", "region", "availability_zone", "disk", "type", "size_gib", "state"}, ) )
var ( ErrInstanceTypeAlreadyExists = errors.New("instance type already exists in the map") ErrParseAttributes = errors.New("error parsing attribute") ErrRegionNotFound = errors.New("no region found") ErrInstanceTypeNotFound = errors.New("no instance type found") ErrVolumeTypeNotFound = errors.New("volume type not found") ErrListSpotPrices = errors.New("error listing spot prices") ErrListOnDemandPrices = errors.New("error listing ondemand prices") ErrListStoragePrices = errors.New("error listing storage prices") )
Functions ¶
func ClusterNameFromInstance ¶
func ListComputeInstances ¶
func ListEBSVolumes ¶ added in v0.4.0
func ListOnDemandPrices ¶
func ListSpotPrices ¶
func ListStoragePrices ¶ added in v0.4.0
func NameFromVolume ¶ added in v0.4.0
Types ¶
type Collector ¶
type Collector struct { Regions []ec2Types.Region ScrapeInterval time.Duration NextComputeScrape time.Time NextStorageScrape time.Time // contains filtered or unexported fields }
Collector is a prometheus collector that collects metrics from AWS EKS clusters.
func New ¶
func New(config *Config, ps pricingClient.Pricing) *Collector
New creates an ec2 collector
func (*Collector) Collect ¶
func (c *Collector) Collect(ch chan<- prometheus.Metric) error
Collect satisfies the provider.Collector interface.
func (*Collector) CollectMetrics ¶
func (c *Collector) CollectMetrics(_ chan<- prometheus.Metric) float64
CollectMetrics is a no-op function that satisfies the provider.Collector interface. Deprecated: CollectMetrics is deprecated and will be removed in a future release.
type ComputePricingMap ¶ added in v0.4.0
type ComputePricingMap struct { // Regions is a map of region code to FamilyPricing // key is the region // value is a map of instance type to PriceTiers Regions map[string]*FamilyPricing InstanceDetails map[string]InstanceAttributes // contains filtered or unexported fields }
ComputePricingMap collects a map of FamilyPricing structs where the key is the region
func NewComputePricingMap ¶ added in v0.4.0
func NewComputePricingMap(l *slog.Logger) *ComputePricingMap
func (*ComputePricingMap) AddInstanceDetails ¶ added in v0.4.0
func (cpm *ComputePricingMap) AddInstanceDetails(attributes InstanceAttributes)
func (*ComputePricingMap) AddToComputePricingMap ¶ added in v0.4.0
func (cpm *ComputePricingMap) AddToComputePricingMap(price float64, attribute InstanceAttributes) error
AddToComputePricingMap adds a price to the compute pricing map. The price is weighted based upon the instance type's CPU and RAM.
func (*ComputePricingMap) GenerateComputePricingMap ¶ added in v0.4.0
func (cpm *ComputePricingMap) GenerateComputePricingMap(ondemandPrices []string, spotPrices []ec2Types.SpotPrice) error
GenerateComputePricingMap accepts a list of ondemand prices and a list of spot prices. The method needs to 1. Parse out the ondemand prices and generate a productTerm map for each instance type 2. Parse out spot prices and use the productTerm map to generate a spot price map
func (*ComputePricingMap) GetPriceForInstanceType ¶ added in v0.4.0
func (cpm *ComputePricingMap) GetPriceForInstanceType(region string, instanceType string) (*Prices, error)
type FamilyPricing ¶
FamilyPricing is a map of instance type to a list of PriceTiers where the key is the ec2 compute instance type
type InstanceAttributes ¶ added in v0.4.0
type InstanceAttributes struct { Region string `json:"regionCode"` InstanceType string `json:"instanceType"` VCPU string `json:"vcpu"` Memory string `json:"memory"` InstanceFamily string `json:"instanceFamily"` PhysicalProcessor string `json:"physicalProcessor"` Tenancy string `json:"tenancy"` MarketOption string `json:"marketOption"` OperatingSystem string `json:"operatingSystem"` ClockSpeed string `json:"clockSpeed"` UsageType string `json:"usageType"` }
InstanceAttributes represents ec2 instance attributes that are pulled from AWS api's describing instances. It's specifically pulled out of productTerm to enable usage during tests.
type StoragePricing ¶ added in v0.4.0
StoragePricing is a map where the key is the storage type and the value is the price
type StoragePricingMap ¶ added in v0.4.0
type StoragePricingMap struct { // Regions is a map of region code to StoragePricing // key is the region // value is a map of storage classes to prices Regions map[string]*StoragePricing // contains filtered or unexported fields }
StoragePricingMap collects a map of StoragePricing structs where the key is the region
func NewStoragePricingMap ¶ added in v0.4.0
func NewStoragePricingMap(l *slog.Logger) *StoragePricingMap
func (*StoragePricingMap) GenerateStoragePricingMap ¶ added in v0.4.0
func (spm *StoragePricingMap) GenerateStoragePricingMap(storagePrices []string) error
GenerateStoragePricingMap receives a json with all the prices of the available storage options It iterates over the storage classes and parses the price for each one.