metrics

package
v0.8.18 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Overview

Copyright 2019 The Kubernetes Authors All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 The Kubernetes Authors All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 The Kubernetes Authors All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 The Kubernetes Authors All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2019 The Kubernetes Authors All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregation

type Aggregation string

Aggregation defines how measurements should be aggregated into data points.

const (
	// LastValue means last measurement overwrites previous measurements (gauge metric).
	LastValue Aggregation = "LastValue"
	// Sum means last measurement will be added onto previous measurements (counter metric).
	Sum Aggregation = "Sum"
)

type FakeInt64Metric

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

FakeInt64Metric implements Int64MetricInterface. FakeInt64Metric can be used as a test double for Int64MetricInterface, allowing inspection of the metrics.

func NewFakeInt64Metric

func NewFakeInt64Metric(name string, aggregation Aggregation, tagNames []string) *FakeInt64Metric

func (*FakeInt64Metric) ListMetrics

func (fake *FakeInt64Metric) ListMetrics() []Int64MetricRepresentation

ListMetrics returns a snapshot of the current metrics.

func (*FakeInt64Metric) Record

func (fake *FakeInt64Metric) Record(tags map[string]string, measurement int64) error

type Float64Metric

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

Float64Metric represents an float64 metric.

func NewFloat64Metric

func NewFloat64Metric(metricID MetricID, viewName string, description string, unit string, aggregation Aggregation, tagNames []string) (*Float64Metric, error)

NewFloat64Metric create a Float64Metric metrics, returns nil when viewName is empty.

func (*Float64Metric) Record

func (metric *Float64Metric) Record(tags map[string]string, measurement float64) error

Record records a measurement for the metric, with provided tags as metric labels.

type Float64MetricRepresentation added in v0.7.1

type Float64MetricRepresentation struct {
	// Name is the metric name.
	Name string
	// Labels contains all metric labels in key-value pair format.
	Labels map[string]string
	// Value is the value of the metric.
	Value float64
}

Float64MetricRepresentation represents a snapshot of a float64 metrics. This is used for inspecting metric internals.

func GetFloat64Metric added in v0.7.1

func GetFloat64Metric(metrics []Float64MetricRepresentation, name string, labels map[string]string,
	strictLabelMatching bool) (Float64MetricRepresentation, error)

GetFloat64Metric finds the metric matching provided name and labels. When strictLabelMatching is set to true, the founded metric labels are identical to the provided labels; when strictLabelMatching is set to false, the founded metric labels are a superset of the provided labels.

func ParsePrometheusMetrics added in v0.7.1

func ParsePrometheusMetrics(metricsText string) ([]Float64MetricRepresentation, error)

ParsePrometheusMetrics parses Prometheus formatted metrics into metrics under Float64MetricRepresentation.

Note: Prometheus's go library stores all counter/gauge-typed metric values under float64.

type Int64Metric

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

Int64Metric represents an int64 metric.

func NewInt64Metric

func NewInt64Metric(metricID MetricID, viewName string, description string, unit string, aggregation Aggregation, tagNames []string) (*Int64Metric, error)

NewInt64Metric create a Int64Metric metric, returns nil when viewName is empty.

func (*Int64Metric) Record

func (metric *Int64Metric) Record(tags map[string]string, measurement int64) error

Record records a measurement for the metric, with provided tags as metric labels.

type Int64MetricInterface

type Int64MetricInterface interface {
	// Record records a measurement for the metric, with provided tags as metric labels.
	Record(tags map[string]string, measurement int64) error
}

Int64MetricInterface is used to create test double for Int64Metric.

type Int64MetricRepresentation

type Int64MetricRepresentation struct {
	// Name is the metric name.
	Name string
	// Labels contains all metric labels in key-value pair format.
	Labels map[string]string
	// Value is the value of the metric.
	Value int64
}

Int64MetricRepresentation represents a snapshot of an int64 metrics. This is used for inspecting metric internals.

type MetricID added in v0.8.0

type MetricID string
const (
	CPURunnableTaskCountID  MetricID = "cpu/runnable_task_count"
	CPUUsageTimeID          MetricID = "cpu/usage_time"
	CPULoad1m               MetricID = "cpu/load_1m"
	CPULoad5m               MetricID = "cpu/load_5m"
	CPULoad15m              MetricID = "cpu/load_15m"
	ProblemCounterID        MetricID = "problem_counter"
	ProblemGaugeID          MetricID = "problem_gauge"
	DiskIOTimeID            MetricID = "disk/io_time"
	DiskWeightedIOID        MetricID = "disk/weighted_io"
	DiskAvgQueueLenID       MetricID = "disk/avg_queue_len"
	DiskOpsCountID          MetricID = "disk/operation_count"
	DiskMergedOpsCountID    MetricID = "disk/merged_operation_count"
	DiskOpsBytesID          MetricID = "disk/operation_bytes_count"
	DiskOpsTimeID           MetricID = "disk/operation_time"
	DiskBytesUsedID         MetricID = "disk/bytes_used"
	DiskPercentUsedID       MetricID = "disk/percent_used"
	HostUptimeID            MetricID = "host/uptime"
	MemoryBytesUsedID       MetricID = "memory/bytes_used"
	MemoryAnonymousUsedID   MetricID = "memory/anonymous_used"
	MemoryPageCacheUsedID   MetricID = "memory/page_cache_used"
	MemoryUnevictableUsedID MetricID = "memory/unevictable_used"
	MemoryDirtyUsedID       MetricID = "memory/dirty_used"
	MemoryPercentUsedID     MetricID = "memory/percent_used"
	OSFeatureID             MetricID = "system/os_feature"
	SystemProcessesTotal    MetricID = "system/processes_total"
	SystemProcsRunning      MetricID = "system/procs_running"
	SystemProcsBlocked      MetricID = "system/procs_blocked"
	SystemInterruptsTotal   MetricID = "system/interrupts_total"
	SystemCPUStat           MetricID = "system/cpu_stat"
	NetDevRxBytes           MetricID = "net/rx_bytes"
	NetDevRxPackets         MetricID = "net/rx_packets"
	NetDevRxErrors          MetricID = "net/rx_errors"
	NetDevRxDropped         MetricID = "net/rx_dropped"
	NetDevRxFifo            MetricID = "net/rx_fifo"
	NetDevRxFrame           MetricID = "net/rx_frame"
	NetDevRxCompressed      MetricID = "net/rx_compressed"
	NetDevRxMulticast       MetricID = "net/rx_multicast"
	NetDevTxBytes           MetricID = "net/tx_bytes"
	NetDevTxPackets         MetricID = "net/tx_packets"
	NetDevTxErrors          MetricID = "net/tx_errors"
	NetDevTxDropped         MetricID = "net/tx_dropped"
	NetDevTxFifo            MetricID = "net/tx_fifo"
	NetDevTxCollisions      MetricID = "net/tx_collisions"
	NetDevTxCarrier         MetricID = "net/tx_carrier"
	NetDevTxCompressed      MetricID = "net/tx_compressed"
)

type MetricMapping added in v0.8.0

type MetricMapping struct {
	// contains filtered or unexported fields
}
var MetricMap MetricMapping

func (*MetricMapping) AddMapping added in v0.8.0

func (mm *MetricMapping) AddMapping(metricID MetricID, viewName string)

func (*MetricMapping) ViewNameToMetricID added in v0.8.0

func (mm *MetricMapping) ViewNameToMetricID(viewName string) (MetricID, bool)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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