metrics

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package metrics implements the optional kubesolo Prometheus metrics endpoint.

It exposes a small /metrics HTTP server that surfaces KubeSolo-native gauges describing the health of each control plane component (apiserver, kine, controller-manager, kubelet, kube-proxy, runtime, coredns, webhook), plus build info, kine DB size, and process uptime.

Component-internal Prometheus metrics are out of scope — this endpoint is intentionally small and focused on operator-facing health monitoring.

Index

Constants

View Source
const (
	ComponentRuntime    = "runtime"
	ComponentKine       = "kine"
	ComponentAPIServer  = "apiserver"
	ComponentController = "controller"
	ComponentKubelet    = "kubelet"
	ComponentKubeProxy  = "kubeproxy"
	ComponentCoreDNS    = "coredns"
	ComponentWebhook    = "webhook"
)

componentNames is the canonical list of components that the metrics service reports an "up" gauge for. Channels in componentReady use the same keys.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildInfo

type BuildInfo struct {
	Version   string
	Commit    string
	BuildDate string
}

BuildInfo carries version metadata stamped by the Makefile via -ldflags. It is used to populate the kubesolo_build_info gauge.

type Service

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

Service is the kubesolo metrics endpoint service. It follows the same NewService/Run + readyCh pattern as the other kubesolo components.

func NewService

func NewService(
	ctx context.Context,
	cancel context.CancelFunc,
	readyCh chan struct{},
	embedded types.Embedded,
	build BuildInfo,
	componentReady map[string]<-chan struct{},
) *Service

NewService creates a new metrics service.

componentReady is a map of component name to readiness channel. The metrics service watches each channel and flips kubesolo_component_up to 1 plus stamps kubesolo_component_ready_timestamp_seconds when the channel closes.

The service does not block any other component on its own readiness — the readyCh argument is only used so main can join the goroutine on shutdown.

func (*Service) Run

func (s *Service) Run() error

Run starts the metrics service. It builds the Prometheus registry, starts the HTTP server, watches readiness channels to flip per-component "up" gauges, and runs a periodic prober. It blocks until ctx is done.

Jump to

Keyboard shortcuts

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