Documentation ¶
Index ¶
- func ExportBucketInfo(ctx context.Context, client *BucketClient, projects []string, ...) error
- func ExportGCPCostData(ctx context.Context, client *billingv1.CloudCatalogClient, serviceName string, ...) float64
- func ExportRegionalDiscounts(ctx context.Context, client RegionsClient, projectID string, discount int, ...) error
- func ExporterOperationsDiscounts(m *Metrics)
- func OpClassFromSkuDescription(s string) string
- func RegionNameSameAsStackdriver(s string) string
- func StorageClassFromSkuDescription(s string, region string) string
- type BucketCache
- type BucketClient
- 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 Metrics
- type RegionsClient
- type StorageClientInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExportBucketInfo ¶
func ExportBucketInfo(ctx context.Context, client *BucketClient, projects []string, cachedBuckets *BucketCache, m *Metrics) error
ExportBucketInfo will list all buckets for a given project and export the data as a prometheus metric. If there are any errors listing buckets, it will export the cached buckets for the project.
func ExportGCPCostData ¶
func ExportGCPCostData(ctx context.Context, client *billingv1.CloudCatalogClient, serviceName string, m *Metrics) float64
ExportGCPCostData will collect all the pricing information for the passed in serviceName and export cost related metrics for each sku
func ExportRegionalDiscounts ¶
func ExporterOperationsDiscounts ¶
func ExporterOperationsDiscounts(m *Metrics)
func OpClassFromSkuDescription ¶
OpClassFromSkuDescription normalizes sku description to one of the following: - If the opsclass contains Class A, it's "class-a" - If the opsclass contains Class B, it's "class-b" - Otherwise, return the original opsclass
func RegionNameSameAsStackdriver ¶
RegionNameSameAsStackdriver will normalize region collectorName to be the same as what Stackdriver uses. Google Cost API returns region names exactly the same how they are referred in StackDriver metrics except one case: For Europe multi-region: API returns "europe", while Stackdriver uses "eu" label value.
func StorageClassFromSkuDescription ¶
StorageClassFromSkuDescription normalize sku description to match the output from stackdriver exporter
Types ¶
type BucketCache ¶
type BucketCache struct { Buckets map[string][]*storage.BucketAttrs // contains filtered or unexported fields }
func NewBucketCache ¶
func NewBucketCache() *BucketCache
func (*BucketCache) Get ¶
func (c *BucketCache) Get(project string) []*storage.BucketAttrs
func (*BucketCache) Set ¶
func (c *BucketCache) Set(project string, buckets []*storage.BucketAttrs)
type BucketClient ¶
type BucketClient struct {
// contains filtered or unexported fields
}
func NewBucketClient ¶
func NewBucketClient(client StorageClientInterface) *BucketClient
func (*BucketClient) List ¶
func (bc *BucketClient) List(ctx context.Context, project string) ([]*storage.BucketAttrs, error)
TODO: Return an interface of the storage.BucketAttrs
type Collector ¶
type Collector struct { ProjectID string Projects []string CachedBuckets *BucketCache // contains filtered or unexported fields }
func New ¶
func New(config *Config, cloudCatalogClient *billingv1.CloudCatalogClient, regionsClient RegionsClient, storageClient StorageClientInterface) (*Collector, error)
func (*Collector) CheckReadiness ¶ added in v0.3.0
func (*Collector) CollectMetrics ¶
func (c *Collector) CollectMetrics(ch chan<- prometheus.Metric) float64
CollectMetrics is by `c.Collect` and can likely be refactored directly into `c.Collect`
type Metrics ¶
type Metrics struct { StorageGauge *prometheus.GaugeVec StorageDiscountGauge *prometheus.GaugeVec OperationsGauge *prometheus.GaugeVec OperationsDiscountGauge *prometheus.GaugeVec BucketInfo *prometheus.GaugeVec BucketListHistogram *prometheus.HistogramVec BucketListStatus *prometheus.CounterVec NextScrapeGauge prometheus.Gauge }
func NewMetrics ¶
func NewMetrics() *Metrics
type RegionsClient ¶
type RegionsClient interface {
List(ctx context.Context, req *computepb.ListRegionsRequest, opts ...gax.CallOption) *compute.RegionIterator
}
type StorageClientInterface ¶
type StorageClientInterface interface {
Buckets(ctx context.Context, projectID string) *storage.BucketIterator
}