Documentation ¶
Overview ¶
Package metrics implements the metrics server.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Counter ¶ added in v0.4.0
type Counter interface { prometheus.Metric prometheus.Collector // Set sets the counter to the given value. Set(value float64) }
Counter is a prometheus counter that can be incremented and decremented.
func NewCounter ¶ added in v0.4.0
func NewCounter(opts CounterOpts) Counter
NewCounter returns a new counter.
type CounterOpts ¶ added in v0.4.0
type CounterOpts = prometheus.CounterOpts
CounterOpts is a prometheus counter options.
type DataSource ¶ added in v0.4.0
DataSource is the interface for getting data for metrics
type Environment ¶ added in v0.6.0
type Environment struct {
// contains filtered or unexported fields
}
Environment is environment in which cel programs are executed
func NewEnvironment ¶ added in v0.6.0
func NewEnvironment(conf EnvironmentConfig) (*Environment, error)
NewEnvironment returns a Environment that is able to evaluate node metrics
func (*Environment) ClearResultCache ¶ added in v0.6.0
func (e *Environment) ClearResultCache()
ClearResultCache clears the result cache
type EnvironmentConfig ¶ added in v0.6.0
type EnvironmentConfig struct { EnableResultCache bool Now func() time.Time StartedContainersTotal func(nodeName string) int64 ContainerResourceUsage func(resourceName, podNamespace, podName, containerName string) float64 PodResourceUsage func(resourceName, podNamespace, podName string) float64 NodeResourceUsage func(resourceName, nodeName string) float64 ContainerResourceCumulativeUsage func(resourceName, podNamespace, podName, containerName string) float64 PodResourceCumulativeUsage func(resourceName, podNamespace, podName string) float64 NodeResourceCumulativeUsage func(resourceName, nodeName string) float64 }
EnvironmentConfig holds configuration for a cel program
type Evaluator ¶ added in v0.6.0
type Evaluator struct {
// contains filtered or unexported fields
}
Evaluator evaluates a cel program
func (*Evaluator) EvaluateFloat64 ¶ added in v0.6.0
EvaluateFloat64 evaluates a cel program and returns a float64.
type Gauge ¶ added in v0.4.0
type Gauge = prometheus.Gauge
Gauge is a prometheus gauge that can be incremented and decremented.
type GaugeOpts ¶ added in v0.4.0
type GaugeOpts = prometheus.GaugeOpts
GaugeOpts is a prometheus gauge options.
type Histogram ¶
type Histogram interface { prometheus.Metric prometheus.Collector Set(le float64, val uint64) }
Histogram is a metric to track distributions of events.
func NewHistogram ¶
func NewHistogram(opts HistogramOpts) Histogram
NewHistogram creates new Histogram based on Histogram options
type HistogramOpts ¶
type HistogramOpts struct { // Namespace, Subsystem, and Name are components of the fully-qualified // name of the Histogram (created by joining these components with // "_"). Only Name is mandatory, the others merely help structuring the // name. Note that the fully-qualified name of the Histogram must be a // valid Prometheus metric name. Namespace string Subsystem string Name string // Help provides information about this Histogram. // // Metrics with the same fully-qualified name must have the same Help // string. Help string // ConstLabels are used to attach fixed labels to this metric. Metrics // with the same fully-qualified name must have the same label names in // their ConstLabels. // // ConstLabels are only used rarely. In particular, do not use them to // attach the same labels to all your metrics. Those use cases are // better covered by target labels set by the scraping Prometheus // server, or by one specific metric (e.g. a build_info or a // machine_role metric). See also // https://prometheus.io/docs/instrumenting/writing_exporters/#target-labels-not-static-scraped-labels ConstLabels prometheus.Labels Buckets []float64 }
HistogramOpts provides configuration options for Histogram.
type UpdateHandler ¶
type UpdateHandler struct {
// contains filtered or unexported fields
}
UpdateHandler handles updating metrics on request
func NewMetricsUpdateHandler ¶
func NewMetricsUpdateHandler(conf UpdateHandlerConfig) *UpdateHandler
NewMetricsUpdateHandler creates new metric update handler based on the config
func (*UpdateHandler) ServeHTTP ¶
func (h *UpdateHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*UpdateHandler) Update ¶ added in v0.4.0
func (h *UpdateHandler) Update(ctx context.Context, nodeName string, metrics []internalversion.MetricConfig)
Update updates metrics for a node
type UpdateHandlerConfig ¶
type UpdateHandlerConfig struct { DataSource DataSource Environment *Environment NodeCacheGetter informer.Getter[*corev1.Node] PodCacheGetter informer.Getter[*corev1.Pod] }
UpdateHandlerConfig is configuration for a single node