metrics

package
v0.36.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 6 Imported by: 4

Documentation

Index

Constants

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

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

	// Reasons for CREATE/DELETE shared metrics
	ConsolidationReason = "consolidation"
	ProvisioningReason  = "provisioning"
	ExpirationReason    = "expiration"
	EmptinessReason     = "emptiness"
	DriftReason         = "drift"
)
View Source
const (
	NodeSubsystem = "nodes"
)

Variables

View Source
var (
	NodeClaimsCreatedCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: Namespace,
			Subsystem: nodeClaimSubsystem,
			Name:      "created",
			Help:      "Number of nodeclaims created in total by Karpenter. Labeled by reason the nodeclaim was created and the owning nodepool.",
		},
		[]string{
			ReasonLabel,
			NodePoolLabel,
			CapacityTypeLabel,
		},
	)
	NodeClaimsTerminatedCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: Namespace,
			Subsystem: nodeClaimSubsystem,
			Name:      "terminated",
			Help:      "Number of nodeclaims terminated in total by Karpenter. Labeled by reason the nodeclaim was terminated and the owning nodepool.",
		},
		[]string{
			ReasonLabel,
			NodePoolLabel,
			CapacityTypeLabel,
		},
	)
	NodeClaimsLaunchedCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: Namespace,
			Subsystem: nodeClaimSubsystem,
			Name:      "launched",
			Help:      "Number of nodeclaims launched in total by Karpenter. Labeled by the owning nodepool.",
		},
		[]string{
			NodePoolLabel,
		},
	)
	NodeClaimsRegisteredCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: Namespace,
			Subsystem: nodeClaimSubsystem,
			Name:      "registered",
			Help:      "Number of nodeclaims registered in total by Karpenter. Labeled by the owning nodepool.",
		},
		[]string{
			NodePoolLabel,
		},
	)
	NodeClaimsInitializedCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: Namespace,
			Subsystem: nodeClaimSubsystem,
			Name:      "initialized",
			Help:      "Number of nodeclaims initialized in total by Karpenter. Labeled by the owning nodepool.",
		},
		[]string{
			NodePoolLabel,
		},
	)
	NodeClaimsDisruptedCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: Namespace,
			Subsystem: nodeClaimSubsystem,
			Name:      "disrupted",
			Help:      "Number of nodeclaims disrupted in total by Karpenter. Labeled by disruption type of the nodeclaim and the owning nodepool.",
		},
		[]string{
			TypeLabel,
			NodePoolLabel,
		},
	)
	NodeClaimsDriftedCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: Namespace,
			Subsystem: nodeClaimSubsystem,
			Name:      "drifted",
			Help:      "Number of nodeclaims drifted reasons in total by Karpenter. Labeled by drift type of the nodeclaim and the owning nodepool.",
		},
		[]string{
			TypeLabel,
			NodePoolLabel,
		},
	)
	NodesCreatedCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: Namespace,
			Subsystem: NodeSubsystem,
			Name:      "created",
			Help:      "Number of nodes created in total by Karpenter. Labeled by owning nodepool.",
		},
		[]string{
			NodePoolLabel,
		},
	)
	NodesTerminatedCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: Namespace,
			Subsystem: NodeSubsystem,
			Name:      "terminated",
			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 prometheus.Observer) 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 {
	*prometheus.GaugeVec
	Value  float64
	Labels prometheus.Labels
}

StoreMetric is a single state metric associated with a prometheus.GaugeVec

Jump to

Keyboard shortcuts

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