Documentation ¶
Overview ¶
Package collector implements the metrics-prometheus-collector which exports metrics to prometheus when scraped.
Collector reads utilization metrics from the metrics-node-sampler, and other metrics directly from the Kubernetes objects.
Collector is highly configurable with respect to how metrics are labeled and aggregated at the time they are collected.
Package labels is responsible for parsing metric labels from Kubernetes objects
Index ¶
- Constants
- Variables
- func GetNewCacheFunc(c collectorcontrollerv1alpha1.MetricsPrometheusCollector) cache.NewCacheFunc
- func ProtoToJSON(s *collectorapi.SampleList, b *bytes.Buffer) error
- type Collector
- func (c *Collector) Collect(ch chan<- prometheus.Metric)
- func (c *Collector) Describe(ch chan<- *prometheus.Desc)
- func (c *Collector) InitInformers(ctx context.Context) error
- func (c *Collector) NewAggregatedSampleListBuilder(src string) *SampleListBuilder
- func (c *Collector) NewSampleListBuilder(src string) *SampleListBuilder
- func (c *Collector) NormalizeForSave(sr *collectorapi.ScrapeResult) error
- func (c *Collector) Run(ctx context.Context)
- func (c *Collector) SaveScrapeResultToFile(sr *collectorapi.ScrapeResult) error
- func (c *Collector) SaveScrapeResultToJSONFile(sr *collectorapi.ScrapeResult) error
- type JSONLine
- type LabelOverrider
- type LabelOverriderFn
- type Metric
- type MissingContainerID
- type SampleListBuilder
- func (sb *SampleListBuilder) AddIntValues(s *collectorapi.Sample, resourceType string, source string, v ...int64)
- func (sb *SampleListBuilder) AddQuantityValues(s *collectorapi.Sample, resourceType string, source string, ...)
- func (sb *SampleListBuilder) NewSample(labels labelsValues) *collectorapi.Sample
- func (sb *SampleListBuilder) SaveSamplesToFile() error
Constants ¶
const ( // MemoryRound defines infinite decimal precision for memory MemoryRound = 0 // CPUUSecRound defines infinite decimal precision for cpu usage seconds CPUUSecRound = 6 // CPUSecRound defines infinite decimal precision for cpu seconds CPUSecRound = 1 // AveragePrecision defines infinite decimal precision for averages AveragePrecision = 6 )
const MaxExtensionLabels = 100
const (
Undefined = "undefined"
)
Variables ¶
var InvalidContainerUtilizationInitialLevelOperations = sets.NewString("sum", "")
var ( KeepAnnotations = []string{ "workload-name", "workload-kind", "workload-api-group", "workload-api-version", "kubernetes.io/hostname", corev1.MirrorPodAnnotationKey, } )
var LabelOverrides []LabelOverrider
LabelOverrides may be appended to in order to explicitly override values To introduce a new label and override it, use an extension to create the label and then override it by appending to this list.
Functions ¶
func GetNewCacheFunc ¶
func GetNewCacheFunc(c collectorcontrollerv1alpha1.MetricsPrometheusCollector) cache.NewCacheFunc
GetNewCacheFunc returns a function which sets informer cache options to reduce memory consumption. * Delete labels and annotations that aren't used by the collector * Don't deep copy objects when reading from the cache
func ProtoToJSON ¶ added in v0.2.0
func ProtoToJSON(s *collectorapi.SampleList, b *bytes.Buffer) error
Types ¶
type Collector ¶
type Collector struct { client.Client UtilizationServer utilization.Server *collectorcontrollerv1alpha1.MetricsPrometheusCollector // contains filtered or unexported fields }
func NewCollector ¶
func NewCollector( ctx context.Context, client client.Client, config *collectorcontrollerv1alpha1.MetricsPrometheusCollector) (*Collector, error)
NewCollector returns a collector which publishes capacity and utilisation metrics.
func (*Collector) Collect ¶
func (c *Collector) Collect(ch chan<- prometheus.Metric)
Collect returns the current state of all metrics of the collector. This there are cached metrics, Collect will return the cached metrics.
func (*Collector) Describe ¶
func (c *Collector) Describe(ch chan<- *prometheus.Desc)
Describe returns all descriptions of the collector.
func (*Collector) InitInformers ¶
InitInformers initializes the informer caches by listing all the objects
func (*Collector) NewAggregatedSampleListBuilder ¶
func (c *Collector) NewAggregatedSampleListBuilder(src string) *SampleListBuilder
func (*Collector) NewSampleListBuilder ¶
func (c *Collector) NewSampleListBuilder(src string) *SampleListBuilder
func (*Collector) NormalizeForSave ¶ added in v0.2.0
func (c *Collector) NormalizeForSave(sr *collectorapi.ScrapeResult) error
func (*Collector) SaveScrapeResultToFile ¶
func (c *Collector) SaveScrapeResultToFile(sr *collectorapi.ScrapeResult) error
func (*Collector) SaveScrapeResultToJSONFile ¶ added in v0.2.0
func (c *Collector) SaveScrapeResultToJSONFile(sr *collectorapi.ScrapeResult) error
type LabelOverrider ¶
type LabelOverriderFn ¶
LabelOverriderFn simplifies writing override types
func (LabelOverriderFn) OverrideLabels ¶
func (l LabelOverriderFn) OverrideLabels(m map[string]string) map[string]string
type Metric ¶
type Metric struct { // Mask contains the set of labels that apply to this metric Mask collectorcontrollerv1alpha1.LabelsMask Name metricName Buckets map[string][]float64 // Values contains the metric values for each unique set of labels Values map[labelsValues][]resource.Quantity }
Metric contains all the values for a metric
type MissingContainerID ¶
type SampleListBuilder ¶
type SampleListBuilder struct { Mask collectorcontrollerv1alpha1.LabelsMask SourceType string DirectoryPath string Save bool TimeFormat string SampleList *collectorapi.SampleList C *Collector }
func (*SampleListBuilder) AddIntValues ¶
func (sb *SampleListBuilder) AddIntValues(s *collectorapi.Sample, resourceType string, source string, v ...int64)
AddIntValues adds a Metric to the sample with the provided values
func (*SampleListBuilder) AddQuantityValues ¶
func (sb *SampleListBuilder) AddQuantityValues(s *collectorapi.Sample, resourceType string, source string, v ...resource.Quantity)
AddQuantityValues adds a Metric to the sample with the provided values
func (*SampleListBuilder) NewSample ¶
func (sb *SampleListBuilder) NewSample(labels labelsValues) *collectorapi.Sample
NewSample creates a new Sample for an object
func (*SampleListBuilder) SaveSamplesToFile ¶
func (sb *SampleListBuilder) SaveSamplesToFile() error
SaveSamplesToFile writes the SampleList to a binary file with the timestamp