base

package
v0.0.0-...-86d5f22 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package base xxx

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DivideSamples

func DivideSamples(samples1, samples2 []prompb.Sample) []prompb.Sample

DivideSamples samples1 divide samples2

func DivideSeries

func DivideSeries(series1, series2 []*prompb.TimeSeries) []*prompb.TimeSeries

DivideSeries divide same metrics series, series1 divide series2, series must only have one element

func DivideSeriesByValue

func DivideSeriesByValue(series []*prompb.TimeSeries, values float64) []*prompb.TimeSeries

DivideSeriesByValue divide same metrics series

func GetNodeCRVersionByName

func GetNodeCRVersionByName(ctx context.Context, clusterId, nodeName string) (string, error)

GetNodeCRVersionByName 通过节点名称获取容器运行时版本

func GetNodeCRVersionByNameIngErr

func GetNodeCRVersionByNameIngErr(ctx context.Context, clusterID, nodeName string) (string, bool)

GetNodeCRVersionByNameIngErr 通过节点名称获取容器运行时版本

func GetNodeInfoIngoreErr

func GetNodeInfoIngoreErr(ctx context.Context, clusterID, nodeName string) (*v1.Node, bool)

GetNodeInfoIngoreErr 获取节点信息 返回相应的节点对象

func GetNodeMatch

func GetNodeMatch(ctx context.Context, clusterId string) (string, string, error)

GetNodeMatch 按集群node节点正则匹配

func GetNodeMatchByName

func GetNodeMatchByName(ctx context.Context, clusterId, nodeName string) (string, string, error)

GetNodeMatchByName 按集群node节点正则匹配

func GetNodeMatchByNameIngErr

func GetNodeMatchByNameIngErr(ctx context.Context, clusterID, nodeName string) (string, string, bool)

GetNodeMatchByNameIngErr 按集群node节点正则匹配

func GetNodeMatchIgnoreErr

func GetNodeMatchIgnoreErr(ctx context.Context, clusterID string) (string, string, bool)

GetNodeMatchIgnoreErr 按集群node节点正则匹配

func GetSameSeries

func GetSameSeries(start, end time.Time, step time.Duration, values float64,
	labels []prompb.Label) []*prompb.TimeSeries

GetSameSeries divide same metrics series, series1 divide series2, series must only have one element

func MatrixToSeries

func MatrixToSeries(matrix model.Matrix) []*prompb.TimeSeries

MatrixToSeries prom返回转换为时序对象

func MatrixsToSeries

func MatrixsToSeries(matrixs []model.Matrix) []*prompb.TimeSeries

MatrixsToSeries prom返回转换为时序对象

func MergeSameSamples

func MergeSameSamples(samples1, samples2 []prompb.Sample) []prompb.Sample

MergeSameSamples merge same samples

func MergeSameSeries

func MergeSameSeries(series []*prompb.TimeSeries) []*prompb.TimeSeries

MergeSameSeries merge same metrics series

Types

type MetricHandler

type MetricHandler interface {
	GetClusterCPUTotal(ctx context.Context, projectId, clusterId string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetClusterCPUUsed(ctx context.Context, projectId, clusterId string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetClusterPodUsage(ctx context.Context, projectId, clusterId string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetClusterPodUsed(ctx context.Context, projectId, clusterId string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetClusterPodTotal(ctx context.Context, projectId, clusterId string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetClusterCPURequest(ctx context.Context, projectId, clusterId string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetClusterCPUUsage(ctx context.Context, projectId, clusterId string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetClusterCPURequestUsage(ctx context.Context, projectId, clusterId string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetClusterMemoryTotal(ctx context.Context, projectId, clusterId string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetClusterMemoryUsed(ctx context.Context, projectId, clusterId string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetClusterMemoryRequest(ctx context.Context, projectId, clusterId string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetClusterMemoryUsage(ctx context.Context, projectId, clusterId string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetClusterMemoryRequestUsage(ctx context.Context, projectId, clusterId string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetClusterDiskTotal(ctx context.Context, projectId, clusterId string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetClusterDiskUsed(ctx context.Context, projectId, clusterId string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetClusterDiskUsage(ctx context.Context, projectId, clusterId string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetClusterDiskioUsage(ctx context.Context, projectId, clusterId string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetClusterDiskioUsed(ctx context.Context, projectId, clusterId string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetClusterDiskioTotal(ctx context.Context, projectId, clusterId string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetClusterGroupNodeNum(ctx context.Context, projectId, clusterId, group string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetClusterGroupMaxNodeNum(ctx context.Context, projectId, clusterId, group string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetNodeInfo(ctx context.Context, projectId, clusterId, nodeName string, t time.Time) (*NodeInfo, error)
	GetNodeCPUTotal(ctx context.Context, projectId, clusterId, nodeName string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetNodeCPURequest(ctx context.Context, projectId, clusterId, nodeName string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetNodeCPUUsed(ctx context.Context, projectId, clusterId, nodeName string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetNodeCPUUsage(ctx context.Context, projectId, clusterId, nodeName string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetNodeCPURequestUsage(ctx context.Context, projectId, clusterId, nodeName string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetNodeMemoryTotal(ctx context.Context, projectId, clusterId, nodeName string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetNodeMemoryRequest(ctx context.Context, projectId, clusterId, nodeName string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetNodeMemoryUsed(ctx context.Context, projectId, clusterId, nodeName string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetNodeMemoryUsage(ctx context.Context, projectId, clusterId, nodeName string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetNodeMemoryRequestUsage(ctx context.Context, projectId, clusterId, nodeName string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetNodeDiskUsed(ctx context.Context, projectId, clusterId, nodeName string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetNodeDiskTotal(ctx context.Context, projectId, clusterId, nodeName string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetNodeDiskUsage(ctx context.Context, projectId, clusterId, nodeName string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetNodeDiskioUsage(ctx context.Context, projectId, clusterId, nodeName string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetNodeNetworkTransmit(ctx context.Context, projectId, clusterId, nodeName string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetNodeNetworkReceive(ctx context.Context, projectId, clusterId, nodeName string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetNodePodCount(ctx context.Context, projectId, clusterId, nodeName string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetNodePodTotal(ctx context.Context, projectId, clusterId, nodeName string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetNodeContainerCount(ctx context.Context, projectId, clusterId, nodeName string, start, end time.Time,
		step time.Duration) ([]*prompb.TimeSeries, error)
	GetPodCPUUsage(ctx context.Context, projectId, clusterId, namespace string, podNameList []string, start,
		end time.Time, step time.Duration) ([]*prompb.TimeSeries, error)
	GetPodCPULimitUsage(ctx context.Context, projectId, clusterId, namespace string, podNameList []string, start,
		end time.Time, step time.Duration) ([]*prompb.TimeSeries, error)
	GetPodCPURequestUsage(ctx context.Context, projectId, clusterId, namespace string, podNameList []string, start,
		end time.Time, step time.Duration) ([]*prompb.TimeSeries, error)
	GetPodMemoryUsed(ctx context.Context, projectId, clusterId, namespace string, podNameList []string, start,
		end time.Time, step time.Duration) ([]*prompb.TimeSeries, error)
	GetPodNetworkReceive(ctx context.Context, projectId, clusterId, namespace string, podNameList []string, start,
		end time.Time, step time.Duration) ([]*prompb.TimeSeries, error)
	GetPodNetworkTransmit(ctx context.Context, projectId, clusterId, namespace string, podNameList []string, start,
		end time.Time, step time.Duration) ([]*prompb.TimeSeries, error)
	GetContainerCPUUsage(ctx context.Context, projectId, clusterId, namespace, podname string, containerNameList []string,
		start, end time.Time, step time.Duration) ([]*prompb.TimeSeries, error)
	GetContainerMemoryUsed(ctx context.Context, projectId, clusterId, namespace, podname string,
		containerNameList []string, start, end time.Time, step time.Duration) ([]*prompb.TimeSeries, error)
	GetContainerCPULimit(ctx context.Context, projectId, clusterId, namespace, podname string, containerNameList []string,
		start, end time.Time, step time.Duration) ([]*prompb.TimeSeries, error)
	GetContainerMemoryLimit(ctx context.Context, projectId, clusterId, namespace, podname string,
		containerNameList []string, start, end time.Time, step time.Duration) ([]*prompb.TimeSeries, error)
	GetContainerGPUMemoryUsage(ctx context.Context, projectId, clusterId, namespace, podname string,
		containerNameList []string, start, end time.Time, step time.Duration) ([]*prompb.TimeSeries, error)
	GetContainerGPUUsed(ctx context.Context, projectId, clusterId, namespace, podname string,
		containerNameList []string, start, end time.Time, step time.Duration) ([]*prompb.TimeSeries, error)
	GetContainerGPUUsage(ctx context.Context, projectId, clusterId, namespace, podname string,
		containerNameList []string, start, end time.Time, step time.Duration) ([]*prompb.TimeSeries, error)
	GetContainerDiskReadTotal(ctx context.Context, projectId, clusterId, namespace, podname string,
		containerNameList []string, start, end time.Time, step time.Duration) ([]*prompb.TimeSeries, error)
	GetContainerDiskWriteTotal(ctx context.Context, projectId, clusterId, namespace, podname string,
		containerNameList []string, start, end time.Time, step time.Duration) ([]*prompb.TimeSeries, error)
}

MetricHandler xxx

type NodeInfo

type NodeInfo struct {
	CPUCount                string `json:"cpu_count"`                 // CPU
	Memory                  string `json:"memory"`                    // 内存, 单位 Byte
	Disk                    string `json:"disk"`                      // 存储, 单位 Byte
	Provider                string `json:"provider"`                  // IP来源, BKMonitor / Prometheus
	Release                 string `json:"release"`                   // 内核, 3.10.107-1-tlinux2_kvm_guest-0052
	DockerVersion           string `json:"dockerVersion"`             // Docker, 18.6.3-ce-tke.1
	Sysname                 string `json:"sysname"`                   // 操作系统, linux
	IP                      string `json:"ip"`                        // ip,多个使用 , 分隔
	ContainerRuntimeVersion string `json:"container_runtime_version"` // 容器运行时版本
}

NodeInfo 节点信息

func (*NodeInfo) PromSeries

func (n *NodeInfo) PromSeries(t time.Time) []*prompb.TimeSeries

PromSeries 给 series

type ResultTuple

type ResultTuple struct {
	NodeMatch     string
	NodeNameMatch string
	Err           error
}

ResultTuple result tuple

func GetNodeMatchWithScale

func GetNodeMatchWithScale(ctx context.Context, clusterId string, scale int) ([]*ResultTuple, error)

GetNodeMatchWithScale 处理集群的节点列表,按照给定的粒度划分

func GetNodeMatchWithScaleIngErr

func GetNodeMatchWithScaleIngErr(ctx context.Context, clusterID string, scale int) ([]*ResultTuple, bool)

GetNodeMatchWithScaleIngErr 处理集群的节点列表,按照给定的粒度划分

Jump to

Keyboard shortcuts

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