Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KnownStates ¶
KnownStates converts the given slice of ~string to a slice of strings.
func KnownStatesStringer ¶
KnownStatesStringer converts the given slice of fmt.Stringer to a slice of strings.
Types ¶
type Exporter ¶
type Exporter[O client.Object, L client.ObjectList] struct { client.Reader Namespace, Subsystem string // StaticLabelKeys are added to all Metrics of this Exporter. StaticLabelKeys []string // GenerateStaticLabelValues returns the values for StaticLabelKeys. GenerateStaticLabelValues func(O) []string Metrics []Metric[O] // optional ListOptions []client.ListOption }
Exporter is a generic state metrics exporter for a given Kubernetes object kind that can be added to a controller-runtime manager.
func (*Exporter[O, L]) AddToManager ¶
AddToManager adds this exporter to the given manager and completes the Metrics descriptors.
func (*Exporter[O, L]) Collect ¶
func (e *Exporter[O, L]) Collect(ch chan<- prometheus.Metric)
func (*Exporter[O, L]) Describe ¶
func (e *Exporter[O, L]) Describe(ch chan<- *prometheus.Desc)
func (*Exporter[O, L]) NeedLeaderElection ¶
NeedLeaderElection tells the manager to run the exporter in all instances.
type GenerateFunc ¶
type GenerateFunc[O client.Object] func(desc *prometheus.Desc, obj O, staticLabelValues []string, ch chan<- prometheus.Metric)
func GenerateStateSet ¶
func GenerateStateSet[O client.Object](knownStates []string, unknownState *string, getState func(O) string) GenerateFunc[O]
GenerateStateSet returns a GenerateFunc that emits stateset metrics: - it generates one metric per known state - the value is 1 if getState returns the state, 0 otherwise - if unknownState is given, a metric with this state label is generated with value 1 if no other state has matched
type Metric ¶
type Metric[O client.Object] struct { Name, Help string LabelKeys []string // Generate returns all metric values for the given object. // staticLabelValues is the result of Exporter.GenerateStaticLabelValues and should be added as the first label values // to all metrics. Generate GenerateFunc[O] // contains filtered or unexported fields }
Metric describes a single metric and how to generate it per object.