collector

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExternalRPSMetricType = "requests-per-second"
	ExternalRPSQuery      = `scalar(sum(rate(%s{host=~"%s"}[1m])) * %.4f)`
)
View Source
const (
	HTTPJSONPathType          = "json-path"
	HTTPMetricNameLegacy      = "http"
	HTTPEndpointAnnotationKey = "endpoint"
	HTTPJsonPathAnnotationKey = "json-key"
)
View Source
const (
	InfluxDBMetricType       = "influxdb"
	InfluxDBMetricNameLegacy = "flux-query"
)
View Source
const (
	PrometheusMetricType       = "prometheus"
	PrometheusMetricNameLegacy = "prometheus-query"
)
View Source
const (
	// ZMONMetricType defines the metric type for metrics based on ZMON
	// checks.
	ZMONMetricType        = "zmon"
	ZMONCheckMetricLegacy = "zmon-check"
)
View Source
const (
	AWSSQSQueueLengthMetric = "sqs-queue-length"
)
View Source
const (
	// NakadiMetricType defines the metric type for metrics based on Nakadi
	// subscriptions.
	NakadiMetricType = "nakadi"
)

Variables

View Source
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

func GetPodReadyAge(pod corev1.Pod) (bool, time.Duration)

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(sessions map[string]*session.Session) *AWSCollectorPlugin

func (*AWSCollectorPlugin) NewCollector

NewCollector initializes a new skipper collector from the specified HPA.

type AWSSQSCollector

type AWSSQSCollector struct {
	// contains filtered or unexported fields
}

func NewAWSSQSCollector

func NewAWSSQSCollector(sessions map[string]*session.Session, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (*AWSSQSCollector, error)

func (*AWSSQSCollector) GetMetrics

func (c *AWSSQSCollector) GetMetrics() ([]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

GetMetrics is the main implementation for collector.Collector interface

func (*ClusterScalingScheduleCollector) Interval added in v0.1.11

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

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 Collector

type Collector interface {
	GetMetrics() ([]CollectedMetric, error)
	Interval() time.Duration
}

type CollectorFactory

type CollectorFactory struct {
	// contains filtered or unexported fields
}

func NewCollectorFactory

func NewCollectorFactory() *CollectorFactory

func (*CollectorFactory) NewCollector

func (c *CollectorFactory) NewCollector(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(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() ([]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

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() ([]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

type InfluxDBCollector added in v0.0.6

type InfluxDBCollector struct {
	// contains filtered or unexported fields
}

func NewInfluxDBCollector added in v0.0.6

func NewInfluxDBCollector(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() ([]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

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(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() ([]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

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

type Now func() time.Time

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 (*PodCollector) GetMetrics

func (c *PodCollector) GetMetrics() ([]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) *PodCollectorPlugin

func (*PodCollectorPlugin) NewCollector

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() ([]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

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() ([]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

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() ([]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

NewCollector initializes a new skipper collector from the specified HPA.

type Store added in v0.1.11

type Store interface {
	GetByKey(key string) (item interface{}, exists bool, err error)
}

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() ([]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

NewCollector initializes a new ZMON collector from the specified HPA.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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