sampler

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Overview

Package sampler implements metrics-node-sampler which samples local utilization metrics from the node it is running on and serves aggregated values from a grpc API.

Samples are stored in memory over a sliding window. Responses contain values aggregated from the samples currently in memory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainerCPUThrottlingMetrics

type ContainerCPUThrottlingMetrics struct {
	// Time is the time that the sample was taken
	Time             time.Time
	ThrottledNanoSec uint64
	// the number of cpu scheduling periods that the container has been throttled for
	// the container has been considered throttled for a period if it attempts to use the Cpu after exceeding Cpu quota.
	ThrottledPeriods uint64
	// the total number of Cpu scheduling period that have elapsed
	TotalPeriods uint64
}

https://kernel.googlesource.com/pub/scm/linux/kernel/git/glommer/memcg/+/cpu_stat/Documentation/cgroups/cpu.txt

type ContainerKey

type ContainerKey struct {
	// ContainerID is the id of the container, and corresponds to the pod.status.containerStatuses.containerID
	ContainerID string
	// PodUID is the uid of the pod the container is running in, and corresponds to the pod.metadata.uid, or for
	// mirror pods the config.mirror annotation.
	PodUID string
}

ContainerKey is the key to a container running in a Pod

type ContainerMetricType

type ContainerMetricType string

ContainerMetricType identifies a type of metrics that corresponds to a specific cgroups file

const (
	MemoryUsageMetricType   ContainerMetricType = "memory-usage"
	MemoryOOMKillMetricType ContainerMetricType = "oom-kill"
	MemoryOMMMetricType     ContainerMetricType = "oom"
	CPUUsageMetricType      ContainerMetricType = "cpu-usage"
	CPUThrottlingMetricType ContainerMetricType = "cpu-throttling"
)

type Float32Slice

type Float32Slice []float32

func (Float32Slice) Len

func (x Float32Slice) Len() int

func (Float32Slice) Less

func (x Float32Slice) Less(i, j int) bool

func (Float32Slice) Swap

func (x Float32Slice) Swap(i, j int)

type Int64Slice

type Int64Slice []int64

func (Int64Slice) Len

func (x Int64Slice) Len() int

func (Int64Slice) Less

func (x Int64Slice) Less(i, j int) bool

func (Int64Slice) Swap

func (x Int64Slice) Swap(i, j int)

type NodeAggregatedMetricsSlice

type NodeAggregatedMetricsSlice []*api.NodeAggregatedMetrics

func (NodeAggregatedMetricsSlice) Len

func (NodeAggregatedMetricsSlice) Less

func (x NodeAggregatedMetricsSlice) Less(i, j int) bool

func (NodeAggregatedMetricsSlice) Swap

func (x NodeAggregatedMetricsSlice) Swap(i, j int)

type Server

type Server struct {
	// MetricsNodeSampler configures the server
	samplerserverv1alpha1.MetricsNodeSampler `json:",inline" yaml:",inline"`

	// FS is the filesystem to use for reading cgroup metrics.  Defaults to the
	// OS filesystem.
	// +optional
	FS fs.FS

	// TimeFunc is the function used for getting the timestamp for when metrics
	// are read.  Defaults to time.Now.
	// +optional
	TimeFunc func(string) time.Time

	SortResults bool

	api.UnimplementedMetricsServer
	api.UnimplementedHealthServer

	PushHealthy  atomic.Bool
	PushErrorMsg atomic.Value
	// contains filtered or unexported fields
}

Server runs the metrics-node-sampler server which samples cgroup metrics from the filesystem, and servers them over a GRPC API.

func (*Server) ListMetrics

ListMetrics lists the aggregated metrics for all containers and nodes

func (*Server) PushMetrics

func (s *Server) PushMetrics(ctx context.Context) error

PushMetrics pushes utilization metrics to a server

func (*Server) Start

func (s *Server) Start(ctx context.Context, stop context.CancelFunc) error

Start starts the server sampling metrics and serving them

func (*Server) Stop

func (s *Server) Stop()

Stop stops the server from sampling metrics

Directories

Path Synopsis
Package api is a reverse proxy.
Package api is a reverse proxy.

Jump to

Keyboard shortcuts

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