metrics

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: Apache-2.0 Imports: 7 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// Common namespace for application metrics.
	Namespace = "karpenter"

	NodePoolLabel     = "nodepool"
	ReasonLabel       = "reason"
	CapacityTypeLabel = "capacity_type"

	// Reasons for CREATE/DELETE shared metrics
	ProvisionedReason = "provisioned"
	ExpiredReason     = "expired"
	UnhealthyReason   = "unhealthy"
)
View Source
const (
	NodeSubsystem      = "nodes"
	NodeClaimSubsystem = "nodeclaims"
	NodePoolSubsystem  = "nodepools"
	PodSubsystem       = "pods"
)

Variables

View Source
var (
	NodeClaimsCreatedTotal = opmetrics.NewPrometheusCounter(
		crmetrics.Registry,
		prometheus.CounterOpts{
			Namespace: Namespace,
			Subsystem: NodeClaimSubsystem,
			Name:      "created_total",
			Help:      "Number of nodeclaims created in total by Karpenter. Labeled by reason the nodeclaim was created and the owning nodepool.",
		},
		[]string{
			ReasonLabel,
			NodePoolLabel,
			CapacityTypeLabel,
		},
	)
	NodeClaimsTerminatedTotal = opmetrics.NewPrometheusCounter(
		crmetrics.Registry,
		prometheus.CounterOpts{
			Namespace: Namespace,
			Subsystem: NodeClaimSubsystem,
			Name:      "terminated_total",
			Help:      "Number of nodeclaims terminated in total by Karpenter. Labeled by the owning nodepool.",
		},
		[]string{
			NodePoolLabel,
			CapacityTypeLabel,
		},
	)
	NodeClaimsDisruptedTotal = opmetrics.NewPrometheusCounter(
		crmetrics.Registry,
		prometheus.CounterOpts{
			Namespace: Namespace,
			Subsystem: NodeClaimSubsystem,
			Name:      "disrupted_total",
			Help:      "Number of nodeclaims disrupted in total by Karpenter. Labeled by reason the nodeclaim was disrupted and the owning nodepool.",
		},
		[]string{
			ReasonLabel,
			NodePoolLabel,
			CapacityTypeLabel,
		},
	)
	NodesCreatedTotal = opmetrics.NewPrometheusCounter(
		crmetrics.Registry,
		prometheus.CounterOpts{
			Namespace: Namespace,
			Subsystem: NodeSubsystem,
			Name:      "created_total",
			Help:      "Number of nodes created in total by Karpenter. Labeled by owning nodepool.",
		},
		[]string{
			NodePoolLabel,
		},
	)
	NodesTerminatedTotal = opmetrics.NewPrometheusCounter(
		crmetrics.Registry,
		prometheus.CounterOpts{
			Namespace: Namespace,
			Subsystem: NodeSubsystem,
			Name:      "terminated_total",
			Help:      "Number of nodes terminated in total by Karpenter. Labeled by owning nodepool.",
		},
		[]string{
			NodePoolLabel,
		},
	)
)

Functions

func DurationBuckets

func DurationBuckets() []float64

DurationBuckets returns a []float64 of default threshold values for duration histograms. Each returned slice is new and may be modified without impacting other bucket definitions.

func Measure

func Measure(observer opmetrics.ObservationMetric, labels map[string]string) func()

Measure returns a deferrable function that observes the duration between the defer statement and the end of the function.

func SummaryObjectives

func SummaryObjectives() map[float64]float64

Returns a map of summary objectives (quantile-error pairs)

Types

type Store

type Store struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Store is a mapping from a key to a list of Metrics Each time Update() is called for a key on Store, the metric store ensures that all metrics are "refreshed" for all currently tracked metrics assigned to the key. This means that any metric that contains the same labels as a previous metric will be updated through the standard prometheus.Gauge metric Set() call while any metric with different labels than the recently fired metrics will be removed from the prometheus client response and the Store

func NewStore

func NewStore() *Store

func (*Store) Delete

func (s *Store) Delete(key string)

Delete calls the delete() method internally

func (*Store) ReplaceAll

func (s *Store) ReplaceAll(newStore map[string][]*StoreMetric)

ReplaceAll replaces all metrics in the store with the new metrics passes into the ReplaceAll function. This calls the update method as normal for any keys that match existing keys while removing any keys that existed in the old store but don't exist in the new store.

func (*Store) Update

func (s *Store) Update(key string, metrics []*StoreMetric)

Update calls the update() method internally

type StoreMetric

type StoreMetric struct {
	opmetrics.GaugeMetric
	Value  float64
	Labels prometheus.Labels
}

StoreMetric is a single state metric associated with a metrics.Gauge

Jump to

Keyboard shortcuts

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