metrics

package
v1.31.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 28 Imported by: 190

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MetricsGrabbingDisabledError = errors.New("metrics grabbing disabled")

MetricsGrabbingDisabledError is an error that is wrapped by the different MetricsGrabber.Wrap functions when metrics grabbing is not supported. Tests that check metrics data should then skip the check.

Functions

func APICallToPerfData added in v1.16.0

func APICallToPerfData(apicalls *APIResponsiveness) *e2eperftype.PerfData

APICallToPerfData transforms APIResponsiveness to PerfData.

func GrabAfterEach added in v1.26.0

func GrabAfterEach(ctx context.Context, f *framework.Framework, before *Collection)

func PrettyPrintJSON added in v1.16.0

func PrettyPrintJSON(metrics interface{}) string

PrettyPrintJSON converts metrics to JSON format. TODO: This function should be replaced with framework.PrettyPrintJSON after solving circulary dependency between core framework and this metrics subpackage.

Types

type APICall added in v1.16.0

type APICall struct {
	Resource    string        `json:"resource"`
	Subresource string        `json:"subresource"`
	Verb        string        `json:"verb"`
	Scope       string        `json:"scope"`
	Latency     LatencyMetric `json:"latency"`
	Count       int           `json:"count"`
}

APICall is a struct for managing API call.

type APIResponsiveness added in v1.16.0

type APIResponsiveness struct {
	APICalls []APICall `json:"apicalls"`
}

APIResponsiveness is a struct for managing multiple API calls.

func (*APIResponsiveness) Len added in v1.16.0

func (a *APIResponsiveness) Len() int

func (*APIResponsiveness) Less added in v1.16.0

func (a *APIResponsiveness) Less(i, j int) bool

func (*APIResponsiveness) PrintHumanReadable added in v1.16.0

func (a *APIResponsiveness) PrintHumanReadable() string

PrintHumanReadable returns metrics with JSON format.

func (*APIResponsiveness) PrintJSON added in v1.16.0

func (a *APIResponsiveness) PrintJSON() string

PrintJSON returns metrics of PerfData(50, 90 and 99th percentiles) with JSON format.

func (*APIResponsiveness) SummaryKind added in v1.16.0

func (a *APIResponsiveness) SummaryKind() string

SummaryKind returns the summary of API responsiveness.

func (*APIResponsiveness) Swap added in v1.16.0

func (a *APIResponsiveness) Swap(i, j int)

type APIServerMetrics added in v1.14.0

type APIServerMetrics testutil.Metrics

APIServerMetrics is metrics for API server

func (*APIServerMetrics) Equal added in v1.14.0

Equal returns true if all metrics are the same as the arguments.

type ClusterAutoscalerMetrics

type ClusterAutoscalerMetrics testutil.Metrics

ClusterAutoscalerMetrics is metrics for cluster autoscaler

func (*ClusterAutoscalerMetrics) Equal

Equal returns true if all metrics are the same as the arguments.

type Collection added in v1.14.0

type Collection struct {
	APIServerMetrics          APIServerMetrics
	APIServerMetricsSLIs      APIServerMetrics
	ControllerManagerMetrics  ControllerManagerMetrics
	SnapshotControllerMetrics SnapshotControllerMetrics
	KubeletMetrics            map[string]KubeletMetrics
	SchedulerMetrics          SchedulerMetrics
	ClusterAutoscalerMetrics  ClusterAutoscalerMetrics
}

Collection is metrics collection of components

func GrabBeforeEach added in v1.26.0

func GrabBeforeEach(ctx context.Context, f *framework.Framework) (result *Collection)

type ComponentCollection added in v1.16.0

type ComponentCollection Collection

ComponentCollection is metrics collection of components.

func (*ComponentCollection) ComputeClusterAutoscalerMetricsDelta added in v1.16.0

func (m *ComponentCollection) ComputeClusterAutoscalerMetricsDelta(before Collection)

ComputeClusterAutoscalerMetricsDelta computes the change in cluster autoscaler metrics.

func (*ComponentCollection) PrintHumanReadable added in v1.16.0

func (m *ComponentCollection) PrintHumanReadable() string

PrintHumanReadable returns e2e metrics with JSON format.

func (*ComponentCollection) PrintJSON added in v1.16.0

func (m *ComponentCollection) PrintJSON() string

PrintJSON returns e2e metrics with JSON format.

func (*ComponentCollection) SummaryKind added in v1.16.0

func (m *ComponentCollection) SummaryKind() string

SummaryKind returns the summary of e2e metrics.

type ControllerManagerMetrics

type ControllerManagerMetrics testutil.Metrics

ControllerManagerMetrics is metrics for controller manager

func (*ControllerManagerMetrics) Equal

Equal returns true if all metrics are the same as the arguments.

type Grabber added in v1.14.0

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

Grabber provides functions which grab metrics from components

func NewMetricsGrabber

func NewMetricsGrabber(ctx context.Context, c clientset.Interface, ec clientset.Interface, config *rest.Config, kubelets bool, scheduler bool, controllers bool, apiServer bool, clusterAutoscaler bool, snapshotController bool) (*Grabber, error)

NewMetricsGrabber prepares for grabbing metrics data from several different components. It should be called when those components are running because it needs to communicate with them to determine for which components metrics data can be retrieved.

Collecting metrics data is an optional debug feature. Not all clusters will support it. If disabled for a component, the corresponding Grab function will immediately return an error derived from MetricsGrabbingDisabledError.

func (*Grabber) Grab added in v1.14.0

func (g *Grabber) Grab(ctx context.Context) (Collection, error)

Grab returns metrics from corresponding component

func (*Grabber) GrabFromAPIServer added in v1.14.0

func (g *Grabber) GrabFromAPIServer(ctx context.Context) (APIServerMetrics, error)

GrabFromAPIServer returns metrics from API server

func (*Grabber) GrabFromClusterAutoscaler added in v1.14.0

func (g *Grabber) GrabFromClusterAutoscaler(ctx context.Context) (ClusterAutoscalerMetrics, error)

GrabFromClusterAutoscaler returns metrics from cluster autoscaler

func (*Grabber) GrabFromControllerManager added in v1.14.0

func (g *Grabber) GrabFromControllerManager(ctx context.Context) (ControllerManagerMetrics, error)

GrabFromControllerManager returns metrics from controller manager

func (*Grabber) GrabFromKubeProxy added in v1.31.0

func (g *Grabber) GrabFromKubeProxy(ctx context.Context, nodeName string) (KubeProxyMetrics, error)

GrabFromKubeProxy returns metrics from kube-proxy

func (*Grabber) GrabFromKubelet added in v1.14.0

func (g *Grabber) GrabFromKubelet(ctx context.Context, nodeName string) (KubeletMetrics, error)

GrabFromKubelet returns metrics from kubelet

func (*Grabber) GrabFromScheduler added in v1.14.0

func (g *Grabber) GrabFromScheduler(ctx context.Context) (SchedulerMetrics, error)

GrabFromScheduler returns metrics from scheduler

func (*Grabber) GrabFromSnapshotController added in v1.22.0

func (g *Grabber) GrabFromSnapshotController(ctx context.Context, podName string, port int) (SnapshotControllerMetrics, error)

GrabFromSnapshotController returns metrics from controller manager

func (*Grabber) GrabMetricsSLIsFromAPIServer added in v1.27.0

func (g *Grabber) GrabMetricsSLIsFromAPIServer(ctx context.Context) (APIServerMetrics, error)

GrabMetricsSLIsFromAPIServer returns metrics from API server

func (*Grabber) GrabResourceMetricsFromKubelet added in v1.29.0

func (g *Grabber) GrabResourceMetricsFromKubelet(ctx context.Context, nodeName string) (KubeletMetrics, error)

GrabresourceMetricsFromKubelet returns resource metrics from kubelet

func (*Grabber) HasControlPlanePods added in v1.19.0

func (g *Grabber) HasControlPlanePods() bool

HasControlPlanePods returns true if metrics grabber was able to find control-plane pods

type KubeProxyMetrics added in v1.31.0

type KubeProxyMetrics testutil.Metrics

KubeProxyMetrics is metrics for kube-proxy

func (*KubeProxyMetrics) GetCounterMetricValue added in v1.31.0

func (m *KubeProxyMetrics) GetCounterMetricValue(metricName string) (float64, error)

GetCounterMetricValue returns value for metric type counter.

type KubeletLatencyMetric added in v1.16.0

type KubeletLatencyMetric struct {
	// eg: list, info, create
	Operation string
	// eg: sync_pods, pod_worker
	Method string
	// 0 <= quantile <=1, e.g. 0.95 is 95%tile, 0.5 is median.
	Quantile float64
	Latency  time.Duration
}

KubeletLatencyMetric stores metrics scraped from the kubelet server's /metric endpoint. TODO: Get some more structure around the metrics and this type

type KubeletLatencyMetrics added in v1.16.0

type KubeletLatencyMetrics []KubeletLatencyMetric

KubeletLatencyMetrics implements sort.Interface for []KubeletMetric based on the latency field.

func GetDefaultKubeletLatencyMetrics added in v1.16.0

func GetDefaultKubeletLatencyMetrics(ms KubeletMetrics) KubeletLatencyMetrics

GetDefaultKubeletLatencyMetrics calls GetKubeletLatencyMetrics with a set of default metricNames identifying common latency metrics. Note that the KubeletMetrics passed in should not contain subsystem prefix.

func GetKubeletLatencyMetrics added in v1.16.0

func GetKubeletLatencyMetrics(ms KubeletMetrics, filterMetricNames sets.String) KubeletLatencyMetrics

GetKubeletLatencyMetrics filters ms to include only those contained in the metricNames set, then constructs a KubeletLatencyMetrics list based on the samples associated with those metrics.

func HighLatencyKubeletOperations added in v1.16.0

func HighLatencyKubeletOperations(ctx context.Context, c clientset.Interface, threshold time.Duration, nodeName string, logFunc func(fmt string, args ...interface{})) (KubeletLatencyMetrics, error)

HighLatencyKubeletOperations logs and counts the high latency metrics exported by the kubelet server via /metrics.

func (KubeletLatencyMetrics) Len added in v1.16.0

func (a KubeletLatencyMetrics) Len() int

func (KubeletLatencyMetrics) Less added in v1.16.0

func (a KubeletLatencyMetrics) Less(i, j int) bool

func (KubeletLatencyMetrics) Swap added in v1.16.0

func (a KubeletLatencyMetrics) Swap(i, j int)

type KubeletMetrics

type KubeletMetrics testutil.Metrics

KubeletMetrics is metrics for kubelet

func GetKubeletMetrics added in v1.16.0

func GetKubeletMetrics(ctx context.Context, c clientset.Interface, nodeName string) (KubeletMetrics, error)

GetKubeletMetrics gets all metrics in kubelet subsystem from specified node and trims the subsystem prefix.

func GrabKubeletMetricsWithoutProxy

func GrabKubeletMetricsWithoutProxy(ctx context.Context, nodeName, path string) (KubeletMetrics, error)

GrabKubeletMetricsWithoutProxy retrieve metrics from the kubelet on the given node using a simple GET over http.

func NewKubeletMetrics

func NewKubeletMetrics() KubeletMetrics

NewKubeletMetrics returns new metrics which are initialized.

func (*KubeletMetrics) Equal

func (m *KubeletMetrics) Equal(o KubeletMetrics) bool

Equal returns true if all metrics are the same as the arguments.

type LatencyMetric added in v1.16.0

type LatencyMetric struct {
	Perc50  time.Duration `json:"Perc50"`
	Perc90  time.Duration `json:"Perc90"`
	Perc99  time.Duration `json:"Perc99"`
	Perc100 time.Duration `json:"Perc100"`
}

LatencyMetric is a struct for dashboard metrics.

type LatencySlice added in v1.16.0

type LatencySlice []PodLatencyData

LatencySlice is an array of PodLatencyData which encapsulates pod startup latency information.

func (LatencySlice) Len added in v1.16.0

func (a LatencySlice) Len() int

func (LatencySlice) Less added in v1.16.0

func (a LatencySlice) Less(i, j int) bool

func (LatencySlice) Swap added in v1.16.0

func (a LatencySlice) Swap(i, j int)

type PodLatencyData added in v1.16.0

type PodLatencyData struct {
	// Name of the pod
	Name string
	// Node this pod was running on
	Node string
	// Latency information related to pod startuptime
	Latency time.Duration
}

PodLatencyData encapsulates pod startup latency information.

type SchedulerMetrics

type SchedulerMetrics testutil.Metrics

SchedulerMetrics is metrics for scheduler

func (*SchedulerMetrics) Equal

Equal returns true if all metrics are the same as the arguments.

type SnapshotControllerMetrics added in v1.22.0

type SnapshotControllerMetrics testutil.Metrics

SnapshotControllerMetrics is metrics for controller manager

func (*SnapshotControllerMetrics) Equal added in v1.22.0

Equal returns true if all metrics are the same as the arguments.

Directories

Path Synopsis
Package init installs GrabBeforeEach and GrabAfterEach as callbacks for gathering data before and after a test.
Package init installs GrabBeforeEach and GrabAfterEach as callbacks for gathering data before and after a test.

Jump to

Keyboard shortcuts

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