metrics

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const Name = "metrics"

Name is the registry key for this scanner.

Variables

This section is empty.

Functions

func NewScanner

func NewScanner() scanner.Scanner

NewScanner returns a scanner that collects node resource utilization from the metrics API. A missing metrics API yields StateUnavailable, while a 403 or any other API failure propagates a wrapped ErrScan so a denied read is never mistaken for a healthy, zero-utilization cluster.

Types

type Data

type Data struct {
	// Available is false when metrics-server is not installed or not authorized.
	Available bool `json:"available"`
	// Forbidden is true when the API returned 403 (metrics-server installed but
	// RBAC denied). Distinguishing this from "not installed" lets operators fix
	// the right thing.
	Forbidden bool `json:"forbidden,omitempty"`
	// NodeCount is the number of nodes with metrics.
	NodeCount int `json:"node_count"`
	// AvgCPUPercent is the average CPU utilization across all nodes.
	AvgCPUPercent float64 `json:"avg_cpu_percent"`
	// AvgMemoryPercent is the average memory utilization across all nodes.
	AvgMemoryPercent float64 `json:"avg_memory_percent"`
	// MaxCPUPercent is the highest CPU utilization on any single node.
	MaxCPUPercent float64 `json:"max_cpu_percent"`
	// MaxMemoryPercent is the highest memory utilization on any single node.
	MaxMemoryPercent float64 `json:"max_memory_percent"`
	// MaxCPUNode is the name of the node with the highest CPU usage.
	MaxCPUNode string `json:"max_cpu_node,omitempty"`
	// MaxMemoryNode is the name of the node with the highest memory usage.
	MaxMemoryNode string `json:"max_memory_node,omitempty"`
	// Nodes lists per-node utilization metrics.
	Nodes []NodeMetrics `json:"nodes"`
}

Data holds cluster-wide resource utilization metrics.

type NodeMetrics

type NodeMetrics struct {
	// Name is the node name.
	Name string `json:"name"`
	// CPUUsage is the current CPU usage (for example "250m").
	CPUUsage string `json:"cpu_usage"`
	// MemoryUsage is the current memory usage (for example "1.2Gi").
	MemoryUsage string `json:"memory_usage"`
	// CPUPercent is usage as a percentage of allocatable CPU (-1 if unknown).
	CPUPercent float64 `json:"cpu_percent"`
	// MemoryPercent is usage as a percentage of allocatable memory (-1 if unknown).
	MemoryPercent float64 `json:"memory_percent"`
}

NodeMetrics describes resource utilization for a single node.

Jump to

Keyboard shortcuts

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