Documentation ¶
Overview ¶
Package clientutil xxx
Index ¶
- Constants
- func ChunkSamples(series *prompb.TimeSeries) (chks []storepb.AggrChunk, err error)
- func CleanStrList(strList []string) []string
- func CopyMap(m map[string]string) map[string]string
- func DumpPromQL(req *storepb.SeriesRequest) string
- func EncodeChunk(ss []prompb.Sample) (storepb.Chunk_Encoding, []byte, error)
- func ExtendLabelSetByNames(externalLabels labels.Labels, metricNames []string) []storepb.LabelSet
- func GetClusterList(series []*prompb.TimeSeries) []string
- func GetCluterID(series *prompb.TimeSeries) string
- func GetEQMatcherMap(matchers []storepb.LabelMatcher) map[string]string
- func GetLabelMatch(name string, matchers []storepb.LabelMatcher) *storepb.LabelMatcher
- func GetLabelMatchFromSeries(name string, matchers []prompb.Label) *prompb.Label
- func GetLabelMatchValue(name string, matchers []storepb.LabelMatcher) (string, error)
- func GetLabelMatchValueFromSeries(name string, matchers []prompb.Label) string
- func GetLabelMatchValues(name string, matchers []storepb.LabelMatcher) ([]string, error)
- func LabelMatcherToString(matchers []storepb.LabelMatcher) string
- func LabelsToSignature(labels map[string]string) string
- func MatchLabels(matchers []*labels.Matcher, lb labels.Labels, metricNames []string) bool
- func MergeTimeSeriesMap(seriesMap map[uint64]*prompb.TimeSeries, ...)
- func QueryResultToHashMap(result *prompb.QueryResult) map[uint64]*prompb.TimeSeries
- func SampleStreamToSeries(values model.Matrix, ignoreLabels map[string]string, ...) []*prompb.TimeSeries
- func TimeSeriesToHash(series *prompb.TimeSeries) uint64
- func ValidateSeries(s *prompb.TimeSeries, minTime int64, maxTime int64) bool
- type DispatchConf
- type MonitorSourceType
- type PromQueryTime
- type TimeSeries
Constants ¶
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 DumpPromQL ¶
func DumpPromQL(req *storepb.SeriesRequest) string
DumpPromQL 组装matcherpromql,打印日志用
func EncodeChunk ¶
EncodeChunk :
func ExtendLabelSetByNames ¶
ExtendLabelSetByNames 通过 metrics 名称生成 store 的 labelsSet,
func GetClusterList ¶
func GetClusterList(series []*prompb.TimeSeries) []string
GetClusterList : 获取去除后的集群 ID 列表
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 ¶
GetLabelMatchFromSeries :
func GetLabelMatchValue ¶
func GetLabelMatchValue(name string, matchers []storepb.LabelMatcher) (string, error)
GetLabelMatchValue :
func GetLabelMatchValueFromSeries ¶
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 ¶
LabelsToSignature 签名, 拼接为 a=b&c=d 的格式
func MatchLabels ¶
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 ¶
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 转换为