Documentation ¶
Index ¶
- Variables
- func ClusterKey() string
- func GcmLabels() map[string]LabelDescriptor
- func NamespaceKey(namespace string) string
- func NodeContainerKey(node, container string) string
- func NodeKey(node string) string
- func PodContainerKey(namespace, podName, containerName string) string
- func PodKey(namespace, podName string) string
- type DataBatch
- type DataProcessor
- type DataSink
- type LabelDescriptor
- type LabeledMetric
- type Metric
- type MetricDescriptor
- type MetricSet
- type MetricType
- type MetricValue
- type MetricsSource
- type MetricsSourceProvider
- type UnitsType
- type ValueType
Constants ¶
This section is empty.
Variables ¶
View Source
var ( LabelMetricSetType = LabelDescriptor{ Key: "type", Description: "Type of the metrics set (container, pod, namespace, node, cluster)", } MetricSetTypeSystemContainer = "sys_container" MetricSetTypePodContainer = "pod_container" MetricSetTypePod = "pod" MetricSetTypeNamespace = "ns" MetricSetTypeNode = "node" MetricSetTypeCluster = "cluster" LabelPodId = LabelDescriptor{ Key: "pod_id", Description: "The unique ID of the pod", } LabelPodName = LabelDescriptor{ Key: "pod_name", Description: "The name of the pod", } // Deprecated label LabelPodNamespace = LabelDescriptor{ Key: "pod_namespace", Description: "The namespace of the pod", } LabelNamespaceName = LabelDescriptor{ Key: "namespace_name", Description: "The name of the namespace", } LabelPodNamespaceUID = LabelDescriptor{ Key: "namespace_id", Description: "The UID of namespace of the pod", } LabelContainerName = LabelDescriptor{ Key: "container_name", Description: "User-provided name of the container or full container name for system containers", } LabelLabels = LabelDescriptor{ Key: "labels", Description: "Comma-separated list of user-provided labels", } LabelNodename = LabelDescriptor{ Key: "nodename", Description: "nodename where the container ran", } LabelHostname = LabelDescriptor{ Key: "hostname", Description: "Hostname where the container ran", } LabelResourceID = LabelDescriptor{ Key: "resource_id", Description: "Identifier(s) specific to a metric", } LabelHostID = LabelDescriptor{ Key: "host_id", Description: "Identifier specific to a host. Set by cloud provider or user", } LabelContainerBaseImage = LabelDescriptor{ Key: "container_base_image", Description: "User-defined image name that is run inside the container", } // The label is populated only for GCM LabelCustomMetricName = LabelDescriptor{ Key: "custom_metric_name", Description: "User-defined name of the exported custom metric", } )
View Source
var AdditionalMetrics = []Metric{ MetricCpuRequest, MetricCpuLimit, MetricMemoryRequest, MetricMemoryLimit}
Metrics computed based on cluster state using Kubernetes API.
View Source
var AllMetrics = append(append(append(StandardMetrics, AdditionalMetrics...), RateMetrics...), LabeledMetrics...)
View Source
var LabeledMetrics = []Metric{ MetricFilesystemUsage, MetricFilesystemLimit, }
View Source
var MetricCpuLimit = Metric{ MetricDescriptor: MetricDescriptor{ Name: "cpu/limit", Description: "CPU hard limit in millicores.", Type: MetricGauge, ValueType: ValueInt64, Units: UnitsCount, }, }
View Source
var MetricCpuRequest = Metric{ MetricDescriptor: MetricDescriptor{ Name: "cpu/request", Description: "CPU request (the guaranteed amount of resources) in millicores. This metric is Kubernetes specific.", Type: MetricGauge, ValueType: ValueInt64, Units: UnitsCount, }, }
Definition of Additional Metrics.
View Source
var MetricCpuUsage = Metric{ MetricDescriptor: MetricDescriptor{ Name: "cpu/usage", Description: "Cumulative CPU usage on all cores", Type: MetricCumulative, ValueType: ValueInt64, Units: UnitsNanoseconds, }, HasValue: func(spec *cadvisor.ContainerSpec) bool { return spec.HasCpu }, GetValue: func(spec *cadvisor.ContainerSpec, stat *cadvisor.ContainerStats) MetricValue { return MetricValue{ ValueType: ValueInt64, MetricType: MetricCumulative, IntValue: int64(stat.Cpu.Usage.Total), Start: spec.CreationTime} }, }
View Source
var MetricCpuUsageRate = Metric{ MetricDescriptor: MetricDescriptor{ Name: "cpu/usage_rate", Description: "CPU usage on all cores in millicores", Type: MetricGauge, ValueType: ValueInt64, Units: UnitsCount, }, }
Definition of Rate Metrics.
View Source
var MetricFilesystemLimit = Metric{ MetricDescriptor: MetricDescriptor{ Name: "filesystem/limit", Description: "The total size of filesystem in bytes", Type: MetricGauge, ValueType: ValueInt64, Units: UnitsBytes, Labels: metricLabels, }, HasLabeledMetric: func(spec *cadvisor.ContainerSpec) bool { return spec.HasFilesystem }, GetLabeledMetric: func(spec *cadvisor.ContainerSpec, stat *cadvisor.ContainerStats) []LabeledMetric { result := make([]LabeledMetric, 0, len(stat.Filesystem)) for _, fs := range stat.Filesystem { result = append(result, LabeledMetric{ Name: "filesystem/limit", Labels: map[string]string{ LabelResourceID.Key: fs.Device, }, ValueType: ValueInt64, MetricType: MetricCumulative, IntValue: int64(fs.Limit), }) } return result }, }
View Source
var MetricFilesystemUsage = Metric{ MetricDescriptor: MetricDescriptor{ Name: "filesystem/usage", Description: "Total number of bytes consumed on a filesystem", Type: MetricGauge, ValueType: ValueInt64, Units: UnitsBytes, Labels: metricLabels, }, HasLabeledMetric: func(spec *cadvisor.ContainerSpec) bool { return spec.HasFilesystem }, GetLabeledMetric: func(spec *cadvisor.ContainerSpec, stat *cadvisor.ContainerStats) []LabeledMetric { result := make([]LabeledMetric, 0, len(stat.Filesystem)) for _, fs := range stat.Filesystem { result = append(result, LabeledMetric{ Name: "filesystem/usage", Labels: map[string]string{ LabelResourceID.Key: fs.Device, }, ValueType: ValueInt64, MetricType: MetricCumulative, IntValue: int64(fs.Usage), }) } return result }, }
View Source
var MetricMemoruUsage = Metric{ MetricDescriptor: MetricDescriptor{ Name: "memory/usage", Description: "Total memory usage", Type: MetricGauge, ValueType: ValueInt64, Units: UnitsBytes, }, HasValue: func(spec *cadvisor.ContainerSpec) bool { return spec.HasMemory }, GetValue: func(spec *cadvisor.ContainerSpec, stat *cadvisor.ContainerStats) MetricValue { return MetricValue{ ValueType: ValueInt64, MetricType: MetricGauge, IntValue: int64(stat.Memory.Usage)} }, }
View Source
var MetricMemoryLimit = Metric{ MetricDescriptor: MetricDescriptor{ Name: "memory/limit", Description: "Memory hard limit in bytes.", Type: MetricGauge, ValueType: ValueInt64, Units: UnitsBytes, }, }
View Source
var MetricMemoryMajorPageFaults = Metric{ MetricDescriptor: MetricDescriptor{ Name: "memory/major_page_faults", Description: "Number of major page faults", Type: MetricCumulative, ValueType: ValueInt64, Units: UnitsCount, }, HasValue: func(spec *cadvisor.ContainerSpec) bool { return spec.HasMemory }, GetValue: func(spec *cadvisor.ContainerSpec, stat *cadvisor.ContainerStats) MetricValue { return MetricValue{ ValueType: ValueInt64, MetricType: MetricCumulative, IntValue: int64(stat.Memory.ContainerData.Pgmajfault), Start: spec.CreationTime} }, }
View Source
var MetricMemoryMajorPageFaultsRate = Metric{ MetricDescriptor: MetricDescriptor{ Name: "memory/major_page_faults_rate", Description: "Rate of major page faults in counts per second", Type: MetricGauge, ValueType: ValueFloat, Units: UnitsCount, }, }
View Source
var MetricMemoryPageFaults = Metric{ MetricDescriptor: MetricDescriptor{ Name: "memory/page_faults", Description: "Number of page faults", Type: MetricCumulative, ValueType: ValueInt64, Units: UnitsCount, }, HasValue: func(spec *cadvisor.ContainerSpec) bool { return spec.HasMemory }, GetValue: func(spec *cadvisor.ContainerSpec, stat *cadvisor.ContainerStats) MetricValue { return MetricValue{ ValueType: ValueInt64, MetricType: MetricCumulative, IntValue: int64(stat.Memory.ContainerData.Pgfault), Start: spec.CreationTime} }, }
View Source
var MetricMemoryPageFaultsRate = Metric{ MetricDescriptor: MetricDescriptor{ Name: "memory/page_faults_rate", Description: "Rate of page faults in counts per second", Type: MetricGauge, ValueType: ValueFloat, Units: UnitsCount, }, }
View Source
var MetricMemoryRequest = Metric{ MetricDescriptor: MetricDescriptor{ Name: "memory/request", Description: "Memory request (the guaranteed amount of resources) in bytes. This metric is Kubernetes specific.", Type: MetricGauge, ValueType: ValueInt64, Units: UnitsBytes, }, }
View Source
var MetricMemoryWorkingSet = Metric{ MetricDescriptor: MetricDescriptor{ Name: "memory/working_set", Description: "Total working set usage. Working set is the memory being used and not easily dropped by the kernel", Type: MetricGauge, ValueType: ValueInt64, Units: UnitsBytes, }, HasValue: func(spec *cadvisor.ContainerSpec) bool { return spec.HasMemory }, GetValue: func(spec *cadvisor.ContainerSpec, stat *cadvisor.ContainerStats) MetricValue { return MetricValue{ ValueType: ValueInt64, MetricType: MetricGauge, IntValue: int64(stat.Memory.WorkingSet)} }, }
View Source
var MetricNetworkRx = Metric{ MetricDescriptor: MetricDescriptor{ Name: "network/rx", Description: "Cumulative number of bytes received over the network", Type: MetricCumulative, ValueType: ValueInt64, Units: UnitsBytes, }, HasValue: func(spec *cadvisor.ContainerSpec) bool { return spec.HasNetwork }, GetValue: func(spec *cadvisor.ContainerSpec, stat *cadvisor.ContainerStats) MetricValue { return MetricValue{ ValueType: ValueInt64, MetricType: MetricCumulative, IntValue: int64(stat.Network.RxBytes), Start: spec.CreationTime} }, }
View Source
var MetricNetworkRxErrors = Metric{ MetricDescriptor: MetricDescriptor{ Name: "network/rx_errors", Description: "Cumulative number of errors while receiving over the network", Type: MetricCumulative, ValueType: ValueInt64, Units: UnitsCount, }, HasValue: func(spec *cadvisor.ContainerSpec) bool { return spec.HasNetwork }, GetValue: func(spec *cadvisor.ContainerSpec, stat *cadvisor.ContainerStats) MetricValue { return MetricValue{ ValueType: ValueInt64, MetricType: MetricCumulative, IntValue: int64(stat.Network.RxErrors), Start: spec.CreationTime} }, }
View Source
var MetricNetworkRxErrorsRate = Metric{ MetricDescriptor: MetricDescriptor{ Name: "network/rx_errors_rate", Description: "Rate of errors sending over the network in errors per second", Type: MetricGauge, ValueType: ValueFloat, Units: UnitsCount, }, }
View Source
var MetricNetworkRxRate = Metric{ MetricDescriptor: MetricDescriptor{ Name: "network/rx_rate", Description: "Rate of bytes received over the network in bytes per second", Type: MetricGauge, ValueType: ValueFloat, Units: UnitsCount, }, }
View Source
var MetricNetworkTx = Metric{ MetricDescriptor: MetricDescriptor{ Name: "network/tx", Description: "Cumulative number of bytes sent over the network", Type: MetricCumulative, ValueType: ValueInt64, Units: UnitsBytes, }, HasValue: func(spec *cadvisor.ContainerSpec) bool { return spec.HasNetwork }, GetValue: func(spec *cadvisor.ContainerSpec, stat *cadvisor.ContainerStats) MetricValue { return MetricValue{ ValueType: ValueInt64, MetricType: MetricCumulative, IntValue: int64(stat.Network.TxBytes), Start: spec.CreationTime} }, }
View Source
var MetricNetworkTxErrors = Metric{ MetricDescriptor: MetricDescriptor{ Name: "network/tx_errors", Description: "Cumulative number of errors while sending over the network", Type: MetricCumulative, ValueType: ValueInt64, Units: UnitsCount, }, HasValue: func(spec *cadvisor.ContainerSpec) bool { return spec.HasNetwork }, GetValue: func(spec *cadvisor.ContainerSpec, stat *cadvisor.ContainerStats) MetricValue { return MetricValue{ ValueType: ValueInt64, MetricType: MetricCumulative, IntValue: int64(stat.Network.TxErrors), Start: spec.CreationTime} }, }
View Source
var MetricNetworkTxErrorsRate = Metric{ MetricDescriptor: MetricDescriptor{ Name: "network/tx_errors_rate", Description: "Rate of errors transmitting over the network in errors per second", Type: MetricGauge, ValueType: ValueFloat, Units: UnitsCount, }, }
View Source
var MetricNetworkTxRate = Metric{ MetricDescriptor: MetricDescriptor{ Name: "network/tx_rate", Description: "Rate of bytes transmitted over the network in bytes per second", Type: MetricGauge, ValueType: ValueFloat, Units: UnitsCount, }, }
View Source
var MetricUptime = Metric{ MetricDescriptor: MetricDescriptor{ Name: "uptime", Description: "Number of milliseconds since the container was started", Type: MetricCumulative, ValueType: ValueInt64, Units: UnitsMilliseconds, }, HasValue: func(spec *cadvisor.ContainerSpec) bool { return !spec.CreationTime.IsZero() }, GetValue: func(spec *cadvisor.ContainerSpec, stat *cadvisor.ContainerStats) MetricValue { return MetricValue{ ValueType: ValueInt64, MetricType: MetricCumulative, IntValue: time.Since(spec.CreationTime).Nanoseconds() / time.Millisecond.Nanoseconds(), Start: spec.CreationTime} }, }
Definition of Standard Metrics.
View Source
var RateMetrics = []Metric{ MetricCpuUsageRate, MetricMemoryPageFaultsRate, MetricMemoryMajorPageFaultsRate, MetricNetworkRxRate, MetricNetworkRxErrorsRate, MetricNetworkTxRate, MetricNetworkTxErrorsRate}
Computed based on corresponding StandardMetrics.
View Source
var RateMetricsMapping = map[string]Metric{ MetricCpuUsage.MetricDescriptor.Name: MetricCpuUsageRate, MetricMemoryPageFaults.MetricDescriptor.Name: MetricMemoryPageFaultsRate, MetricMemoryMajorPageFaults.MetricDescriptor.Name: MetricMemoryMajorPageFaultsRate, MetricNetworkRx.MetricDescriptor.Name: MetricNetworkRxRate, MetricNetworkRxErrors.MetricDescriptor.Name: MetricNetworkRxErrorsRate, MetricNetworkTx.MetricDescriptor.Name: MetricNetworkTxRate, MetricNetworkTxErrors.MetricDescriptor.Name: MetricNetworkTxErrorsRate}
View Source
var StandardMetrics = []Metric{ MetricUptime, MetricCpuUsage, MetricMemoruUsage, MetricMemoryWorkingSet, MetricMemoryPageFaults, MetricMemoryMajorPageFaults, MetricNetworkRx, MetricNetworkRxErrors, MetricNetworkTx, MetricNetworkTxErrors}
Provided by Kubelet/cadvisor.
Functions ¶
func ClusterKey ¶
func ClusterKey() string
func GcmLabels ¶
func GcmLabels() map[string]LabelDescriptor
func NamespaceKey ¶
func NodeContainerKey ¶
func PodContainerKey ¶
Types ¶
type DataProcessor ¶
type DataSink ¶
type DataSink interface { Name() string // Exports data to the external storge. The funciton should be synchronous/blocking and finish only // after the given DataBatch was written. This will allow sink manager to push data only to these // sinks that finished writing the previous data. ExportData(*DataBatch) Stop() }
type LabelDescriptor ¶
type LabelDescriptor struct { // Key to use for the label. Key string `json:"key,omitempty"` // Description of the label. Description string `json:"description,omitempty"` }
func CommonLabels ¶
func CommonLabels() []LabelDescriptor
func ContainerLabels ¶
func ContainerLabels() []LabelDescriptor
func MetricLabels ¶
func MetricLabels() []LabelDescriptor
func PodLabels ¶
func PodLabels() []LabelDescriptor
func SupportedLabels ¶
func SupportedLabels() []LabelDescriptor
type LabeledMetric ¶
type Metric ¶
type Metric struct { MetricDescriptor // Returns whether this metric is present. HasValue func(*cadvisor.ContainerSpec) bool // Returns a slice of internal point objects that contain metric values and associated labels. GetValue func(*cadvisor.ContainerSpec, *cadvisor.ContainerStats) MetricValue // Returns whether this metric is present. HasLabeledMetric func(*cadvisor.ContainerSpec) bool // Returns a slice of internal point objects that contain metric values and associated labels. GetLabeledMetric func(*cadvisor.ContainerSpec, *cadvisor.ContainerStats) []LabeledMetric }
Metric represents a resource usage stat metric.
type MetricDescriptor ¶
type MetricDescriptor struct { // The unique name of the metric. Name string `json:"name,omitempty"` // Description of the metric. Description string `json:"description,omitempty"` // Descriptor of the labels specific to this metric. Labels []LabelDescriptor `json:"labels,omitempty"` // Type and value of metric data. Type MetricType `json:"type,omitempty"` ValueType ValueType `json:"value_type,omitempty"` Units UnitsType `json:"units,omitempty"` }
type MetricSet ¶
type MetricSet struct { MetricValues map[string]MetricValue Labels map[string]string LabeledMetrics []LabeledMetric }
type MetricType ¶
type MetricType int8
const ( MetricCumulative MetricType = iota MetricGauge )
func (*MetricType) String ¶
func (self *MetricType) String() string
type MetricValue ¶
type MetricsSource ¶
A place from where the metrics should be scraped.
type MetricsSourceProvider ¶
type MetricsSourceProvider interface {
GetMetricsSources() []MetricsSource
}
Provider of list of sources to be scaped.
Click to show internal directories.
Click to hide internal directories.