metrics

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package metrics provides Prometheus metrics for the Keeper K8s Injector.

Index

Constants

This section is empty.

Variables

View Source
var (
	// MutationsTotal counts total pod mutations
	MutationsTotal = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: namespace,
			Subsystem: "injector",
			Name:      "mutations_total",
			Help:      "Total number of pod mutations",
		},
		[]string{"namespace", "result"},
	)

	// MutationDuration tracks mutation latency
	MutationDuration = promauto.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: namespace,
			Subsystem: "injector",
			Name:      "mutation_duration_seconds",
			Help:      "Time spent processing pod mutations",
			Buckets:   prometheus.DefBuckets,
		},
		[]string{"namespace"},
	)

	// SecretsInjected tracks number of secrets injected per mutation
	SecretsInjected = promauto.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: namespace,
			Subsystem: "injector",
			Name:      "secrets_injected",
			Help:      "Number of secrets injected per pod",
			Buckets:   []float64{0, 1, 2, 3, 5, 10, 20},
		},
		[]string{"namespace"},
	)
)

Webhook metrics

View Source
var (
	// SecretFetchesTotal counts total secret fetches
	SecretFetchesTotal = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: namespace,
			Subsystem: "sidecar",
			Name:      "secret_fetches_total",
			Help:      "Total number of secret fetches",
		},
		[]string{"secret", "result"},
	)

	// SecretFetchDuration tracks fetch latency
	SecretFetchDuration = promauto.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: namespace,
			Subsystem: "sidecar",
			Name:      "secret_fetch_duration_seconds",
			Help:      "Time spent fetching secrets from KSM",
			Buckets:   prometheus.DefBuckets,
		},
		[]string{"secret"},
	)

	// SecretsActive tracks number of active secrets
	SecretsActive = promauto.NewGauge(
		prometheus.GaugeOpts{
			Namespace: namespace,
			Subsystem: "sidecar",
			Name:      "secrets_active",
			Help:      "Number of secrets currently being managed",
		},
	)

	// LastRefreshTimestamp tracks last successful refresh
	LastRefreshTimestamp = promauto.NewGauge(
		prometheus.GaugeOpts{
			Namespace: namespace,
			Subsystem: "sidecar",
			Name:      "last_refresh_timestamp",
			Help:      "Unix timestamp of last successful secret refresh",
		},
	)

	// RefreshCyclesTotal counts refresh cycles
	RefreshCyclesTotal = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: namespace,
			Subsystem: "sidecar",
			Name:      "refresh_cycles_total",
			Help:      "Total number of refresh cycles",
		},
		[]string{"result"},
	)
)

Sidecar metrics

Functions

func RecordMutation

func RecordMutation(namespace string, success bool, duration float64, secretCount int)

RecordMutation records a mutation event

func RecordRefreshCycle

func RecordRefreshCycle(success bool)

RecordRefreshCycle records a refresh cycle completion

func RecordSecretFetch

func RecordSecretFetch(secretName string, success bool, duration float64)

RecordSecretFetch records a secret fetch event

Types

This section is empty.

Jump to

Keyboard shortcuts

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