metricquery

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: Apache-2.0, BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NotMatchWorkloadError  = fmt.Errorf("metric type %v, but no WorkloadNamerInfo provided", WorkloadMetricType)
	NotMatchContainerError = fmt.Errorf("metric type %v, but no ContainerNamerInfo provided", ContainerMetricType)
	NotMatchPodError       = fmt.Errorf("metric type %v, but no PodNamerInfo provided", PodMetricType)
	NotMatchNodeError      = fmt.Errorf("metric type %v, but no NodeNamerInfo provided", NodeMetricType)
	NotMatchPromError      = fmt.Errorf("metric type %v, but no PromNamerInfo provided", PromQLMetricType)
)

Functions

This section is empty.

Types

type ContainerNamerInfo

type ContainerNamerInfo struct {
	Namespace    string
	WorkloadName string
	WorkloadKind string
	APIVersion   string
	Name         string
	// used to fetch workload pods and containers, when use metric server, it is required
	Selector labels.Selector
}

type GenericQuery added in v0.6.0

type GenericQuery struct {
	Metric *Metric
}

type Metric

type Metric struct {
	Type MetricType
	// such as cpu/memory, or http_requests
	MetricName string
	// Workload only support for MetricName cpu/memory
	Workload *WorkloadNamerInfo
	// Container only support for MetricName cpu/memory
	Container *ContainerNamerInfo
	// Pod only support for MetricName cpu/memory
	Pod *PodNamerInfo
	// Node only support for MetricName cpu/memory
	Node *NodeNamerInfo
	// Prom can support any MetricName, user give the promQL
	Prom *PromNamerInfo
}

func (*Metric) BuildUniqueKey

func (m *Metric) BuildUniqueKey() string

func (*Metric) ValidateMetric

func (m *Metric) ValidateMetric() error

type MetricSource

type MetricSource string
const (
	PrometheusMetricSource   MetricSource = "prom"
	MetricServerMetricSource MetricSource = "metricserver"
	GrpcMetricSource         MetricSource = "grpc"
)

type MetricType

type MetricType string
const (
	WorkloadMetricType  MetricType = "workload"
	PodMetricType       MetricType = "pod"
	ContainerMetricType MetricType = "container"
	NodeMetricType      MetricType = "node"
	PromQLMetricType    MetricType = "promql"
)

type NodeNamerInfo

type NodeNamerInfo struct {
	Name     string
	Selector labels.Selector
}

type PodNamerInfo

type PodNamerInfo struct {
	Namespace string
	Name      string
	Selector  labels.Selector
}

type PromNamerInfo

type PromNamerInfo struct {
	QueryExpr string
	Namespace string
	Selector  labels.Selector
}

type PrometheusQuery

type PrometheusQuery struct {
	Query string
}

PrometheusQuery is used to do query for prometheus

type Query

type Query struct {
	Type         MetricSource
	GenericQuery *GenericQuery
	Prometheus   *PrometheusQuery
}

Query is used to do query for different data source. you can extends it with your data source query

type WorkloadNamerInfo

type WorkloadNamerInfo struct {
	Namespace  string
	Kind       string
	Name       string
	APIVersion string
	// used to fetch workload pods and containers, when use metric server, it is required
	Selector labels.Selector
}

Jump to

Keyboard shortcuts

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