clientutil

package
v0.0.0-...-faa1211 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package clientutil xxx

Index

Constants

View Source
const (
	// MinStepSeconds 最小步长, 单位秒
	MinStepSeconds = 60
	// SeriesStepDeltaSeconds 查询 Series 的回溯步长, 单位秒
	SeriesStepDeltaSeconds = 60 * 5
)

Variables

This section is empty.

Functions

func ChunkSamples

func ChunkSamples(series *prompb.TimeSeries) (chks []storepb.AggrChunk, err error)

ChunkSamples 按120个点,分割为chunk

func CleanStrList

func CleanStrList(strList []string) []string

CleanStrList 去掉空字符串, 去掉字符串2边的空格

func CopyMap

func CopyMap(m map[string]string) map[string]string

CopyMap 复制 map 对象

func DumpPromQL

func DumpPromQL(req *storepb.SeriesRequest) string

DumpPromQL 组装matcherpromql,打印日志用

func EncodeChunk

func EncodeChunk(ss []prompb.Sample) (storepb.Chunk_Encoding, []byte, error)

EncodeChunk :

func ExtendLabelSetByNames

func ExtendLabelSetByNames(externalLabels labels.Labels, metricNames []string) []storepb.LabelSet

ExtendLabelSetByNames 通过 metrics 名称生成 store 的 labelsSet,

func GetClusterList

func GetClusterList(series []*prompb.TimeSeries) []string

GetClusterList : 获取去除后的集群 ID 列表

func GetCluterID

func GetCluterID(series *prompb.TimeSeries) string

GetCluterID : 获取集群id value

func GetEQMatcherMap

func GetEQMatcherMap(matchers []storepb.LabelMatcher) map[string]string

GetEQMatcherMap 获取 = 匹配关系

func GetLabelMatch

func GetLabelMatch(name string, matchers []storepb.LabelMatcher) *storepb.LabelMatcher

GetLabelMatch :

func GetLabelMatchFromSeries

func GetLabelMatchFromSeries(name string, matchers []prompb.Label) *prompb.Label

GetLabelMatchFromSeries :

func GetLabelMatchValue

func GetLabelMatchValue(name string, matchers []storepb.LabelMatcher) (string, error)

GetLabelMatchValue :

func GetLabelMatchValueFromSeries

func GetLabelMatchValueFromSeries(name string, matchers []prompb.Label) string

GetLabelMatchValueFromSeries :

func GetLabelMatchValues

func GetLabelMatchValues(name string, matchers []storepb.LabelMatcher) ([]string, error)

GetLabelMatchValues :

func LabelMatcherToString

func LabelMatcherToString(matchers []storepb.LabelMatcher) string

LabelMatcherToString LabelMatcher 组装字符串

func LabelsToSignature

func LabelsToSignature(labels map[string]string) string

LabelsToSignature 签名, 拼接为 a=b&c=d 的格式

func MatchLabels

func MatchLabels(matchers []*labels.Matcher, lb labels.Labels, metricNames []string) bool

MatchLabels label 匹配

func MergeTimeSeriesMap

func MergeTimeSeriesMap(seriesMap map[uint64]*prompb.TimeSeries, toBeMerged map[uint64]*prompb.TimeSeries)

MergeTimeSeriesMap 合并2个时间序列 seriesMap 会被修改的变量

func QueryResultToHashMap

func QueryResultToHashMap(result *prompb.QueryResult) map[uint64]*prompb.TimeSeries

QueryResultToHashMap Result 转换为 hashMap

func SampleStreamToSeries

func SampleStreamToSeries(values model.Matrix, ignoreLabels map[string]string,
	appendLabels map[string]string) []*prompb.TimeSeries

SampleStreamToSeries :

func TimeSeriesToHash

func TimeSeriesToHash(series *prompb.TimeSeries) uint64

TimeSeriesToHash 计算hash签名

func ValidateSeries

func ValidateSeries(s *prompb.TimeSeries, minTime int64, maxTime int64) bool

ValidateSeries series是否合法

Types

type DispatchConf

type DispatchConf struct {
	ClusterID     string            `yaml:"cluster_id"`
	URL           string            `yaml:"url"`
	MetricsPrefix string            `yaml:"metrics_prefix"` // 某些集群 metrics 有特定的前缀
	SourceType    MonitorSourceType `yaml:"source_type"`
}

DispatchConf xxx

type MonitorSourceType

type MonitorSourceType string

MonitorSourceType monitor source type

const (
	// MonitorSourceCompute 算力 metrics
	MonitorSourceCompute MonitorSourceType = "compute"
	// MonitorSourceComputeV2 算力 metrics v2,数据来源于 bk-monitor
	MonitorSourceComputeV2 MonitorSourceType = "compute_v2"
	// MonitorSourceFederation 联邦集群 metrics
	MonitorSourceFederation MonitorSourceType = "federation"
)

type PromQueryTime

type PromQueryTime struct {
	Start time.Time
	End   time.Time
	Step  time.Duration
}

PromQueryTime promql range 时间参数

func GetPromQueryTime

func GetPromQueryTime(r *storepb.SeriesRequest) *PromQueryTime

GetPromQueryTime 获取查询时间

type TimeSeries

type TimeSeries struct {
	*prompb.TimeSeries
}

TimeSeries 时间序列封装

func (*TimeSeries) AddLabel

func (s *TimeSeries) AddLabel(name, value string) *TimeSeries

AddLabel :

func (*TimeSeries) AddLabels

func (s *TimeSeries) AddLabels(promLabels []prompb.Label) *TimeSeries

AddLabels 添加 Labels

func (*TimeSeries) RenameLabel

func (s *TimeSeries) RenameLabel(oldname, newName string) *TimeSeries

RenameLabel 重命名一个label, 如果有重复label,以后面一个为准

func (*TimeSeries) ToThanosSeries

func (s *TimeSeries) ToThanosSeries(skipChunks bool) (*storepb.Series, error)

ToThanosSeries 转换为

Jump to

Keyboard shortcuts

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