metricscollector

package
v1.32.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (

	// Label Values for Syncer Sync Result Metrics
	EPCountsDiffer           = "EndpointCountsDiffer"
	EPNodeMissing            = "EndpointNodeMissing"
	EPNodeNotFound           = "EndpointNodeNotFound"
	EPPodMissing             = "EndpointPodMissing"
	EPPodNotFound            = "EndpointPodNotFound"
	EPPodTypeAssertionFailed = "EndpointPodTypeAssertionFailed"
	EPZoneMissing            = "EndpointZoneMissing"
	EPSEndpointCountZero     = "EndpointSliceEndpointCountZero"
	EPCalculationCountZero   = "EndpointCalculationCountZero"
	InvalidAPIResponse       = "InvalidAPIResponse"
	InvalidEPAttach          = "InvalidEndpointAttach"
	InvalidEPDetach          = "InvalidEndpointDetach"
	NegNotFound              = "NetworkEndpointGroupNotFound"
	CurrentNegEPNotFound     = "CurrentNEGEndpointNotFound"
	EPSNotFound              = "EndpointSliceNotFound"
	OtherError               = "OtherError"
	Success                  = "Success"
)

Variables

View Source
var (
	// SyncerCountBySyncResult tracks the count of syncer in different states
	SyncerCountBySyncResult = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Subsystem: negControllerSubsystem,
			Name:      "syncer_count",
			Help:      "Current count of syncers in each state",
		},
		[]string{"last_sync_result", "in_error_state"},
	)

	NumberOfEndpoints = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Subsystem: negControllerSubsystem,
			Name:      "number_of_endpoints",
			Help:      "The total number of endpoints",
		},
		[]string{"feature"},
	)

	DualStackMigrationFinishedDurations = prometheus.NewHistogram(
		prometheus.HistogramOpts{
			Subsystem: negControllerSubsystem,
			Name:      "dual_stack_migration_finished_durations_seconds",
			Help:      "Time taken to migrate all endpoints within all NEGs for a service port",

			Buckets: prometheus.ExponentialBuckets(1, 1.85, 18),
		},
	)

	// A zero value for this metric means that there are no ongoing migrations.
	DualStackMigrationLongestUnfinishedDuration = prometheus.NewGauge(
		prometheus.GaugeOpts{
			Subsystem: negControllerSubsystem,
			Name:      "dual_stack_migration_longest_unfinished_duration_seconds",
			Help:      "Longest time elapsed since a migration was started which hasn't yet completed",
		},
	)

	SyncerCountByEndpointType = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Subsystem: negControllerSubsystem,
			Name:      "syncer_count_by_endpoint_type",
			Help:      "Number of Syncers managing NEGs containing endpoint of a particular kind",
		},
		[]string{"endpoint_type"},
	)

	DualStackMigrationServiceCount = prometheus.NewGauge(
		prometheus.GaugeOpts{
			Subsystem: negControllerSubsystem,
			Name:      "dual_stack_migration_service_count",
			Help:      "Number of Services which have migration endpoints",
		},
	)
)

Functions

func RegisterMetrics

func RegisterMetrics()

RegisterSyncerMetrics registers syncer related metrics

Types

type LabelPropagationMetrics

type LabelPropagationMetrics struct {
	EndpointsWithAnnotation int
	NumberOfEndpoints       int
}

LabelPropagationMetrics contains aggregated label propagation related metrics.

type LabelPropagationStats

type LabelPropagationStats struct {
	EndpointsWithAnnotation int
	NumberOfEndpoints       int
}

LabelPropagationStat contains stats related to label propagation.

type NegServiceState added in v1.28.0

type NegServiceState struct {
	// standaloneNeg is the count of standalone NEG
	StandaloneNeg int
	// ingressNeg is the count of NEGs created for ingress
	IngressNeg int
	// asmNeg is the count of NEGs created for ASM
	AsmNeg int
	// VmIpNeg specifies if a service uses GCE_VM_IP NEG.
	VmIpNeg *VmIpNegType
	// CustomNamedNeg is the count of standalone negs with custom names
	CustomNamedNeg int
	// SuccessfulNeg is the count of successful NEG syncer creations
	SuccessfulNeg int
	// SuccessfulNeg is the count of errors in NEG syncer creations
	ErrorNeg int
}

NegServiceState contains all the neg usage associated with one service

type SyncerMetrics

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

func FakeSyncerMetrics

func FakeSyncerMetrics() *SyncerMetrics

FakeSyncerMetrics creates new NegMetricsCollector with fixed 5 second metricsInterval, to be used in tests

func NewNegMetricsCollector

func NewNegMetricsCollector(exportInterval time.Duration, logger klog.Logger) *SyncerMetrics

NewNEGMetricsCollector initializes SyncerMetrics and starts a go routine to compute and export metrics periodically.

func (*SyncerMetrics) CollectDualStackMigrationMetrics added in v1.24.0

func (sm *SyncerMetrics) CollectDualStackMigrationMetrics(key negtypes.NegSyncerKey, committedEndpoints map[negtypes.EndpointGroupInfo]negtypes.NetworkEndpointSet, migrationCount int)

CollectDualStackMigrationMetrics will be used by dualstack.Migrator to export metrics.

func (*SyncerMetrics) DeleteNegService added in v1.28.0

func (sm *SyncerMetrics) DeleteNegService(svcKey string)

DeleteNegService implements NegMetricsCollector.

func (*SyncerMetrics) DeleteSyncer

func (sm *SyncerMetrics) DeleteSyncer(key negtypes.NegSyncerKey)

DeleteSyncer will reset any metrics for the syncer corresponding to `key`. It should be invoked when a Syncer has been stopped.

func (*SyncerMetrics) Run

func (sm *SyncerMetrics) Run(stopCh <-chan struct{})

func (*SyncerMetrics) SetLabelPropagationStats

func (sm *SyncerMetrics) SetLabelPropagationStats(key negtypes.NegSyncerKey, labelstatLabelPropagationStats LabelPropagationStats)

func (*SyncerMetrics) SetNegService added in v1.28.0

func (sm *SyncerMetrics) SetNegService(svcKey string, negState NegServiceState)

SetNegService implements NegMetricsCollector.

func (*SyncerMetrics) UpdateSyncerEPMetrics added in v1.24.0

func (sm *SyncerMetrics) UpdateSyncerEPMetrics(key negtypes.NegSyncerKey, endpointCount, endpointSliceCount negtypes.StateCountMap)

func (*SyncerMetrics) UpdateSyncerNegCount

func (sm *SyncerMetrics) UpdateSyncerNegCount(key negtypes.NegSyncerKey, negsByLocation map[string]int)

func (*SyncerMetrics) UpdateSyncerStatusInMetrics added in v1.24.0

func (sm *SyncerMetrics) UpdateSyncerStatusInMetrics(key negtypes.NegSyncerKey, err error, inErrorState bool)

UpdateSyncerStatusInMetrics update the status of syncer based on the error

type SyncerMetricsCollector

type SyncerMetricsCollector interface {
	// UpdateSyncerStatusInMetrics update the status of corresponding syncer based on the sync error
	UpdateSyncerStatusInMetrics(key negtypes.NegSyncerKey, err error, inErrorState bool)
	// UpdateSyncerEPMetrics update the endpoint and endpointSlice count for the given syncer
	UpdateSyncerEPMetrics(key negtypes.NegSyncerKey, endpointCount, endpointSliceCount negtypes.StateCountMap)
	SetLabelPropagationStats(key negtypes.NegSyncerKey, labelstatLabelPropagationStats LabelPropagationStats)
	// Updates the number of negs per syncer per zone
	UpdateSyncerNegCount(key negtypes.NegSyncerKey, negByLocation map[string]int)
	// SetNegService adds/updates neg state for given service key.
	SetNegService(svcKey string, negState NegServiceState)
	// DeleteNegService removes the given service key.
	DeleteNegService(svcKey string)
}

type VmIpNegType added in v1.28.0

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

VmIpNegType contains whether a GCE_VM_IP NEG is requesting for local traffic (or service external policy set to local).

func NewVmIpNegType added in v1.28.0

func NewVmIpNegType(trafficPolicyLocal bool) *VmIpNegType

NewVmIpNegType returns a new VmIpNegType.

Jump to

Keyboard shortcuts

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