metrics

package
v0.0.0-...-2dbac4b Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CPUUtilizationDataPointsQuery = "cpuUtilizationDataPointsQuery"
	BreachDataPointsQuery         = "breachDataPointsQuery"
)

Variables

This section is empty.

Functions

func ValidateQuery

func ValidateQuery(query string) bool

Types

type CPUUtilizationBreachQuery

type CPUUtilizationBreachQuery CompositeQuery

func (*CPUUtilizationBreachQuery) Render

func (qb *CPUUtilizationBreachQuery) Render(redLineUtilization float64, labels map[string]string) string

type CPUUtilizationQuery

type CPUUtilizationQuery CompositeQuery

func (*CPUUtilizationQuery) Render

func (qb *CPUUtilizationQuery) Render(labels map[string]string) string

type CompositeQuery

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

func NewPrometheusCompositeQueries

func NewPrometheusCompositeQueries() *CompositeQuery

type CompositeQueryBuilder

type CompositeQueryBuilder CompositeQuery

func NewCompositeQueryBuilder

func NewCompositeQueryBuilder() *CompositeQueryBuilder

func (*CompositeQueryBuilder) Build

func (*CompositeQueryBuilder) WithQuery

type DataPoint

type DataPoint struct {
	Timestamp time.Time
	Value     float64
}

type MetricsTransformer

type MetricsTransformer interface {
	Transform(
		startTime time.Time, endTime time.Time, dataPoints []DataPoint) ([]DataPoint, error)
}

type PodReadyLatencyQuery

type PodReadyLatencyQuery CompositeQuery

func (*PodReadyLatencyQuery) Render

func (qb *PodReadyLatencyQuery) Render(labels map[string]string) string

type PrometheusInstance

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

type PrometheusQueryResult

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

type PrometheusScraper

type PrometheusScraper struct {
	CPUUtilizationQuery       *CPUUtilizationQuery
	CPUUtilizationBreachQuery *CPUUtilizationBreachQuery
	PodReadyLatencyQuery      *PodReadyLatencyQuery
	// contains filtered or unexported fields
}

PrometheusScraper is a Scraper implementation that scrapes metrics data from Prometheus.

func NewPrometheusScraper

func NewPrometheusScraper(apiUrls []string,
	timeout time.Duration,
	splitInterval time.Duration,
	metricIngestionTime float64,
	metricProbeTime float64,
	logger logr.Logger) (*PrometheusScraper, error)

func (*PrometheusScraper) GetACLByWorkload

func (ps *PrometheusScraper) GetACLByWorkload(namespace string, workload string) (time.Duration, error)

func (*PrometheusScraper) GetAverageCPUUtilizationByWorkload

func (ps *PrometheusScraper) GetAverageCPUUtilizationByWorkload(namespace string,
	workload string,
	start time.Time,
	end time.Time,
	step time.Duration) ([]DataPoint, error)

GetAverageCPUUtilizationByWorkload returns the average CPU utilization for the given workload type and name in the specified namespace, in the given time range.

func (*PrometheusScraper) GetCPUUtilizationBreachDataPoints

func (ps *PrometheusScraper) GetCPUUtilizationBreachDataPoints(namespace,
	workloadType,
	workload string,
	redLineUtilization float64,
	start time.Time,
	end time.Time,
	step time.Duration) ([]DataPoint, error)

GetCPUUtilizationBreachDataPoints returns the data points where avg CPU utilization for a workload goes above the redLineUtilization while no of ready pods for the workload were < maxReplicas defined in the HPA.

type QueryComponent

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

func (*QueryComponent) Render

func (qc *QueryComponent) Render(m map[string]string) string

type QueryComponentBuilder

type QueryComponentBuilder QueryComponent

func NewQueryComponentBuilder

func NewQueryComponentBuilder() *QueryComponentBuilder

func (*QueryComponentBuilder) Build

func (*QueryComponentBuilder) WithLabelKeys

func (qb *QueryComponentBuilder) WithLabelKeys(labelKeys []string) *QueryComponentBuilder

func (*QueryComponentBuilder) WithMetric

func (qb *QueryComponentBuilder) WithMetric(metric string) *QueryComponentBuilder

type RangeQuerySplitter

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

RangeQuerySplitter splits a given queryRange into multiple range queries of width splitInterval. This is done to avoid loading too many samples into P8s memory.

func NewRangeQuerySplitter

func NewRangeQuerySplitter(splitInterval time.Duration) *RangeQuerySplitter

func (*RangeQuerySplitter) QueryRangeByInterval

func (rqs *RangeQuerySplitter) QueryRangeByInterval(ctx context.Context,
	pi PrometheusInstance,
	query string,
	start, end time.Time,
	step time.Duration) (model.Value, error)

type Scraper

type Scraper interface {
	GetAverageCPUUtilizationByWorkload(namespace,
		workload string,
		start time.Time,
		end time.Time,
		step time.Duration) ([]DataPoint, error)

	GetCPUUtilizationBreachDataPoints(namespace,
		workloadType,
		workload string,
		redLineUtilization float64,
		start time.Time,
		end time.Time,
		step time.Duration) ([]DataPoint, error)

	GetACLByWorkload(namespace,
		workload string) (time.Duration, error)
}

Scraper is an interface for scraping metrics data.

Jump to

Keyboard shortcuts

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