Documentation
¶
Index ¶
- Variables
- func AppendSupportedMetricObject(supported map[string]schema.GroupVersionResource)
- func GetSupportedMetricObject() map[string]schema.GroupVersionResource
- func Marshal(internalList []*InternalMetric) ([]byte, error)
- type CachedMetric
- func (c *CachedMetric) Add(dList ...*InternalMetric)
- func (c *CachedMetric) GC(expiredTime time.Time)
- func (c *CachedMetric) GetMetric(namespace, metricName string, gr *schema.GroupResource) ([]*InternalMetric, bool)
- func (c *CachedMetric) GetMetricInNamespace(namespace string) []*InternalMetric
- func (c *CachedMetric) GetMetricInNamespaceWithLimit(namespace string, limit int) []*InternalMetric
- func (c *CachedMetric) GetMetricWithLimit(namespace, metricName string, gr *schema.GroupResource, limit int) ([]*InternalMetric, bool)
- func (c *CachedMetric) ListAllMetric() []*InternalMetric
- func (c *CachedMetric) ListAllMetricMeta(withObject bool) []MetricMeta
- func (c *CachedMetric) ListAllMetricNames() []string
- type CustomMetricLabelAggregateFunc
- type CustomMetricLabelKey
- type InternalMetric
- func (a *InternalMetric) AppendMetric(i *InternalValue)
- func (a *InternalMetric) DeepCopy() *InternalMetric
- func (a *InternalMetric) DeepCopyWithLimit(limit int) *InternalMetric
- func (a *InternalMetric) GetLabels() map[string]string
- func (a *InternalMetric) GetValues() []*InternalValue
- func (a *InternalMetric) Len() int
- func (a *InternalMetric) Less(i, j int) bool
- func (a *InternalMetric) SetLabel(key, value string)
- func (a *InternalMetric) SetObjectNamespace(objectNamespace string)
- func (a *InternalMetric) String() string
- func (a *InternalMetric) Swap(i, j int)
- type InternalValue
- type MetricData
- type MetricMeta
- type MetricSeries
- type ObjectMeta
Constants ¶
This section is empty.
Variables ¶
var ValidCustomMetricLabelAggregateFuncMap = map[CustomMetricLabelAggregateFunc]interface{}{ CustomMetricLabelAggregateFuncMax: struct{}{}, CustomMetricLabelAggregateFuncMin: struct{}{}, CustomMetricLabelAggregateFuncP99: struct{}{}, CustomMetricLabelAggregateFuncP90: struct{}{}, CustomMetricLabelAggregateFuncP50: struct{}{}, CustomMetricLabelAggregateFuncAvg: struct{}{}, CustomMetricLabelAggregateFuncSum: struct{}{}, }
Functions ¶
func AppendSupportedMetricObject ¶
func AppendSupportedMetricObject(supported map[string]schema.GroupVersionResource)
func GetSupportedMetricObject ¶
func GetSupportedMetricObject() map[string]schema.GroupVersionResource
func Marshal ¶
func Marshal(internalList []*InternalMetric) ([]byte, error)
Types ¶
type CachedMetric ¶
CachedMetric stores all metricItems in an organized way;
func NewCachedMetric ¶
func NewCachedMetric() *CachedMetric
func (*CachedMetric) Add ¶
func (c *CachedMetric) Add(dList ...*InternalMetric)
func (*CachedMetric) GC ¶
func (c *CachedMetric) GC(expiredTime time.Time)
func (*CachedMetric) GetMetric ¶
func (c *CachedMetric) GetMetric(namespace, metricName string, gr *schema.GroupResource) ([]*InternalMetric, bool)
GetMetric returns the metric matched with the given key
func (*CachedMetric) GetMetricInNamespace ¶
func (c *CachedMetric) GetMetricInNamespace(namespace string) []*InternalMetric
GetMetricInNamespace returns the metric matched with the given Namespace
func (*CachedMetric) GetMetricInNamespaceWithLimit ¶
func (c *CachedMetric) GetMetricInNamespaceWithLimit(namespace string, limit int) []*InternalMetric
func (*CachedMetric) GetMetricWithLimit ¶
func (c *CachedMetric) GetMetricWithLimit(namespace, metricName string, gr *schema.GroupResource, limit int) ([]*InternalMetric, bool)
func (*CachedMetric) ListAllMetric ¶
func (c *CachedMetric) ListAllMetric() []*InternalMetric
ListAllMetric returns all metric with a flattened slice
func (*CachedMetric) ListAllMetricMeta ¶
func (c *CachedMetric) ListAllMetricMeta(withObject bool) []MetricMeta
ListAllMetricMeta returns all metric meta with a flattened slice
func (*CachedMetric) ListAllMetricNames ¶
func (c *CachedMetric) ListAllMetricNames() []string
ListAllMetricNames returns all metric with a flattened slice, but only contain names
type CustomMetricLabelAggregateFunc ¶
type CustomMetricLabelAggregateFunc string
const ( CustomMetricLabelAggregateFuncMax CustomMetricLabelAggregateFunc = "max" CustomMetricLabelAggregateFuncMin CustomMetricLabelAggregateFunc = "min" CustomMetricLabelAggregateFuncP99 CustomMetricLabelAggregateFunc = "p99" CustomMetricLabelAggregateFuncP90 CustomMetricLabelAggregateFunc = "p90" CustomMetricLabelAggregateFuncP50 CustomMetricLabelAggregateFunc = "p50" CustomMetricLabelAggregateFuncAvg CustomMetricLabelAggregateFunc = "avg" CustomMetricLabelAggregateFuncSum CustomMetricLabelAggregateFunc = "sum" )
type CustomMetricLabelKey ¶
type CustomMetricLabelKey string
const ( CustomMetricLabelKeyNamespace CustomMetricLabelKey = "namespace" CustomMetricLabelKeyObject CustomMetricLabelKey = "object" CustomMetricLabelKeyObjectName CustomMetricLabelKey = "object_name" CustomMetricLabelKeyTimestamp CustomMetricLabelKey = "timestamp" CustomMetricLabelSelectorPrefixKey CustomMetricLabelKey = "selector_" CustomMetricLabelAggregatePrefixKey CustomMetricLabelKey = "agg_" )
those const variables define the standard semantics of metric labels
CustomMetricLabelKeyNamespace defines the namespace; CustomMetricLabelKeyObject defines the standard kubernetes objects; CustomMetricLabelKeyObjectName defines the name of kubernetes objects; CustomMetricLabelKeyTimestamp defines the timestamp of this metric; CustomMetricLabelSelectorPrefixKey nominates those labels that should be used as selector; CustomMetricLabelAggregatePrefixKey means that we should do aggregations for metric with the same labels;
type InternalMetric ¶
type InternalMetric struct { MetricMeta `json:",inline"` ObjectMeta `json:",inline"` Labels map[string]string `json:"labels,omitempty"` InternalValue []*InternalValue `json:"internalValue,omitempty"` }
InternalMetric is used as an internal version of metricItem
func MergeInternalMetricList ¶
func MergeInternalMetricList(internalLists ...[]*InternalMetric) []*InternalMetric
MergeInternalMetricList merges internal metric lists and sort them, if the same timestamp appears in different list (which should happen actually), we will randomly choose one item.
func NewInternalMetric ¶
func NewInternalMetric(name string) *InternalMetric
func Unmarshal ¶
func Unmarshal(bytes []byte) ([]*InternalMetric, error)
func (*InternalMetric) AppendMetric ¶
func (a *InternalMetric) AppendMetric(i *InternalValue)
func (*InternalMetric) DeepCopy ¶
func (a *InternalMetric) DeepCopy() *InternalMetric
func (*InternalMetric) DeepCopyWithLimit ¶
func (a *InternalMetric) DeepCopyWithLimit(limit int) *InternalMetric
func (*InternalMetric) GetLabels ¶
func (a *InternalMetric) GetLabels() map[string]string
func (*InternalMetric) GetValues ¶
func (a *InternalMetric) GetValues() []*InternalValue
func (*InternalMetric) Len ¶
func (a *InternalMetric) Len() int
func (*InternalMetric) Less ¶
func (a *InternalMetric) Less(i, j int) bool
func (*InternalMetric) SetLabel ¶
func (a *InternalMetric) SetLabel(key, value string)
func (*InternalMetric) SetObjectNamespace ¶
func (a *InternalMetric) SetObjectNamespace(objectNamespace string)
func (*InternalMetric) String ¶
func (a *InternalMetric) String() string
func (*InternalMetric) Swap ¶
func (a *InternalMetric) Swap(i, j int)
type InternalValue ¶
type InternalValue struct { Value int64 `json:"value,omitempty"` Timestamp int64 `json:"timestamp,omitempty"` }
func NewInternalValue ¶
func NewInternalValue(value int64, timestamp int64) *InternalValue
func (*InternalValue) DeepCopy ¶
func (i *InternalValue) DeepCopy() *InternalValue
func (*InternalValue) GetTimestamp ¶
func (i *InternalValue) GetTimestamp() int64
func (*InternalValue) GetValue ¶
func (i *InternalValue) GetValue() int64
type MetricData ¶
type MetricMeta ¶
type MetricMeta struct { Name string `json:"name,omitempty"` Namespaced bool `json:"namespaced,omitempty"` ObjectKind string `json:"objectKind,omitempty"` }
func MergeMetricMetaList ¶
func MergeMetricMetaList(metricMetaLists ...[]MetricMeta) []MetricMeta
MergeMetricMetaList merges MetricMeta lists and removes duplicates
func (*MetricMeta) GetName ¶
func (m *MetricMeta) GetName() string
func (*MetricMeta) GetNamespaced ¶
func (m *MetricMeta) GetNamespaced() bool
func (*MetricMeta) GetObjectKind ¶
func (m *MetricMeta) GetObjectKind() string
func (*MetricMeta) SetName ¶
func (m *MetricMeta) SetName(name string)
func (*MetricMeta) SetNamespaced ¶
func (m *MetricMeta) SetNamespaced(namespaced bool)
func (*MetricMeta) SetObjectKind ¶
func (m *MetricMeta) SetObjectKind(objectKind string)
type MetricSeries ¶
type MetricSeries struct { Name string `json:"name,omitempty"` Labels map[string]string `json:"labels,omitempty"` Series []*MetricData `json:"series,omitempty"` }
type ObjectMeta ¶
type ObjectMeta struct { ObjectNamespace string `json:"objectNamespace,omitempty"` ObjectName string `json:"objectName,omitempty"` }
func (*ObjectMeta) GetObjectName ¶
func (m *ObjectMeta) GetObjectName() string
func (*ObjectMeta) GetObjectNamespace ¶
func (m *ObjectMeta) GetObjectNamespace() string
func (*ObjectMeta) SetObjectName ¶
func (m *ObjectMeta) SetObjectName(objectName string)
func (*ObjectMeta) SetObjectNamespace ¶
func (m *ObjectMeta) SetObjectNamespace(objectNamespace string)