Documentation
¶
Index ¶
- Constants
- type AggregatedMetrics
- type CollectionSpec
- type MetricHistory
- type MetricKey
- type MetricPoint
- type MetricSnapshot
- type ScaleRequest
- type ScaleResult
- type ScaleTarget
- type ScalingConstraints
- type TimeWindow
- func (tw *TimeWindow) Avg() (float64, error)
- func (tw *TimeWindow) Max() (float64, error)
- func (tw *TimeWindow) Min() (float64, error)
- func (tw *TimeWindow) Record(timestamp time.Time, value float64)
- func (tw *TimeWindow) Size() int
- func (tw *TimeWindow) String() string
- func (tw *TimeWindow) Values() []float64
- type WindowStats
Constants ¶
const ( // AutoscalingLabelPrefix is the prefix for all autoscaling annotation keys AutoscalingLabelPrefix = "autoscaling.aibrix.ai/" // MaxScaleUpRateLabel controls the maximum rate at which to scale up // Value: float (e.g., "2.0" means can double replicas in one step) MaxScaleUpRateLabel = AutoscalingLabelPrefix + "max-scale-up-rate" // MaxScaleDownRateLabel controls the maximum rate at which to scale down // Value: float (e.g., "2.0" means can halve replicas in one step) MaxScaleDownRateLabel = AutoscalingLabelPrefix + "max-scale-down-rate" // ScaleUpToleranceLabel sets tolerance for upward metric fluctuations // Value: float (e.g., "0.1" means 10% tolerance before scaling up) ScaleUpToleranceLabel = AutoscalingLabelPrefix + "scale-up-tolerance" // ScaleDownToleranceLabel sets tolerance for downward metric fluctuations // Value: float (e.g., "0.1" means 10% tolerance before scaling down) ScaleDownToleranceLabel = AutoscalingLabelPrefix + "scale-down-tolerance" // PanicThresholdLabel sets the threshold for entering panic mode (KPA only) // Value: float (e.g., "2.0" means panic when short-term exceeds 2x long-term average) PanicThresholdLabel = AutoscalingLabelPrefix + "panic-threshold" // ScaleUpCooldownWindowLabel sets the cooldown window for scale-up decisions // Value: duration (e.g., "0s", "60s") ScaleUpCooldownWindowLabel = AutoscalingLabelPrefix + "scale-up-cooldown-window" // ScaleDownCooldownWindowLabel sets the cooldown window for scale-down decisions // Value: duration (e.g., "300s", "5m") ScaleDownCooldownWindowLabel = AutoscalingLabelPrefix + "scale-down-cooldown-window" // ScaleToZeroLabel enables/disables scaling to zero replicas // Value: bool (e.g., "true", "false") ScaleToZeroLabel = AutoscalingLabelPrefix + "scale-to-zero" )
Annotation keys for PodAutoscaler configuration These constants define the annotation keys used to configure autoscaling behavior
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AggregatedMetrics ¶
type AggregatedMetrics struct {
MetricKey MetricKey
CurrentValue float64
StableValue float64
PanicValue float64
Trend float64
Confidence float64
LastUpdated time.Time
}
AggregatedMetrics contains processed metrics data
type CollectionSpec ¶
type CollectionSpec struct {
Namespace string // Target namespace
TargetName string // Target resource name
MetricName string // Name of the metric
MetricSource autoscalingv1alpha1.MetricSource
Pods []corev1.Pod
Timestamp time.Time
}
CollectionSpec defines what metrics to collect
type MetricHistory ¶
type MetricHistory struct {
// contains filtered or unexported fields
}
MetricHistory tracks historical metrics for trend analysis
func NewMetricHistory ¶
func NewMetricHistory(maxAge time.Duration) *MetricHistory
NewMetricHistory creates a new metric history tracker
func (*MetricHistory) Add ¶
func (h *MetricHistory) Add(value float64, timestamp time.Time)
Add adds a new metric point to history
func (*MetricHistory) GetStats ¶
func (h *MetricHistory) GetStats(now time.Time) WindowStats
GetStats calculates statistics for the history
type MetricKey ¶
type MetricKey struct {
Namespace string // Target workload namespace
Name string // Target workload name
MetricName string // Metric name (e.g., "concurrency", "qps")
// PodAutoscaler identification for multi-tenancy
PaNamespace string // PodAutoscaler namespace
PaName string // PodAutoscaler name
}
MetricKey identifies a specific metric for a PodAutoscaler
type MetricPoint ¶
MetricPoint represents a single metric measurement
type MetricSnapshot ¶
type MetricSnapshot struct {
Namespace string
TargetName string
MetricName string
Values []float64 // TODO(Jeffwan): Prefill/Decode case needs extension
Timestamp time.Time
Source string
Error error
}
MetricSnapshot contains collected raw metrics
type ScaleRequest ¶
type ScaleRequest struct {
PodAutoscaler autoscalingv1alpha1.PodAutoscaler
CurrentReplicas int32
Pods []corev1.Pod
Timestamp time.Time
}
ScaleRequest contains everything needed for scaling
type ScaleResult ¶
type ScaleResult struct {
DesiredPodCount int32
ExcessBurstCapacity int32
ScaleValid bool
Reason string
Algorithm string
Metadata map[string]interface{}
}
ScaleResult contains scaling outcome - extends existing ScaleResult
type ScaleTarget ¶
type ScaleTarget struct {
Namespace string
Name string
Kind string
APIVersion string
MetricKey MetricKey
}
ScaleTarget represents what to scale
type ScalingConstraints ¶
ScalingConstraints defines scaling limits
type TimeWindow ¶
type TimeWindow struct {
// contains filtered or unexported fields
}
TimeWindow manages a sliding window of metric values
func NewTimeWindow ¶
func NewTimeWindow(duration, granularity time.Duration) *TimeWindow
NewTimeWindow creates a new time window
func (*TimeWindow) Avg ¶
func (tw *TimeWindow) Avg() (float64, error)
Avg returns the average value in the window
func (*TimeWindow) Max ¶
func (tw *TimeWindow) Max() (float64, error)
Max returns the maximum value in the window
func (*TimeWindow) Min ¶
func (tw *TimeWindow) Min() (float64, error)
Min returns the minimum value in the window
func (*TimeWindow) Record ¶
func (tw *TimeWindow) Record(timestamp time.Time, value float64)
Record adds a value to the time window
func (*TimeWindow) Size ¶
func (tw *TimeWindow) Size() int
Size returns the number of data points in the window
func (*TimeWindow) String ¶
func (tw *TimeWindow) String() string
String returns a string representation of the time window
func (*TimeWindow) Values ¶
func (tw *TimeWindow) Values() []float64
Values returns all values in the window in chronological order