metrics

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package metrics defines the Prometheus collectors shared across kyverno-runtime's collector, attribution, monitor, and reporter packages, plus a small HTTP server helper to expose them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(ctx context.Context, addr string, g prometheus.Gatherer, health func() error, log logr.Logger) error

Serve starts an HTTP server exposing g at "/metrics" and health at "/healthz" on addr. It blocks until ctx is canceled or the server fails to serve, then shuts the server down and returns. A nil error is returned for both a clean shutdown and a graceful listener close.

Types

type Metrics

type Metrics struct {
	// EventsIngested counts runtime events ingested by the collector,
	// labeled by source and kind.
	EventsIngested *prometheus.CounterVec
	// EventsDropped counts events dropped by the collector, labeled by
	// source and reason.
	EventsDropped *prometheus.CounterVec
	// SourceAvailable reports whether a source has announced readiness.
	SourceAvailable *prometheus.GaugeVec
	// SourceFailures counts source lifecycle failures by stable reason.
	SourceFailures *prometheus.CounterVec
	// AttributionMisses counts events that could not be attributed to a
	// pod (see pkg/attribution.Index.Annotate).
	AttributionMisses prometheus.Counter
	// MonitorFilterEvalErrors counts monitorFilter expressions that failed to
	// evaluate, labeled by policy and expression name. A failure reports the
	// finding anyway, so this counts filters that are not narrowing.
	MonitorFilterEvalErrors *prometheus.CounterVec
	// FindingsEmitted counts findings emitted to the reporter, labeled by
	// policy and behavior.
	FindingsEmitted *prometheus.CounterVec
	// ReportWrites counts OpenReports write attempts, labeled by result
	// (ok|error|skipped).
	ReportWrites *prometheus.CounterVec
}

Metrics holds every Prometheus collector registered by kyverno-runtime.

func New

func New(reg prometheus.Registerer) *Metrics

New creates and registers all collectors against reg. Passing a fresh *prometheus.Registry (rather than the global DefaultRegisterer) keeps tests and repeated daemon.go wiring free of "duplicate metrics collector registration" panics.

func (*Metrics) RecordSourceStatus added in v0.1.3

func (m *Metrics) RecordSourceStatus(source string, state runtimeevent.SourceState, reason string)

RecordSourceStatus updates the source lifecycle metrics. It accepts the source status seam directly so all production lifecycle writes share one path.

Jump to

Keyboard shortcuts

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