measure

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package measure provides functionality for measuring/retrieving metrics from the K8s metrics server.

Package measure provides K8s metric gathering, in the same way that the Horizontal Pod Autoscaler gathers metrics, using the metrics APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExternalMetricSource

type ExternalMetricSource struct {
	Metric autoscaling.MetricIdentifier `json:"metric"`
	Target MetricTarget                 `json:"target"`
}

ExternalMetricSource defines gathering metrics for a metric not associated with any Kubernetes object (for example length of queue in cloud messaging service, or QPS from loadbalancer running outside of cluster).

type Gather

type Gather struct {
	Resource resource.Gatherer
	Pods     pods.Gatherer
	Object   object.Gatherer
	External external.Gatherer
}

Gather provides functionality for retrieving metrics on supplied metric specs.

func NewGather

func NewGather(
	metricsClient metricsclient.MetricsClient,
	podlister corelisters.PodLister,
	cpuInitializationPeriod time.Duration,
	delayOfInitialReadinessStatus time.Duration) *Gather

NewGather sets up a new Metric Gatherer

func (*Gather) GetMetrics

func (c *Gather) GetMetrics(resource metav1.Object, specs []MetricSpec, namespace string) ([]*Metric, error)

GetMetrics processes each MetricSpec provided, calculating metric values for each and combining them into a slice before returning them. Error will only be returned if all metrics are invalid, otherwise it will return the valid metrics.

type Gatherer

type Gatherer interface {
	GetMetrics(resource metav1.Object, specs []MetricSpec, namespace string) ([]*Metric, error)
}

Gatherer allows retrieval of metrics.

type Metric

type Metric struct {
	CurrentReplicas int32            `json:"current_replicas"`
	Spec            MetricSpec       `json:"spec"`
	Resource        *resource.Metric `json:"resource,omitempty"`
	Pods            *pods.Metric     `json:"pods,omitempty"`
	Object          *object.Metric   `json:"object,omitempty"`
	External        *external.Metric `json:"external,omitempty"`
}

Metric is a metric that has been retrieved from the K8s metrics server

type MetricSpec

type MetricSpec struct {
	Type     autoscaling.MetricSourceType `json:"type"`
	Object   *ObjectMetricSource          `json:"object,omitempty"`
	Pods     *PodsMetricSource            `json:"pods,omitempty"`
	Resource *ResourceMetricSource        `json:"resource,omitempty"`
	External *ExternalMetricSource        `json:"external,omitempty"`
}

MetricSpec defines which metrics to query from the metrics server

type MetricTarget

type MetricTarget struct {
	Type autoscaling.MetricTargetType `json:"type"`
}

MetricTarget defines the type of metric gathering, either target value, average value, or average utilization of a specific metric

type ObjectMetricSource

type ObjectMetricSource struct {
	DescribedObject autoscaling.CrossVersionObjectReference `json:"describedObject"`
	Metric          autoscaling.MetricIdentifier            `json:"metric"`
	Target          MetricTarget                            `json:"target"`
}

ObjectMetricSource defines gathering metrics for a kubernetes object (for example, hits-per-second on an Ingress object).

type PodsMetricSource

type PodsMetricSource struct {
	Metric autoscaling.MetricIdentifier `json:"metric"`
	Target MetricTarget                 `json:"target"`
}

PodsMetricSource defines gathering metrics describing each pod in the current scale target (for example, transactions-processed-per-second).

type ResourceMetricSource

type ResourceMetricSource struct {
	Name   v1.ResourceName `json:"name" protobuf:"bytes,1,name=name"`
	Target MetricTarget    `json:"target"`
}

ResourceMetricSource defines gathering metrics for a resource metric known to Kubernetes, as specified in requests and limits, describing each pod in the current scale target (e.g. CPU or memory). Such metrics are built in to Kubernetes.

Directories

Path Synopsis
Package value represents a computed value for a metric, can be either a raw value or an average value
Package value represents a computed value for a metric, can be either a raw value or an average value

Jump to

Keyboard shortcuts

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