calculate

package
v0.0.0-...-9e299b5 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TikvSumStorageMetricsPattern         = `` /* 153-byte string literal not displayed */
	TikvSumStorageMetricsPressurePattern = `` /* 170-byte string literal not displayed */
	TidbSumCpuMetricsPattern             = `` /* 191-byte string literal not displayed */
	TidbSumTpsMetricsPattern             = `` /* 203-byte string literal not displayed */

)
View Source
const (
	CpuSumMetricsErrorMsg  = "" /* 139-byte string literal not displayed */
	TpmcSumMetricsErrorMsg = "" /* 139-byte string literal not displayed */
)
View Source
const (
	TpmcType = 0
	CpuType  = 1
)

Variables

View Source
var AverageUtilization = os.Getenv("CPU_AVERAGE_UTILIZATION")
View Source
var Tpc = os.Getenv("TPMC_PER_CPU")

Functions

func CalculateRecomendedReplicasByCpuCosts

func CalculateRecomendedReplicasByCpuCosts(sldb *sldbv1.ServerlessDB, sq *SingleQuery,
	client promClient.Client, memberType v1alpha1.MemberType, duration time.Duration, isCpuOrTpmc int) (float64, error)

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

func CalculateStoragePressureBaseTc

func CalculateStoragePressureBaseTc(sldb *sldbv1.ServerlessDB, tc *v1alpha1.TidbCluster) (bool, error)

func CalculateStorageSize

func CalculateStorageSize(sldb *sldbv1.ServerlessDB, usedSq *SingleQuery,
	client promClient.Client) (uint64, error)

func CalculateWhetherStoragePressure

func CalculateWhetherStoragePressure(sldb *sldbv1.ServerlessDB, capacitySq, availableSq *SingleQuery,
	client promClient.Client) (bool, error)

func GetUtilizationRatio

func GetUtilizationRatio() (float64, error)

Types

type Data

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

type Metric

type Metric struct {
	Cluster             string `json:"app_kubernetes_io_instance,omitempty"`
	Instance            string `json:"statefulset_kubernetes_io_pod_name,omitempty"`
	Job                 string `json:"job,omitempty"`
	KubernetesNamespace string `json:"kubernetes_namespace,omitempty"`
}

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
	Query     string
	Instances []string
}

Jump to

Keyboard shortcuts

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