provider

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// CollectionSuccesses is the total number of successful collections.
	CollectionSuccesses = promauto.NewCounter(prometheus.CounterOpts{
		Name: "kube_metrics_adapter_collections_success",
		Help: "The total number of successful collections",
	})
	// CollectionErrors is the total number of failed collection attempts.
	CollectionErrors = promauto.NewCounter(prometheus.CounterOpts{
		Name: "kube_metrics_adapter_collections_error",
		Help: "The total number of failed collection attempts",
	})
	// UpdateSuccesses is the total number of successful HPA updates.
	UpdateSuccesses = promauto.NewCounter(prometheus.CounterOpts{
		Name: "kube_metrics_adapter_updates_success",
		Help: "The total number of successful HPA updates",
	})
	// UpdateErrors is the total number of failed HPA update attempts.
	UpdateErrors = promauto.NewCounter(prometheus.CounterOpts{
		Name: "kube_metrics_adapter_updates_error",
		Help: "The total number of failed HPA update attempts",
	})
)

Functions

This section is empty.

Types

type CollectorScheduler

type CollectorScheduler struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

CollectorScheduler is a scheduler for running metric collection jobs. It keeps track of all running collectors and stops them if they are to be removed.

func NewCollectorScheduler

func NewCollectorScheduler(ctx context.Context, metricsc chan<- metricCollection) *CollectorScheduler

NewCollectorScheudler initializes a new CollectorScheduler.

func (*CollectorScheduler) Add

func (t *CollectorScheduler) Add(resourceRef resourceReference, typeName collector.MetricTypeName, metricCollector collector.Collector)

Add adds a new collector to the collector scheduler. Once the collector is added it will be started to collect metrics.

func (*CollectorScheduler) Remove

func (t *CollectorScheduler) Remove(resourceRef resourceReference)

Remove removes a collector from the Collector scheduler. The collector is stopped before it's removed.

type HPAProvider

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

HPAProvider is a base provider for initializing metric collectors based on HPA resources.

func NewHPAProvider

func NewHPAProvider(client kubernetes.Interface, interval, collectorInterval time.Duration, collectorFactory *collector.CollectorFactory, disregardIncompatibleHPAs bool, metricsTTL time.Duration, gcInterval time.Duration) *HPAProvider

NewHPAProvider initializes a new HPAProvider.

func (*HPAProvider) GetExternalMetric

func (p *HPAProvider) GetExternalMetric(ctx context.Context, namespace string, metricSelector labels.Selector, info provider.ExternalMetricInfo) (*external_metrics.ExternalMetricValueList, error)

func (*HPAProvider) GetMetricByName

func (p *HPAProvider) GetMetricByName(ctx context.Context, name types.NamespacedName, info provider.CustomMetricInfo, metricSelector labels.Selector) (*custom_metrics.MetricValue, error)

GetMetricByName gets a single metric by name.

func (*HPAProvider) GetMetricBySelector

func (p *HPAProvider) GetMetricBySelector(ctx context.Context, namespace string, selector labels.Selector, info provider.CustomMetricInfo, metricSelector labels.Selector) (*custom_metrics.MetricValueList, error)

GetMetricBySelector returns metrics for namespaced resources by label selector.

func (*HPAProvider) ListAllExternalMetrics

func (p *HPAProvider) ListAllExternalMetrics() []provider.ExternalMetricInfo

func (*HPAProvider) ListAllMetrics

func (p *HPAProvider) ListAllMetrics() []provider.CustomMetricInfo

ListAllMetrics list all available metrics from the provicer.

func (*HPAProvider) Run

func (p *HPAProvider) Run(ctx context.Context)

Run runs the HPA resource discovery and metric collection.

type MetricStore

type MetricStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

MetricStore is a simple in-memory Metrics Store for HPA metrics.

func NewMetricStore

func NewMetricStore(ttlCalculator func() time.Time) *MetricStore

NewMetricStore initializes an empty Metrics Store.

func (*MetricStore) GetExternalMetric

func (s *MetricStore) GetExternalMetric(_ context.Context, namespace objectNamespace, selector labels.Selector, info provider.ExternalMetricInfo) (*external_metrics.ExternalMetricValueList, error)

GetExternalMetric gets external metric from the store by metric name and selector.

func (*MetricStore) GetMetricsByName

GetMetricsByName looks up metrics in the customMetricsStore by resource name.

func (*MetricStore) GetMetricsBySelector

func (s *MetricStore) GetMetricsBySelector(_ context.Context, namespace objectNamespace, selector labels.Selector, info provider.CustomMetricInfo) *custom_metrics.MetricValueList

GetMetricsBySelector gets metric from the customMetricsStore using a label selector to find metrics for matching resources.

func (*MetricStore) Insert

func (s *MetricStore) Insert(value collector.CollectedMetric)

Insert inserts a collected metric into the metric customMetricsStore.

func (*MetricStore) ListAllExternalMetrics

func (s *MetricStore) ListAllExternalMetrics() []provider.ExternalMetricInfo

ListAllExternalMetrics lists all external metrics in the Metrics Store.

func (*MetricStore) ListAllMetrics

func (s *MetricStore) ListAllMetrics() []provider.CustomMetricInfo

ListAllMetrics lists all custom metrics in the Metrics Store.

func (*MetricStore) RemoveExpired

func (s *MetricStore) RemoveExpired()

RemoveExpired removes expired metrics from the Metrics Store. A metric is considered expired if its metricsTTL is before time.Now().

Jump to

Keyboard shortcuts

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