api

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SumAggregation     = "sum"
	MaxAggregation     = "max"
	MinAggregation     = "min"
	DefaultAggregation = SumAggregation
)

Aggregation modes which should be used for data aggregation. Eg. [sum, min, max].

View Source
const (
	CpuUsage    = "cpu/usage_rate"
	MemoryUsage = "memory/usage"
)

Variables

DerivedResources is a map from a derived resource(a resource that is not supported by heapster) to native resource (supported by heapster) to which derived resource should be converted. For example, deployment is not available in heapster so it has to be converted to its pods before downloading any data. Hence deployments map to pods.

View Source
var NoResourceCache = &CachedResources{}
View Source
var OnlyDefaultAggregation = AggregationModes{DefaultAggregation}
View Source
var OnlySumAggregation = AggregationModes{SumAggregation}

Functions

func MaxAggregate

func MaxAggregate(values []int64) int64

func MinAggregate

func MinAggregate(values []int64) int64

func SumAggregate

func SumAggregate(values []int64) int64

Types

type AggregationMode

type AggregationMode string

AggregationMode informs how data should be aggregated (sum, min, max)

type AggregationModes

type AggregationModes []AggregationMode

type CachedResources

type CachedResources struct {
	Pods []v1.Pod
}

CachedResources contains all resources that may be required by DataSelect functions for metric gathering. Depending on the need you may have to provide DataSelect with resources it requires, for example resource like deployment will need Pods in order to calculate its metrics.

type DataPoint

type DataPoint struct {
	X int64 `json:"x"`
	Y int64 `json:"y"`
}

type DataPoints

type DataPoints []DataPoint

type Label

type Label map[api.ResourceKind][]types.UID

Label stores information about identity of resources (UIDs) described by metric.

func (Label) AddMetricLabel

func (self Label) AddMetricLabel(other Label) Label

AddMetricLabel returns a unique combined Label of self and other resource. New label describes both resources.

type Metric

type Metric struct {
	// DataPoints is a list of X, Y int64 data points, sorted by X.
	DataPoints `json:"dataPoints"`
	// MetricPoints is a list of value, timestamp metrics used for sparklines on a pod list page.
	MetricPoints []MetricPoint `json:"metricPoints"`
	// MetricName is the name of metric stored in this struct.
	MetricName string `json:"metricName"`
	// Label stores information about identity of resources (UIDS) described by this metric.
	Label `json:"-"`
	// Names of aggregating function used.
	Aggregate AggregationMode `json:"aggregation,omitempty"`
}

Metric is a format of data used in this module. This is also the format of data that is being sent by backend API.

func (Metric) String

func (self Metric) String() string

String implements stringer interface to allow easy printing

type MetricClient

type MetricClient interface {
	// DownloadMetric returns MetricPromises for specified list of selector, for single type
	// of metric, i.e. cpu usage. Cached resources is usually list of pods as other high level
	// resources do not directly provide metrics. Only pods targeted by them.
	DownloadMetric(selectors []ResourceSelector, metricName string,
		cachedResources *CachedResources) MetricPromises
	// DownloadMetrics is similar to DownloadMetric method. It returns MetricPromises for
	// given list of metrics, i.e. cpu/memory usage instead of single metric type.
	DownloadMetrics(selectors []ResourceSelector, metricNames []string,
		cachedResources *CachedResources) MetricPromises
	// AggregateMetrics is used to aggregate previously downloaded metrics based on
	// aggregation mode (sum, min, avg). It is used to show cumulative metric graphs on
	// resource list pages.
	AggregateMetrics(metrics MetricPromises, metricName string,
		aggregations AggregationModes) MetricPromises

	// Implements IntegrationApp interface
	integrationapi.Integration
}

MetricClient is an interface that exposes API used by dashboard to show graphs and sparklines.

type MetricPoint

type MetricPoint struct {
	Timestamp time.Time `json:"timestamp"`
	Value     uint64    `json:"value"`
}

type MetricPromise

type MetricPromise struct {
	Metric chan *Metric
	Error  chan error
}

MetricPromise is used for parallel data extraction. Contains len 1 channels for Metric and Error.

func NewMetricPromise

func NewMetricPromise() MetricPromise

NewMetricPromise creates a MetricPromise structure with both channels of length 1.

func (MetricPromise) GetMetric

func (self MetricPromise) GetMetric() (*Metric, error)

GetMetric returns pointer to received Metrics and forwarded error (if any)

type MetricPromises

type MetricPromises []MetricPromise

func NewMetricPromises

func NewMetricPromises(length int) MetricPromises

NewMetricPromises returns a list of MetricPromises with requested length.

func (MetricPromises) GetMetrics

func (self MetricPromises) GetMetrics() ([]Metric, error)

GetMetrics returns all metrics from MetricPromises. In case of no metrics were downloaded it does not initialise []Metric and returns nil.

func (MetricPromises) PutMetrics

func (self MetricPromises) PutMetrics(metrics []Metric, err error)

PutMetrics forwards provided list of metrics to all channels. If provided err is not nil, error will be forwarded.

type ResourceSelector

type ResourceSelector struct {
	// Namespace of this resource.
	Namespace string
	// Type of this resource
	ResourceType api.ResourceKind
	// Name of this resource.
	ResourceName string
	// Selector used to identify this resource (should be used only for Deployments!).
	Selector map[string]string
	// UID is resource unique identifier.
	UID types.UID
}

ResourceSelector is a structure used to quickly and uniquely identify given resource. This struct can be later used for heapster data download etc.

Jump to

Keyboard shortcuts

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