metric

package
v3.29.4 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KubeletCAdvisorMetricsPath is the path where kubelet serves information about cadvisor.
	KubeletCAdvisorMetricsPath = "/metrics/cadvisor"
)
View Source
const KubeletPodsPath = "/pods"

KubeletPodsPath is the path where kubelet serves information about pods.

View Source
const StatsSummaryPath = "/stats/summary"

StatsSummaryPath is the path where kubelet serves a summary with several information.

Variables

This section is empty.

Functions

func AddUint64RawMetric

func AddUint64RawMetric(r definition.RawMetrics, name string, valuePtr *uint64)

AddUint64RawMetric adds a new metric to a RawMetrics if it exists

func CadvisorFetchFunc

func CadvisorFetchFunc(fetchAndFilterPrometheus prometheus.FetchAndFilterMetricsFamilies, queries []prometheus.Query) data.FetchFunc

CadvisorFetchFunc creates a FetchFunc that fetches data from the kubelet cadvisor metrics path.

func FromLabelGetNamespace added in v3.3.0

func FromLabelGetNamespace(metrics definition.RawMetrics) string

func FromRawEntityIDGroupEntityIDGenerator

func FromRawEntityIDGroupEntityIDGenerator(key string) definition.EntityIDGeneratorFunc

FromRawEntityIDGroupEntityIDGenerator generates an entityID from the raw entity ID which is composed of namespace and pod name. It's used only for k8s pods.

func FromRawGroupsEntityIDGenerator

func FromRawGroupsEntityIDGenerator(key string) definition.EntityIDGeneratorFunc

FromRawGroupsEntityIDGenerator generates an entityID from the pod name from kubelet. It's only used for k8s containers.

func FromRawGroupsEntityTypeGenerator

func FromRawGroupsEntityTypeGenerator(groupLabel string, rawEntityID string, groups definition.RawGroups, clusterName string) (string, error)

FromRawGroupsEntityTypeGenerator generates the entity type using the cluster name and group label. If group label is different than "namespace" or "node", then entity type is also composed of namespace. If group label is "container" then pod name is also included.

func FromRawWithFallbackToDefaultInterface

func FromRawWithFallbackToDefaultInterface(metricKey string) definition.FetchFunc

FromRawWithFallbackToDefaultInterface fetches network metrics from the raw groups, if the metric is not present it tries to find the default interface network metrics and gets the required metric from there.

func GetMetricsData

func GetMetricsData(c client.HTTPGetter) (*v1.Summary, error)

GetMetricsData calls kubelet /stats/summary endpoint and returns unmarshalled response

func GroupStatsSummary

func GroupStatsSummary(statsSummary *v1.Summary) (definition.RawGroups, []error)

GroupStatsSummary groups specific data for pods, containers and node

func OneAttributePerAllocatable

func OneAttributePerAllocatable(rawResources definition.FetchedValue) (definition.FetchedValue, error)

OneAttributePerAllocatable transforms a map of resources to FetchedValues type, which will be converted later to one attribute per allocatable resource.

The attribute names will be prefixed with `allocatable.`.

func OneAttributePerCapacity

func OneAttributePerCapacity(rawResources definition.FetchedValue) (definition.FetchedValue, error)

OneAttributePerCapacity transforms a map of resources to FetchedValues type, which will be converted later to one attribute per capacity resource.

The attribute names will be prefixed with `capacity.`.

func OneMetricPerLabel

func OneMetricPerLabel(rawLabels definition.FetchedValue) (definition.FetchedValue, error)

OneMetricPerLabel transforms a map of labels to FetchedValues type, which will be converted later to one metric per label. It also prefix the labels with 'label.'

func PrefixFromMapInt

func PrefixFromMapInt(prefix string) func(mapValue definition.FetchedValue) (definition.FetchedValue, error)

PrefixFromMapInt does the same as OneMetricPerLabel but for map[string]int and with configurable prefix. We need two separate functions because we must return a map from string to a concrete type, as that type will be later asserted and checked.

Types

type PodsFetcher

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

PodsFetcher queries the kubelet and fetches the information of pods running on the node. It contains an in-memory cache to store the results and avoid querying the kubelet multiple times in the same integration execution.

func NewPodsFetcher

func NewPodsFetcher(l *log.Logger, c client.HTTPGetter) *PodsFetcher

NewPodsFetcher returns a new PodsFetcher.

func (*PodsFetcher) DoPodsFetch

func (f *PodsFetcher) DoPodsFetch() (definition.RawGroups, error)

DoPodsFetch used to have a cache that was invalidated each execution of the integration TODO: could we move this to informers?

Jump to

Keyboard shortcuts

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