calculate

package
v1.1.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TikvSumCpuMetricsPattern     = `sum(increase(tikv_thread_cpu_seconds_total{cluster="%s"}[%s])) by (instance)`
	TidbSumCpuMetricsPattern     = `sum(increase(process_cpu_seconds_total{cluster="%s",job="tidb"}[%s])) by (instance)`
	InvalidTacMetricConfigureMsg = "tac[%s/%s] metric configuration invalid"
)
View Source
const (
	CpuSumMetricsErrorMsg = "" /* 142-byte string literal not displayed */
)

Variables

This section is empty.

Functions

func CalculateRecomendedReplicasByCpuCosts

func CalculateRecomendedReplicasByCpuCosts(tac *v1alpha1.TidbClusterAutoScaler, sq *SingleQuery, sts *appsv1.StatefulSet,
	client promClient.Client, memberType v1alpha1.MemberType, duration time.Duration) (int32, error)

TODO: create issue to explain how auto-scaling algorithm based on cpu metrics work

func FilterMetrics

currently, we only choose one metrics to be computed. If there exists several metrics, we tend to choose ResourceMetricSourceType metric

Types

type Data

type Data struct {
	ResultType string   `json:"resultType"`
	Result     []Result `json:"result"`
}

type Metric

type Metric struct {
	Cluster             string `json:"cluster,omitempty"`
	Instance            string `json:"instance"`
	Job                 string `json:"job,omitempty"`
	KubernetesNamespace string `json:"kubernetes_namespace,omitempty"`
	KubernetesNode      string `json:"kubernetes_node,omitempty"`
	KubernetesPodIp     string `json:"kubernetes_pod_ip,omitempty"`
}

type MetricType

type MetricType string

MetricType describe the current Supported Metric Type to calculate the recommended Replicas

const (
	MetricTypeCPU MetricType = "cpu"
)

func GenMetricType

genMetricType return the supported MetricType in Operator by kubernetes auto-scaling MetricType

type Response

type Response struct {
	Status string `json:"status"`
	Data   Data   `json:"data"`
}

Response is used to marshal the data queried from Prometheus

type Result

type Result struct {
	Metric Metric        `json:"metric"`
	Value  []interface{} `json:"value"`
}

type SingleQuery

type SingleQuery struct {
	Endpoint  string
	Timestamp int64
	Quary     string
	Instances []string
	Metric    autoscalingv2beta2.MetricSpec
}

Jump to

Keyboard shortcuts

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