Documentation
¶
Index ¶
- Variables
- func ClusterNameFromInstance(instance types.Instance) string
- func NameFromVolume(volume types.Volume) string
- func RegionsFromEC2Types(regions []types.Region) []string
- type AWSClient
- func (c *AWSClient) DescribeLoadBalancers(ctx context.Context) ([]elbTypes.LoadBalancer, error)
- func (c *AWSClient) DescribeRegions(ctx context.Context, allRegions bool) ([]types.Region, error)
- func (c *AWSClient) GetBillingData(ctx context.Context, startDate time.Time, endDate time.Time) (*BillingData, error)
- func (c *AWSClient) GetRDSUnitData(ctx context.Context, ...) (string, error)
- func (c *AWSClient) ListComputeInstances(ctx context.Context) ([]types.Reservation, error)
- func (c *AWSClient) ListEBSVolumes(ctx context.Context) ([]types.Volume, error)
- func (c *AWSClient) ListEC2ServicePrices(ctx context.Context, region string, filters []pricingTypes.Filter) ([]string, error)
- func (c *AWSClient) ListELBPrices(ctx context.Context, region string) ([]string, error)
- func (c *AWSClient) ListOnDemandPrices(ctx context.Context, region string) ([]string, error)
- func (c *AWSClient) ListRDSInstances(ctx context.Context) ([]rdsTypes.DBInstance, error)
- func (c *AWSClient) ListSpotPrices(ctx context.Context) ([]types.SpotPrice, error)
- func (c *AWSClient) ListStoragePrices(ctx context.Context, region string) ([]string, error)
- func (c *AWSClient) ListVPCServicePrices(ctx context.Context, region string, filters []pricingTypes.Filter) ([]string, error)
- func (c *AWSClient) Metrics() []prometheus.Collector
- type BillingData
- type Client
- type Config
- type Metrics
- type Pricing
- type PricingModel
Constants ¶
This section is empty.
Variables ¶
var BillingToRegionMap = map[string]string{
"APE1": "ap-east-1",
"APN1": "ap-northeast-1",
"APN2": "ap-northeast-2",
"APN3": "ap-northeast-3",
"APS1": "ap-southeast-1",
"APS2": "ap-southeast-2",
"APS3": "ap-south-1",
"APS4": "ap-southeast-3",
"APS5": "ap-south-2",
"APS6": "ap-southeast-4",
"CAN1": "ca-central-1",
"CNN1": "cn-north-1",
"CNW1": "cn-northwest-1",
"CPT1": "af-south-1",
"EUC1": "eu-central-1",
"EUC2": "eu-central-2",
"EU": "eu-west-1",
"EUW2": "eu-west-2",
"EUW3": "eu-west-3",
"EUN1": "eu-north-1",
"EUS1": "eu-south-1",
"EUS2": "eu-south-2",
"MEC1": "me-central-1",
"MES1": "me-south-1",
"SAE1": "sa-east-1",
"US": "us-east-1",
"USE1": "us-east-1",
"USE2": "us-east-2",
"USW1": "us-west-1",
"USW2": "us-west-2",
"AWS GovCloud (US-East)": "us-gov-east-1",
"AWS GovCloud (US)": "us-gov-west-1",
}
billingToRegionMap maps the AWS billing region code to the AWS region Billing codes: https://docs.aws.amazon.com/AmazonS3/latest/userguide/aws-usage-report-understand.html Regions: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-regions
Functions ¶
func ClusterNameFromInstance ¶
func NameFromVolume ¶
func RegionsFromEC2Types ¶ added in v0.28.1
RegionsFromEC2Types converts a slice of EC2 Region types to a slice of region name strings.
Types ¶
type AWSClient ¶
type AWSClient struct {
// contains filtered or unexported fields
}
func NewAWSClient ¶
func (*AWSClient) DescribeLoadBalancers ¶ added in v0.13.0
func (*AWSClient) DescribeRegions ¶
func (*AWSClient) GetBillingData ¶
func (*AWSClient) GetRDSUnitData ¶ added in v0.15.0
func (*AWSClient) ListComputeInstances ¶
func (*AWSClient) ListEBSVolumes ¶
func (*AWSClient) ListEC2ServicePrices ¶ added in v0.13.0
func (*AWSClient) ListELBPrices ¶ added in v0.13.0
func (*AWSClient) ListOnDemandPrices ¶
func (*AWSClient) ListRDSInstances ¶ added in v0.15.0
func (*AWSClient) ListSpotPrices ¶
func (*AWSClient) ListStoragePrices ¶
func (*AWSClient) ListVPCServicePrices ¶ added in v0.17.0
func (*AWSClient) Metrics ¶
func (c *AWSClient) Metrics() []prometheus.Collector
type BillingData ¶
type BillingData struct {
// Regions is a map where string is the region and PricingModel is the value
Regions map[string]*PricingModel
}
BillingData is the struct for the data we will be collecting
func (*BillingData) AddMetricGroup ¶
func (s *BillingData) AddMetricGroup(region string, component string, group types.Group)
AddMetricGroup adds a metric group to the Region. If the key is empty, it will not add the metric group to the Region. If the dimension is empty, it will not add the metric group to the Region. Dimensions are cumulative and will be added to the same dimension if the dimension already exists.
type Client ¶
type Client interface {
GetBillingData(ctx context.Context, startDate time.Time, endDate time.Time) (*BillingData, error)
DescribeRegions(ctx context.Context, allRegions bool) ([]types.Region, error)
ListComputeInstances(ctx context.Context) ([]types.Reservation, error)
ListEBSVolumes(ctx context.Context) ([]types.Volume, error)
ListSpotPrices(ctx context.Context) ([]types.SpotPrice, error)
ListOnDemandPrices(ctx context.Context, region string) ([]string, error)
ListStoragePrices(ctx context.Context, region string) ([]string, error)
ListEC2ServicePrices(ctx context.Context, region string, filters []pricingTypes.Filter) ([]string, error)
ListVPCServicePrices(ctx context.Context, region string, filters []pricingTypes.Filter) ([]string, error)
ListELBPrices(ctx context.Context, region string) ([]string, error)
DescribeLoadBalancers(ctx context.Context) ([]elbTypes.LoadBalancer, error)
ListRDSInstances(ctx context.Context) ([]rdsTypes.DBInstance, error)
GetRDSUnitData(ctx context.Context, instType, region, deploymentOption, engineCode, isOutpost string) (string, error)
// TODO: Break out Metrics into an independent interface
Metrics() []prometheus.Collector
}
type Config ¶
type Config struct {
PricingService p.Pricing
EC2Service e.EC2
BillingService c.CostExplorer
RDSService *rds.Client
ELBService elbv2client.ELBv2
}
type Metrics ¶
type Metrics struct {
// RequestCount is a counter that tracks the number of requests made to the AWS Cost Explorer API
RequestCount prometheus.Counter
// RequestErrorsCount is a counter that tracks the number of errors when making requests to the AWS Cost Explorer API
RequestErrorsCount prometheus.Counter
}
func NewMetrics ¶
func NewMetrics() *Metrics