Documentation
¶
Index ¶
- Constants
- Variables
- func GetPodReadyAge(pod corev1.Pod) (bool, time.Duration)
- type AWSCollectorPlugin
- type AWSSQSCollector
- type ClusterScalingScheduleCollector
- type ClusterScalingScheduleCollectorPlugin
- type CollectedMetric
- type Collector
- type CollectorFactory
- func (c *CollectorFactory) NewCollector(ctx context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, ...) (Collector, error)
- func (c *CollectorFactory) RegisterExternalCollector(metrics []string, plugin CollectorPlugin)
- func (c *CollectorFactory) RegisterObjectCollector(kind, metricCollector string, plugin CollectorPlugin) error
- func (c *CollectorFactory) RegisterPodsCollector(metricCollector string, plugin CollectorPlugin) error
- type CollectorPlugin
- type ExternalRPSCollector
- type ExternalRPSCollectorPlugin
- type HTTPCollector
- type HTTPCollectorPlugin
- type InfluxDBCollector
- type InfluxDBCollectorPlugin
- type MetricConfig
- type MetricTypeName
- type NakadiCollector
- type NakadiCollectorPlugin
- type NoResultError
- type Now
- type ObjectReference
- type PluginNotFoundError
- type PodCollector
- type PodCollectorPlugin
- type PrometheusCollector
- type PrometheusCollectorPlugin
- type ScalingScheduleCollector
- type ScalingScheduleCollectorPlugin
- type SkipperCollector
- type SkipperCollectorPlugin
- type Store
- type ZMONCollector
- type ZMONCollectorPlugin
Constants ¶
const ( ExternalRPSMetricType = "requests-per-second" ExternalRPSQuery = `scalar(sum(rate(%s{host=~"%s"}[1m])) * %.4f)` )
const ( HTTPJSONPathType = "json-path" HTTPMetricNameLegacy = "http" HTTPEndpointAnnotationKey = "endpoint" HTTPJsonPathAnnotationKey = "json-key" )
const ( InfluxDBMetricType = "influxdb" InfluxDBMetricNameLegacy = "flux-query" )
const ( PrometheusMetricType = "prometheus" PrometheusMetricNameLegacy = "prometheus-query" )
const ( // ZMONMetricType defines the metric type for metrics based on ZMON // checks. ZMONMetricType = "zmon" ZMONCheckMetricLegacy = "zmon-check" )
const (
AWSSQSQueueLengthMetric = "sqs-queue-length"
)
const ( // NakadiMetricType defines the metric type for metrics based on Nakadi // subscriptions. NakadiMetricType = "nakadi" )
Variables ¶
var ( // ErrScalingScheduleNotFound is returned when a item referenced in // the HPA config is not in the ScalingScheduleCollectorPlugin.store. ErrScalingScheduleNotFound = errors.New("referenced ScalingSchedule not found") // ErrNotScalingScheduleFound is returned when a item returned from // the ScalingScheduleCollectorPlugin.store was expected to // be an ScalingSchedule but the type assertion failed. ErrNotScalingScheduleFound = errors.New("error converting returned object to ScalingSchedule") // ErrClusterScalingScheduleNotFound is returned when a item referenced in // the HPA config is not in the ClusterScalingScheduleCollectorPlugin.store. ErrClusterScalingScheduleNotFound = errors.New("referenced ClusterScalingSchedule not found") // ErrNotClusterScalingScheduleFound is returned when a item returned from // the ClusterScalingScheduleCollectorPlugin.store was expected to // be an ClusterScalingSchedule but the type assertion failed. When // returned the type assertion to ScalingSchedule failed too. ErrNotClusterScalingScheduleFound = errors.New("error converting returned object to ClusterScalingSchedule") )
Functions ¶
func GetPodReadyAge ¶ added in v0.1.11
GetPodReadyAge extracts corev1.PodReady condition from the given pod object and returns true, time.Duration() for LastTransitionTime if the condition corev1.PodReady is found. Returns time.Duration(0s), false if the condition is not present.
Types ¶
type AWSCollectorPlugin ¶
type AWSCollectorPlugin struct {
// contains filtered or unexported fields
}
func NewAWSCollectorPlugin ¶
func NewAWSCollectorPlugin(configs map[string]aws.Config) *AWSCollectorPlugin
func (*AWSCollectorPlugin) NewCollector ¶
func (c *AWSCollectorPlugin) NewCollector(ctx context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error)
NewCollector initializes a new skipper collector from the specified HPA.
type AWSSQSCollector ¶
type AWSSQSCollector struct {
// contains filtered or unexported fields
}
func NewAWSSQSCollector ¶
func NewAWSSQSCollector(ctx context.Context, configs map[string]aws.Config, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (*AWSSQSCollector, error)
func (*AWSSQSCollector) GetMetrics ¶
func (c *AWSSQSCollector) GetMetrics(ctx context.Context) ([]CollectedMetric, error)
func (*AWSSQSCollector) Interval ¶
func (c *AWSSQSCollector) Interval() time.Duration
Interval returns the interval at which the collector should run.
type ClusterScalingScheduleCollector ¶ added in v0.1.11
type ClusterScalingScheduleCollector struct {
// contains filtered or unexported fields
}
ClusterScalingScheduleCollector is a metrics collector for time based scaling metrics.
func NewClusterScalingScheduleCollector ¶ added in v0.1.11
func NewClusterScalingScheduleCollector(store Store, defaultScalingWindow time.Duration, defaultTimeZone string, rampSteps int, now Now, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (*ClusterScalingScheduleCollector, error)
NewClusterScalingScheduleCollector initializes a new ScalingScheduleCollector.
func (*ClusterScalingScheduleCollector) GetMetrics ¶ added in v0.1.11
func (c *ClusterScalingScheduleCollector) GetMetrics(_ context.Context) ([]CollectedMetric, error)
GetMetrics is the main implementation for collector.Collector interface
func (*ClusterScalingScheduleCollector) Interval ¶ added in v0.1.11
func (c *ClusterScalingScheduleCollector) Interval() time.Duration
Interval returns the interval at which the collector should run.
type ClusterScalingScheduleCollectorPlugin ¶ added in v0.1.11
type ClusterScalingScheduleCollectorPlugin struct {
// contains filtered or unexported fields
}
ClusterScalingScheduleCollectorPlugin is a collector plugin for initializing metrics collectors for getting ClusterScalingSchedule configured metrics.
func NewClusterScalingScheduleCollectorPlugin ¶ added in v0.1.11
func NewClusterScalingScheduleCollectorPlugin(store Store, now Now, defaultScalingWindow time.Duration, defaultTimeZone string, rampSteps int) (*ClusterScalingScheduleCollectorPlugin, error)
NewClusterScalingScheduleCollectorPlugin initializes a new ClusterScalingScheduleCollectorPlugin.
func (*ClusterScalingScheduleCollectorPlugin) NewCollector ¶ added in v0.1.11
func (c *ClusterScalingScheduleCollectorPlugin) NewCollector(_ context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error)
NewCollector initializes a new cluster wide scaling schedule collector from the specified HPA. It's the only required method to implement the collector.CollectorPlugin interface.
type CollectedMetric ¶
type CollectedMetric struct { Type autoscalingv2.MetricSourceType Namespace string Custom custom_metrics.MetricValue External external_metrics.ExternalMetricValue }
type CollectorFactory ¶
type CollectorFactory struct {
// contains filtered or unexported fields
}
func NewCollectorFactory ¶
func NewCollectorFactory() *CollectorFactory
func (*CollectorFactory) NewCollector ¶
func (c *CollectorFactory) NewCollector(ctx context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error)
func (*CollectorFactory) RegisterExternalCollector ¶
func (c *CollectorFactory) RegisterExternalCollector(metrics []string, plugin CollectorPlugin)
func (*CollectorFactory) RegisterObjectCollector ¶
func (c *CollectorFactory) RegisterObjectCollector(kind, metricCollector string, plugin CollectorPlugin) error
func (*CollectorFactory) RegisterPodsCollector ¶
func (c *CollectorFactory) RegisterPodsCollector(metricCollector string, plugin CollectorPlugin) error
type CollectorPlugin ¶
type CollectorPlugin interface {
NewCollector(ctx context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error)
}
type ExternalRPSCollector ¶ added in v0.2.1
type ExternalRPSCollector struct {
// contains filtered or unexported fields
}
func (*ExternalRPSCollector) GetMetrics ¶ added in v0.2.1
func (c *ExternalRPSCollector) GetMetrics(ctx context.Context) ([]CollectedMetric, error)
GetMetrics gets hostname metrics from Prometheus
func (*ExternalRPSCollector) Interval ¶ added in v0.2.1
func (c *ExternalRPSCollector) Interval() time.Duration
Interval returns the interval at which the collector should run.
type ExternalRPSCollectorPlugin ¶ added in v0.2.1
type ExternalRPSCollectorPlugin struct {
// contains filtered or unexported fields
}
func NewExternalRPSCollectorPlugin ¶ added in v0.2.1
func NewExternalRPSCollectorPlugin( promPlugin CollectorPlugin, metricName string, ) (*ExternalRPSCollectorPlugin, error)
func (*ExternalRPSCollectorPlugin) NewCollector ¶ added in v0.2.1
func (p *ExternalRPSCollectorPlugin) NewCollector( ctx context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration, ) (Collector, error)
NewCollector initializes a new skipper collector from the specified HPA.
type HTTPCollector ¶ added in v0.1.3
type HTTPCollector struct {
// contains filtered or unexported fields
}
func (*HTTPCollector) GetMetrics ¶ added in v0.1.3
func (c *HTTPCollector) GetMetrics(ctx context.Context) ([]CollectedMetric, error)
func (*HTTPCollector) Interval ¶ added in v0.1.3
func (c *HTTPCollector) Interval() time.Duration
type HTTPCollectorPlugin ¶ added in v0.1.3
type HTTPCollectorPlugin struct{}
func NewHTTPCollectorPlugin ¶ added in v0.1.3
func NewHTTPCollectorPlugin() (*HTTPCollectorPlugin, error)
func (*HTTPCollectorPlugin) NewCollector ¶ added in v0.1.3
func (p *HTTPCollectorPlugin) NewCollector(_ context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error)
type InfluxDBCollector ¶ added in v0.0.6
type InfluxDBCollector struct {
// contains filtered or unexported fields
}
func NewInfluxDBCollector ¶ added in v0.0.6
func NewInfluxDBCollector(_ context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, address string, token string, org string, config *MetricConfig, interval time.Duration) (*InfluxDBCollector, error)
func (*InfluxDBCollector) GetMetrics ¶ added in v0.0.6
func (c *InfluxDBCollector) GetMetrics(ctx context.Context) ([]CollectedMetric, error)
func (*InfluxDBCollector) Interval ¶ added in v0.0.6
func (c *InfluxDBCollector) Interval() time.Duration
type InfluxDBCollectorPlugin ¶ added in v0.0.6
type InfluxDBCollectorPlugin struct {
// contains filtered or unexported fields
}
func NewInfluxDBCollectorPlugin ¶ added in v0.0.6
func NewInfluxDBCollectorPlugin(client kubernetes.Interface, address, token, org string) (*InfluxDBCollectorPlugin, error)
func (*InfluxDBCollectorPlugin) NewCollector ¶ added in v0.0.6
func (p *InfluxDBCollectorPlugin) NewCollector(ctx context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error)
type MetricConfig ¶
type MetricConfig struct { MetricTypeName CollectorType string Config map[string]string ObjectReference custom_metrics.ObjectReference PerReplica bool Interval time.Duration MinPodReadyAge time.Duration MetricSpec autoscalingv2.MetricSpec }
func ParseHPAMetrics ¶
func ParseHPAMetrics(hpa *autoscalingv2.HorizontalPodAutoscaler) ([]*MetricConfig, error)
ParseHPAMetrics parses the HPA object into a list of metric configurations.
type MetricTypeName ¶
type MetricTypeName struct { Type autoscalingv2.MetricSourceType Metric autoscalingv2.MetricIdentifier }
type NakadiCollector ¶ added in v0.2.2
type NakadiCollector struct {
// contains filtered or unexported fields
}
NakadiCollector defines a collector that is able to collect metrics from Nakadi.
func NewNakadiCollector ¶ added in v0.2.2
func NewNakadiCollector(_ context.Context, nakadi nakadi.Nakadi, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (*NakadiCollector, error)
NewNakadiCollector initializes a new NakadiCollector.
func (*NakadiCollector) GetMetrics ¶ added in v0.2.2
func (c *NakadiCollector) GetMetrics(ctx context.Context) ([]CollectedMetric, error)
GetMetrics returns a list of collected metrics for the Nakadi subscription ID.
func (*NakadiCollector) Interval ¶ added in v0.2.2
func (c *NakadiCollector) Interval() time.Duration
Interval returns the interval at which the collector should run.
type NakadiCollectorPlugin ¶ added in v0.2.2
type NakadiCollectorPlugin struct {
// contains filtered or unexported fields
}
NakadiCollectorPlugin defines a plugin for creating collectors that can get unconsumed events from Nakadi.
func NewNakadiCollectorPlugin ¶ added in v0.2.2
func NewNakadiCollectorPlugin(nakadi nakadi.Nakadi) (*NakadiCollectorPlugin, error)
NewNakadiCollectorPlugin initializes a new NakadiCollectorPlugin.
func (*NakadiCollectorPlugin) NewCollector ¶ added in v0.2.2
func (c *NakadiCollectorPlugin) NewCollector(ctx context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error)
NewCollector initializes a new Nakadi collector from the specified HPA.
type NoResultError ¶
type NoResultError struct {
// contains filtered or unexported fields
}
func (NoResultError) Error ¶
func (r NoResultError) Error() string
type Now ¶ added in v0.1.11
Now is the function that returns a time.Time object representing the current moment. Its main implementation is the time.Now func in the std lib. It's used mainly for test/mock purposes.
type ObjectReference ¶
type ObjectReference struct { autoscalingv2.CrossVersionObjectReference Namespace string }
type PluginNotFoundError ¶ added in v0.1.1
type PluginNotFoundError struct {
// contains filtered or unexported fields
}
func (*PluginNotFoundError) Error ¶ added in v0.1.1
func (p *PluginNotFoundError) Error() string
func (*PluginNotFoundError) Is ¶ added in v0.1.11
func (p *PluginNotFoundError) Is(target error) bool
type PodCollector ¶
type PodCollector struct { Getter httpmetrics.PodMetricsGetter // contains filtered or unexported fields }
func NewPodCollector ¶
func NewPodCollector(ctx context.Context, client kubernetes.Interface, argoRolloutsClient argoRolloutsClient.Interface, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (*PodCollector, error)
func (*PodCollector) GetMetrics ¶
func (c *PodCollector) GetMetrics(ctx context.Context) ([]CollectedMetric, error)
func (*PodCollector) Interval ¶
func (c *PodCollector) Interval() time.Duration
type PodCollectorPlugin ¶
type PodCollectorPlugin struct {
// contains filtered or unexported fields
}
func NewPodCollectorPlugin ¶
func NewPodCollectorPlugin(client kubernetes.Interface, argoRolloutsClient argoRolloutsClient.Interface) *PodCollectorPlugin
func (*PodCollectorPlugin) NewCollector ¶
func (p *PodCollectorPlugin) NewCollector(ctx context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error)
type PrometheusCollector ¶
type PrometheusCollector struct {
// contains filtered or unexported fields
}
func NewPrometheusCollector ¶
func NewPrometheusCollector(client kubernetes.Interface, promAPI promv1.API, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (*PrometheusCollector, error)
func (*PrometheusCollector) GetMetrics ¶
func (c *PrometheusCollector) GetMetrics(ctx context.Context) ([]CollectedMetric, error)
func (*PrometheusCollector) Interval ¶
func (c *PrometheusCollector) Interval() time.Duration
type PrometheusCollectorPlugin ¶
type PrometheusCollectorPlugin struct {
// contains filtered or unexported fields
}
func NewPrometheusCollectorPlugin ¶
func NewPrometheusCollectorPlugin(client kubernetes.Interface, prometheusServer string) (*PrometheusCollectorPlugin, error)
func (*PrometheusCollectorPlugin) NewCollector ¶
func (p *PrometheusCollectorPlugin) NewCollector(_ context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error)
type ScalingScheduleCollector ¶ added in v0.1.11
type ScalingScheduleCollector struct {
// contains filtered or unexported fields
}
ScalingScheduleCollector is a metrics collector for time based scaling metrics.
func NewScalingScheduleCollector ¶ added in v0.1.11
func NewScalingScheduleCollector(store Store, defaultScalingWindow time.Duration, defaultTimeZone string, rampSteps int, now Now, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (*ScalingScheduleCollector, error)
NewScalingScheduleCollector initializes a new ScalingScheduleCollector.
func (*ScalingScheduleCollector) GetMetrics ¶ added in v0.1.11
func (c *ScalingScheduleCollector) GetMetrics(_ context.Context) ([]CollectedMetric, error)
GetMetrics is the main implementation for collector.Collector interface
func (*ScalingScheduleCollector) Interval ¶ added in v0.1.11
func (c *ScalingScheduleCollector) Interval() time.Duration
Interval returns the interval at which the collector should run.
type ScalingScheduleCollectorPlugin ¶ added in v0.1.11
type ScalingScheduleCollectorPlugin struct {
// contains filtered or unexported fields
}
ScalingScheduleCollectorPlugin is a collector plugin for initializing metrics collectors for getting ScalingSchedule configured metrics.
func NewScalingScheduleCollectorPlugin ¶ added in v0.1.11
func NewScalingScheduleCollectorPlugin(store Store, now Now, defaultScalingWindow time.Duration, defaultTimeZone string, rampSteps int) (*ScalingScheduleCollectorPlugin, error)
NewScalingScheduleCollectorPlugin initializes a new ScalingScheduleCollectorPlugin.
func (*ScalingScheduleCollectorPlugin) NewCollector ¶ added in v0.1.11
func (c *ScalingScheduleCollectorPlugin) NewCollector(_ context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error)
NewCollector initializes a new scaling schedule collector from the specified HPA. It's the only required method to implement the collector.CollectorPlugin interface.
type SkipperCollector ¶
type SkipperCollector struct {
// contains filtered or unexported fields
}
SkipperCollector is a metrics collector for getting skipper ingress metrics. It depends on the prometheus collector for getting the metrics.
func NewSkipperCollector ¶
func NewSkipperCollector(client kubernetes.Interface, rgClient rginterface.Interface, plugin CollectorPlugin, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration, backendAnnotations []string, backend string) (*SkipperCollector, error)
NewSkipperCollector initializes a new SkipperCollector.
func (*SkipperCollector) GetMetrics ¶
func (c *SkipperCollector) GetMetrics(ctx context.Context) ([]CollectedMetric, error)
GetMetrics gets skipper metrics from prometheus.
func (*SkipperCollector) Interval ¶
func (c *SkipperCollector) Interval() time.Duration
Interval returns the interval at which the collector should run.
type SkipperCollectorPlugin ¶
type SkipperCollectorPlugin struct {
// contains filtered or unexported fields
}
SkipperCollectorPlugin is a collector plugin for initializing metrics collectors for getting skipper ingress metrics.
func NewSkipperCollectorPlugin ¶
func NewSkipperCollectorPlugin(client kubernetes.Interface, rgClient rginterface.Interface, prometheusPlugin *PrometheusCollectorPlugin, backendAnnotations []string) (*SkipperCollectorPlugin, error)
NewSkipperCollectorPlugin initializes a new SkipperCollectorPlugin.
func (*SkipperCollectorPlugin) NewCollector ¶
func (c *SkipperCollectorPlugin) NewCollector(_ context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error)
NewCollector initializes a new skipper collector from the specified HPA.
type Store ¶ added in v0.1.11
Store represent an in memory Store for the [Cluster]ScalingSchedule objects. Its main implementation is the [cache.cache]0 struct returned by the [cache.NewStore]1 function. Here it's used mainly for tests/mock purposes.
type ZMONCollector ¶
type ZMONCollector struct {
// contains filtered or unexported fields
}
ZMONCollector defines a collector that is able to collect metrics from ZMON.
func NewZMONCollector ¶
func NewZMONCollector(zmon zmon.ZMON, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (*ZMONCollector, error)
NewZMONCollector initializes a new ZMONCollector.
func (*ZMONCollector) GetMetrics ¶
func (c *ZMONCollector) GetMetrics(ctx context.Context) ([]CollectedMetric, error)
GetMetrics returns a list of collected metrics for the ZMON check.
func (*ZMONCollector) Interval ¶
func (c *ZMONCollector) Interval() time.Duration
Interval returns the interval at which the collector should run.
type ZMONCollectorPlugin ¶
type ZMONCollectorPlugin struct {
// contains filtered or unexported fields
}
ZMONCollectorPlugin defines a plugin for creating collectors that can get metrics from ZMON.
func NewZMONCollectorPlugin ¶
func NewZMONCollectorPlugin(zmon zmon.ZMON) (*ZMONCollectorPlugin, error)
NewZMONCollectorPlugin initializes a new ZMONCollectorPlugin.
func (*ZMONCollectorPlugin) NewCollector ¶
func (c *ZMONCollectorPlugin) NewCollector(_ context.Context, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (Collector, error)
NewCollector initializes a new ZMON collector from the specified HPA.