collector

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2023 License: Apache-2.0 Imports: 35 Imported by: 0

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

View Source
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
)
View Source
const (
	Undefined = "undefined"
)

Variables

View Source
var InvalidContainerUtilizationInitialLevelOperations = sets.NewString("sum", "")
View Source
var (
	KeepAnnotations = []string{
		"workload-name", "workload-kind", "workload-api-group", "workload-api-version",
		"kubernetes.io/hostname", corev1.MirrorPodAnnotationKey,
	}
)
View Source
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

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

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

func (c *Collector) InitInformers(ctx context.Context) error

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) Run

func (c *Collector) Run(ctx context.Context)

Start runs the collector

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 JSONLine added in v0.2.0

type JSONLine struct {
	MetricName string            `json:"metricName"`
	Timestamp  time.Time         `json:"timestamp"`
	Value      float64           `json:"value"`
	Labels     map[string]string `json:"labels"`
}

type LabelOverrider

type LabelOverrider interface {
	// OverrideLabels takes as an arg a map of all labels for a sample and returns
	// a map of labels to change the values of.
	OverrideLabels(map[string]string) map[string]string
}

type LabelOverriderFn

type LabelOverriderFn func(map[string]string) map[string]string

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 MissingContainerID struct {
	PodNamespace  string
	PodName       string
	ContainerName string
	NodeName      string
	ID            sampler.ContainerKey
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL