Documentation ¶
Index ¶
- Constants
- Variables
- func MaxAggregate(values []int64) int64
- func MinAggregate(values []int64) int64
- func SumAggregate(values []int64) int64
- type AggregationMode
- type AggregationModes
- type CachedResources
- type DataPoint
- type DataPoints
- type Label
- type Metric
- type MetricClient
- type MetricPoint
- type MetricPromise
- type MetricPromises
- type MetricResultList
- type ResourceSelector
- type SidecarMetric
- type SidecarMetricResultList
Constants ¶
const ( SumAggregation = "sum" MaxAggregation = "max" MinAggregation = "min" DefaultAggregation = SumAggregation )
Aggregation modes which should be used for data aggregation. Eg. [sum, min, max].
const ( CpuUsage = "cpu/usage_rate" MemoryUsage = "memory/usage" )
Variables ¶
var AggregatingFunctions = map[AggregationMode]func([]int64) int64{ SumAggregation: SumAggregate, MaxAggregation: MaxAggregate, MinAggregation: MinAggregate, }
var DerivedResources = map[api.ResourceKind]api.ResourceKind{ api.ResourceKindDeployment: api.ResourceKindPod, api.ResourceKindReplicaSet: api.ResourceKindPod, api.ResourceKindReplicationController: api.ResourceKindPod, api.ResourceKindDaemonSet: api.ResourceKindPod, api.ResourceKindStatefulSet: api.ResourceKindPod, api.ResourceKindJob: api.ResourceKindPod, }
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.
var NoResourceCache = &CachedResources{}
var OnlyDefaultAggregation = AggregationModes{DefaultAggregation}
var OnlySumAggregation = AggregationModes{SumAggregation}
Functions ¶
func MaxAggregate ¶
func MinAggregate ¶
func SumAggregate ¶
Types ¶
type AggregationMode ¶
type AggregationMode string
AggregationMode informs how data should be aggregated (sum, min, max)
type AggregationModes ¶
type AggregationModes []AggregationMode
type CachedResources ¶
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 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 ¶
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) AddMetricPoint ¶
func (metric *Metric) AddMetricPoint(item MetricPoint) []MetricPoint
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 MetricPromise ¶
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 MetricResultList ¶
type MetricResultList struct {
Items []Metric `json:"items"`
}
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.
type SidecarMetric ¶
type SidecarMetric 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. UIDs []string `json:"uids"` }
SidecarMetric is a format of data used by our sidecar. This is also the format of data that is being sent by backend API.
func (*SidecarMetric) AddMetricPoint ¶
func (metric *SidecarMetric) AddMetricPoint(item MetricPoint) []MetricPoint
type SidecarMetricResultList ¶
type SidecarMetricResultList struct {
Items []SidecarMetric `json:"items"`
}