Documentation ¶
Index ¶
- Variables
- func ClusterNameFromInstance(instance types.Instance) string
- func ListComputeInstances(ctx context.Context, client ec2.EC2) ([]types.Reservation, error)
- func ListOnDemandPrices(ctx context.Context, region string, client pricingClient.Pricing) ([]string, error)
- func ListSpotPrices(ctx context.Context, client ec2client.EC2) ([]ec2Types.SpotPrice, error)
- type Attributes
- type Collector
- func (c *Collector) CheckReadiness() bool
- func (c *Collector) Collect(ch chan<- prometheus.Metric) error
- func (c *Collector) CollectMetrics(_ chan<- prometheus.Metric) float64
- func (c *Collector) Describe(ch chan<- *prometheus.Desc) error
- func (c *Collector) Name() string
- func (c *Collector) Register(_ provider.Registry) error
- type Config
- type FamilyPricing
- type Prices
- type StructuredPricingMap
- func (spm *StructuredPricingMap) AddInstanceDetails(attributes Attributes)
- func (spm *StructuredPricingMap) AddToPricingMap(price float64, attribute Attributes) error
- func (spm *StructuredPricingMap) CheckReadiness() bool
- func (spm *StructuredPricingMap) GeneratePricingMap(ondemandPrices []string, spotPrices []ec2Types.SpotPrice) error
- func (spm *StructuredPricingMap) GetPriceForInstanceType(region string, instanceType string) (*Prices, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrClientNotFound = errors.New("no client found") ErrGeneratePricingMap = errors.New("error generating pricing map") )
var ( InstanceCPUHourlyCostDesc = prometheus.NewDesc( prometheus.BuildFQName(cloudcostexporter.MetricPrefix, subsystem, "instance_cpu_usd_per_core_hour"), "The cpu cost a ec2 instance in USD/(core*h)", []string{"instance", "region", "family", "machine_type", "cluster_name", "price_tier"}, nil, ) InstanceMemoryHourlyCostDesc = prometheus.NewDesc( prometheus.BuildFQName(cloudcostexporter.MetricPrefix, subsystem, "instance_memory_usd_per_gib_hour"), "The memory cost of a ec2 instance in USD/(GiB*h)", []string{"instance", "region", "family", "machine_type", "cluster_name", "price_tier"}, nil, ) InstanceTotalHourlyCostDesc = prometheus.NewDesc( prometheus.BuildFQName(cloudcostexporter.MetricPrefix, subsystem, "instance_total_usd_per_hour"), "The total cost of the ec2 instance in USD/h", []string{"instance", "region", "family", "machine_type", "cluster_name", "price_tier"}, nil, ) )
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") ErrListSpotPrices = errors.New("error listing spot prices") ErrListOnDemandPrices = errors.New("error listing ondemand prices") )
Functions ¶
func ClusterNameFromInstance ¶
func ListComputeInstances ¶
func ListOnDemandPrices ¶
Types ¶
type Attributes ¶
type Attributes 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"` }
Attributes 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 Collector ¶
type Collector struct { Regions []ec2Types.Region ScrapeInterval time.Duration NextScrape 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) CheckReadiness ¶ added in v0.3.0
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 FamilyPricing ¶
FamilyPricing is a map of instance type to a list of PriceTiers where the key is the ec2 compute instance type
type StructuredPricingMap ¶
type StructuredPricingMap 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]Attributes // contains filtered or unexported fields }
StructuredPricingMap collects a map of FamilyPricing structs where the key is the region
func NewStructuredPricingMap ¶
func NewStructuredPricingMap() *StructuredPricingMap
func (*StructuredPricingMap) AddInstanceDetails ¶
func (spm *StructuredPricingMap) AddInstanceDetails(attributes Attributes)
func (*StructuredPricingMap) AddToPricingMap ¶
func (spm *StructuredPricingMap) AddToPricingMap(price float64, attribute Attributes) error
AddToPricingMap adds a price to the pricing map. The price is weighted based upon the instance type's CPU and RAM.
func (*StructuredPricingMap) CheckReadiness ¶ added in v0.3.0
func (spm *StructuredPricingMap) CheckReadiness() bool
func (*StructuredPricingMap) GeneratePricingMap ¶
func (spm *StructuredPricingMap) GeneratePricingMap(ondemandPrices []string, spotPrices []ec2Types.SpotPrice) error
GeneratePricingMap 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 (*StructuredPricingMap) GetPriceForInstanceType ¶
func (spm *StructuredPricingMap) GetPriceForInstanceType(region string, instanceType string) (*Prices, error)