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 ¶
- type ContainerCPUThrottlingMetrics
- type ContainerKey
- type ContainerMetricType
- type Float32Slice
- type Int64Slice
- type NodeAggregatedMetricsSlice
- type Server
- func (s *Server) Check(ctx context.Context, _ *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error)
- func (s *Server) ListMetrics(context.Context, *api.ListMetricsRequest) (*api.ListMetricsResponse, error)
- func (s *Server) RegisterCollectors(ctx context.Context, req *api.RegisterCollectorsRequest) (*api.RegisterCollectorsResponse, error)
- func (s *Server) Start(ctx context.Context, stop context.CancelFunc) error
- func (s *Server) Stop()
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 }
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 // NamespaceName is the namespace of the pod NamespaceName string // ContainerName is the name of the container ContainerName string // PodName is the name of the pod PodName 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" MemoryOOMKillMetricTypeV1 ContainerMetricType = "oom-kill" MemoryOOMMetricType ContainerMetricType = "oom" MemoryCurrentMetricsTypeV2 ContainerMetricType = "memory-current" CPUUsageMetricType ContainerMetricType = "cpu-usage" CPUThrottlingMetricTypeV1 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 (x NodeAggregatedMetricsSlice) Len() int
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 CTX context.Context HostName string // 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) Check ¶
func (s *Server) Check(ctx context.Context, _ *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error)
func (*Server) ListMetrics ¶
func (s *Server) ListMetrics(context.Context, *api.ListMetricsRequest) (*api.ListMetricsResponse, error)
ListMetrics lists the aggregated metrics for all containers and nodes
func (*Server) RegisterCollectors ¶ added in v0.6.2
func (s *Server) RegisterCollectors(ctx context.Context, req *api.RegisterCollectorsRequest) (*api.RegisterCollectorsResponse, error)
RegisterCollector provides an endpoint for collectors to manually register with the samplers. This is useful in cases where DNS isn't adequate. - Collector needs to get utilization data before marking itself as ready and serving metrics - DNS is slow to propagate