metrics

package
v0.0.0-...-be2354b Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2021 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHeapsterNamespace = "kube-system"
	DefaultHeapsterScheme    = "http"
	DefaultHeapsterService   = "heapster"
	DefaultHeapsterPort      = "" // use the first exposed port on the service

)

Variables

This section is empty.

Functions

func GetMetricUtilizationRatio

func GetMetricUtilizationRatio(metrics PodMetricsInfo, targetUtilization int64) (utilizationRatio float64, currentUtilization int64)

GetMetricUtilizationRatio takes in a set of metrics and a target utilization value, and calculates the ratio of desired to actual utilization (returning that and the actual utilization)

func GetResourceUtilizationRatio

func GetResourceUtilizationRatio(metrics PodMetricsInfo, requests map[string]int64, targetUtilization int32) (utilizationRatio float64, currentUtilization int32, rawAverageValue int64, err error)

GetResourceUtilizationRatio takes in a set of metrics, a set of matching requests, and a target utilization percentage, and calculates the ratio of desired to actual utilization (returning that, the actual utilization, and the raw average value)

Types

type HeapsterMetricsClient

type HeapsterMetricsClient struct {
	// contains filtered or unexported fields
}

func (*HeapsterMetricsClient) GetExternalMetric

func (h *HeapsterMetricsClient) GetExternalMetric(metricName, namespace string, selector labels.Selector) ([]int64, time.Time, error)

func (*HeapsterMetricsClient) GetObjectMetric

func (h *HeapsterMetricsClient) GetObjectMetric(metricName string, namespace string, objectRef *autoscaling.CrossVersionObjectReference, metricSelector labels.Selector) (int64, time.Time, error)

func (*HeapsterMetricsClient) GetRawMetric

func (h *HeapsterMetricsClient) GetRawMetric(metricName string, namespace string, selector labels.Selector, metricSelector labels.Selector) (PodMetricsInfo, time.Time, error)

func (*HeapsterMetricsClient) GetResourceMetric

func (h *HeapsterMetricsClient) GetResourceMetric(resource v1.ResourceName, namespace string, selector labels.Selector, container string) (PodMetricsInfo, time.Time, error)

type MetricsClient

type MetricsClient interface {
	// GetResourceMetric gets the given resource metric (and an associated oldest timestamp)
	// for all pods matching the specified selector in the given namespace
	GetResourceMetric(resource v1.ResourceName, namespace string, selector labels.Selector, container string) (PodMetricsInfo, time.Time, error)

	// GetRawMetric gets the given metric (and an associated oldest timestamp)
	// for all pods matching the specified selector in the given namespace
	GetRawMetric(metricName string, namespace string, selector labels.Selector, metricSelector labels.Selector) (PodMetricsInfo, time.Time, error)

	// GetObjectMetric gets the given metric (and an associated timestamp) for the given
	// object in the given namespace
	GetObjectMetric(metricName string, namespace string, objectRef *autoscaling.CrossVersionObjectReference, metricSelector labels.Selector) (int64, time.Time, error)

	// GetExternalMetric gets all the values of a given external metric
	// that match the specified selector.
	GetExternalMetric(metricName string, namespace string, selector labels.Selector) ([]int64, time.Time, error)
}

MetricsClient knows how to query a remote interface to retrieve container-level resource metrics as well as pod-level arbitrary metrics

func NewHeapsterMetricsClient

func NewHeapsterMetricsClient(client clientset.Interface, namespace, scheme, service, port string) MetricsClient

type PodMetric

type PodMetric struct {
	Timestamp time.Time
	Window    time.Duration
	Value     int64
}

PodMetric contains pod metric value (the metric values are expected to be the metric as a milli-value)

type PodMetricsInfo

type PodMetricsInfo map[string]PodMetric

PodMetricsInfo contains pod metrics as a map from pod names to PodMetricsInfo

type PrometheusMetricServer

type PrometheusMetricServer struct{}

PrometheusMetricServer the type of MetricsServer

func (PrometheusMetricServer) NewServer

func (metricsServer PrometheusMetricServer) NewServer(address string, pattern string)

NewServer creates a new http serving instance of prometheus metrics

func (PrometheusMetricServer) RecordHPAScalerError

func (metricsServer PrometheusMetricServer) RecordHPAScalerError(namespace string, scaledObject string, scaler string, scalerIndex int, metric string, err error)

RecordHPAScalerError counts the number of errors occurred in trying get an external metric used by the HPA

func (PrometheusMetricServer) RecordHPAScalerMetric

func (metricsServer PrometheusMetricServer) RecordHPAScalerMetric(namespace string, scaledObject string, scaler string, scalerIndex int, metric string, value int64)

RecordHPAScalerMetric create a measurement of the external metric used by the HPA

func (PrometheusMetricServer) RecordScalerObjectError

func (metricsServer PrometheusMetricServer) RecordScalerObjectError(namespace string, scaledObject string, err error)

RecordScalerObjectError counts the number of errors with the scaled object

type Server

type Server interface {
	NewServer(address string, pattern string)
	RecordScalerError(namespace string, scaledObject string, scaler string, scalerIndex int, metric string, err error)
	RecordScalerMetric(namespace string, scaledObject string, scaler string, scalerIndex int, metric string, value int64)
	RecordScalerObjectError(namespace string, scaledObject string, err error)
}

Server an HTTP serving instance to track metrics

Jump to

Keyboard shortcuts

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