Documentation ¶
Overview ¶
Package statemetrics is library contains interface and utilities to expose prometheus metrics for Kubernetes Resources state.
The interface is inspired by how k8s.io/kube-state-metrics provides state metrics for Kubernetes Custom Resources. This library uses prometheus.Collector interface to write the metrics instead of using the own writer generator as k8s.io/kube-state-metrics do. That makes this library compatible with Prometheus Registry
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector struct { // APIReader is a controller-runtime client.Reader // that configured to uses the API server instead of cache. APIReader client.Reader // CacheReader is a controller-runtime client.Reader // that configured to uses controller-runtime cache. CacheReader client.Reader // contains filtered or unexported fields }
Collector collects prometheus metrics from given providers
func (*Collector) Collect ¶
func (c *Collector) Collect(ch chan<- prometheus.Metric)
Collect implements prometheus.Collector.
func (*Collector) Describe ¶
func (c *Collector) Describe(ch chan<- *prometheus.Desc)
Describe implements prometheus.Collector.
type Metric ¶
type Metric struct { // LabelKeys list of prometheus label keys. LabelKeys []string // LabelValues list of prometheus label values. LabelValues []string // Value is prometheus metric value. Value float64 }
Metric represents a single time series.
type MetricFamily ¶
type MetricFamily struct { // Name is name of metrics Name string // Help provides information about this metric. Help string // Type is prometheus metric types. Type prometheus.ValueType // MetricsFunc knowns how to provide the metrics from given Kubernetes Object. MetricsFunc func(obj runtime.Object) []*Metric }
MetricFamily represents a set of metrics with the same name and help text.
type Provider ¶
type Provider interface { // Namespace returns the prometheus namespace of this provider. Namespace() string // Subsystem returns the prometheus subsystem of this provider. Subsystem() string // ProvideMetricFamily returns slice of MetricFamily. ProvideMetricFamily() []MetricFamily // Lister knowns how to fetch list of Kubernetes Objects. Lister(ctx context.Context, r client.Reader) cache.Lister }
Provider knowns how to construct and scrape the metrics.