label

package
v0.0.0-...-33ac69c Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package label contains code for parsing spate service labels and constructing objects out of them.

Index

Constants

View Source
const (

	// Namespace for spate
	Namespace = "de.mtneug.spate"

	// AutoscalerPeriod is the suffix (after spate namespace) for the autoscaler
	// period.
	AutoscalerPeriod = "autoscaler.period"

	// AutoscalerCooldownScaledUp is the suffix (after spate namespace) for
	// autoscaler cooldown time after a ScaledUp.
	AutoscalerCooldownScaledUp = "autoscaler.cooldown.scaled_up"

	// AutoscalerCooldownScaledDown is the suffix (after spate namespace) for
	// autoscaler cooldown time after a ScaledDown.
	AutoscalerCooldownScaledDown = "autoscaler.cooldown.scaled_down"

	// AutoscalerCooldownServiceAdded is the suffix (after spate namespace) for
	// autoscaler cooldown time after a ServiceAdded.
	AutoscalerCooldownServiceAdded = "autoscaler.cooldown.service_added"

	// AutoscalerCooldownServiceUpdated is the suffix (after spate namespace) for
	// autoscaler cooldown time after a ServiceUpdated.
	AutoscalerCooldownServiceUpdated = "autoscaler.cooldown.service_updated"

	// ReplicaMin is the suffix (after spate namespace) for the minimum number of
	// replicas.
	ReplicaMin = "replica.min"

	// ReplicaMax is the suffix (after spate namespace) for the maximum number of
	// replicas.
	ReplicaMax = "replica.max"

	// MetricSuffix is the suffix (after spate namespace) for metrics.
	MetricSuffix = "metric"

	// MetricTypeSuffix is the suffix (after metric name) for the type.
	MetricTypeSuffix = "type"

	// MetricKindSuffix is the suffix (after metric name) for the kind.
	MetricKindSuffix = "kind"

	// MetricPrometheusEndpointSuffix is the suffix (after metric name) for the
	// Prometheus endpoint.
	MetricPrometheusEndpointSuffix = "prometheus.endpoint"

	// MetricPrometheusNameSuffix is the suffix (after metric name) for the
	// Prometheus metric name.
	MetricPrometheusNameSuffix = "prometheus.name"

	// MetricAggregationMethodSuffix is the suffix (after metric name) for the
	// aggregation method.
	MetricAggregationMethodSuffix = "aggregation.method"

	// MetricAggregationMethodMax in string form.
	MetricAggregationMethodMax = "max"

	// MetricAggregationMethodMin in string form.
	MetricAggregationMethodMin = "min"

	// MetricAggregationMethodAvg in string form.
	MetricAggregationMethodAvg = "avg"

	// MetricAggregationAmountSuffix is the suffix (after metric name) for the
	// aggregation amount.
	MetricAggregationAmountSuffix = "aggregation.amount"

	// MetricObserverPeriodSuffix is the suffix (after metric name) for the
	// observer period.
	MetricObserverPeriodSuffix = "observer.period"

	// MetricTargetSuffix is the suffix (after metric name) for the target.
	MetricTargetSuffix = "target"

	// MetricTargetDeviationLowerSuffix is the suffix (after metric name) for the
	// lower deviation.
	MetricTargetDeviationLowerSuffix = "target.deviation.lower"

	// MetricTargetDeviationUpperSuffix is the suffix (after metric name) for the
	// lower deviation.
	MetricTargetDeviationUpperSuffix = "target.deviation.upper"
)

Variables

View Source
var (
	// DefaultAutoscalerPeriod for autoscaler.
	DefaultAutoscalerPeriod = 30 * time.Second

	// DefaultCooldownScaledUp for autoscaler.
	DefaultCooldownScaledUp = 3 * time.Minute

	// DefaultCooldownScaledDown for autoscaler.
	DefaultCooldownScaledDown = 5 * time.Minute

	// DefaultCooldownServiceAdded for autoscaler.
	DefaultCooldownServiceAdded = 0 * time.Second

	// DefaultCooldownServiceUpdated for autoscaler.
	DefaultCooldownServiceUpdated = 0 * time.Second
)
View Source
var (
	// ErrInvalidMetricLabel indicates that the parsing failed because the metric
	// label is invalid.
	ErrInvalidMetricLabel = errors.New("label: metric label invalid")

	// ErrDuplicateMetric indicates that at least two metrics are the same.
	ErrDuplicateMetric = errors.New("label: duplicate metric")

	// ErrNoType indicates that the parsing failed because no type was specified.
	ErrNoType = errors.New("label: no type specified")

	// ErrUnknownType indicates that the parsing failed because the type is
	// unknown.
	ErrUnknownType = errors.New("label: unknown type")

	// ErrNoKind indicates that the parsing failed because no kind was specified.
	ErrNoKind = errors.New("label: no kind specified")

	// ErrUnknownKind indicates that the parsing failed because the kind is
	// unknown.
	ErrUnknownKind = errors.New("label: unknown kind")

	// ErrWrongKind indicates that the parsing failed because a wrong kind was
	// used for the metric.
	ErrWrongKind = errors.New("label: wrong kind")

	// ErrNoPrometheusEndpoint indicates that the parsing failed because no
	// Prometheus endpoint was specified.
	ErrNoPrometheusEndpoint = errors.New("label: no Prometheus endpoint specified")

	// ErrInvalidHTTPUrl indicates that the parsing failed because the specified
	// URL is an invalid HTTP URL.
	ErrInvalidHTTPUrl = errors.New("label: invalid HTTP URL")

	// ErrNoPrometheusMetricName indicates that the parsing failed because no
	// Prometheus metric name was specified.
	ErrNoPrometheusMetricName = errors.New("label: no Prometheus metric name specified")

	// ErrUnknownAggregationMethod indicates that the parsing failed because the
	// aggregation method is unknown.
	ErrUnknownAggregationMethod = errors.New("label: aggregation method is unknown")

	// ErrNoValue indicates that the parsing failed because no value was
	// specified.
	ErrNoValue = errors.New("label: no value specified")

	// ErrInvalidFloat indicates that the parsing failed because the float is
	// invalid.
	ErrInvalidFloat = errors.New("label: invalid float")

	// ErrInvalidDeviation indicates that the parsing failed because the deviation
	// is invalid.
	ErrInvalidDeviation = errors.New("label: invalid deviation")

	// ErrInvalidDuration indicates that the parsing failed because the duration
	// is invalid.
	ErrInvalidDuration = errors.New("label: invalid duration")

	// ErrInvalidUint indicates that the parsing failed because the uint is
	// invalid.
	ErrInvalidUint = errors.New("label: invalid uint")
)
View Source
var (
	// DefaultObserverPeriod for new observers.
	DefaultObserverPeriod = 30 * time.Second

	// DefaultObserverAggregationAmount for new observers.
	DefaultObserverAggregationAmount uint8 = 5
)
View Source
var (
	// DefaultTargetValueCPU if no value given.
	DefaultTargetValueCPU = 0.8

	// DefaultTargetValueMemory if no value given.
	DefaultTargetValueMemory = 0.8
)

Functions

func ConstructAutoscaler

func ConstructAutoscaler(srv swarm.Service) (*autoscaler.Autoscaler, error)

ConstructAutoscaler creates a new autoscaler based on a swarm service.

func ExtractSpateLabels

func ExtractSpateLabels(labels map[string]string, metricLabels map[string]map[string]string,
	srvLabels map[string]string) error

ExtractSpateLabels from service labels.

func ParseAutoscaler

func ParseAutoscaler(a *autoscaler.Autoscaler, labels map[string]string) error

ParseAutoscaler parses the labels and sets the corresponding values for given autoscaler.

func ParseMetric

func ParseMetric(m *metric.Metric, labels map[string]string) error

ParseMetric parses the labels and sets the corresponding values for given metric.

func ParseObserver

func ParseObserver(observer *metric.Observer, labels map[string]string) error

ParseObserver parses the labels and sets the corresponding values for given observer.

func ParseReducer

func ParseReducer(labels map[string]string) (reducer.Reducer, error)

ParseReducer parses the labels and returnes the correct reducer.

func ParseTarget

func ParseTarget(target *metric.Target, labels map[string]string) error

ParseTarget parses the labels and sets the corresponding values for given target.

Types

This section is empty.

Jump to

Keyboard shortcuts

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