httpmetrics

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConnectTimeout = 15 * time.Second
View Source
var DefaultRequestTimeout = 15 * time.Second

Functions

func Average

func Average(values ...float64) float64

Average implements the average mathematical function over a slice of float64

func CustomMetricsHTTPClient added in v0.1.4

func CustomMetricsHTTPClient(requestTimeout time.Duration, connectTimeout time.Duration) *http.Client

func DefaultMetricsHTTPClient

func DefaultMetricsHTTPClient() *http.Client

func Maximum

func Maximum(values ...float64) float64

Maximum implements the absolute maximum mathematical function over a slice of float64

func Minimum

func Minimum(values ...float64) float64

Minimum implements the absolute minimum mathematical function over a slice of float64

func Sum

func Sum(values ...float64) float64

Sum implements the summation mathematical function over a slice of float64

Types

type AggregatorFunc

type AggregatorFunc func(...float64) float64

func ParseAggregator

func ParseAggregator(aggregator string) (AggregatorFunc, error)

reduce will reduce a slice of numbers given a aggregator function's name. If it's empty or not recognized, an error is returned.

type JSONPathMetricsGetter

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

JSONPathMetricsGetter is a metrics getter which looks up pod metrics by querying the pods metrics endpoint and lookup the metric value as defined by the json path query.

func NewJSONPathMetricsGetter

func NewJSONPathMetricsGetter(httpClient *http.Client, aggregatorFunc AggregatorFunc, jsonPath string) (*JSONPathMetricsGetter, error)

NewJSONPathMetricsGetter initializes a new JSONPathMetricsGetter.

func (*JSONPathMetricsGetter) GetMetric

func (g *JSONPathMetricsGetter) GetMetric(metricsURL url.URL) (float64, error)

GetMetric gets metric from pod by fetching json metrics from the pods metric endpoint and extracting the desired value using the specified json path query.

type PodMetricsGetter

type PodMetricsGetter interface {
	GetMetric(pod *v1.Pod) (float64, error)
}

type PodMetricsJSONPathGetter

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

func NewPodMetricsJSONPathGetter

func NewPodMetricsJSONPathGetter(config map[string]string) (*PodMetricsJSONPathGetter, error)

func (PodMetricsJSONPathGetter) GetMetric

func (g PodMetricsJSONPathGetter) GetMetric(pod *v1.Pod) (float64, error)

Jump to

Keyboard shortcuts

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