prometheus

package
v0.0.0-...-69feff2 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TIME_SECOND = int64(time.Second)
	TIME_MINUTE = 60 * TIME_SECOND
	TIME_HOUR   = 60 * TIME_MINUTE
	TIME_DAY    = TIME_HOUR * 24
)
View Source
const (
	TEMPLATE_GET_SERVICES                = `sum by(svc_name) (increase(kindling_span_trace_duration_nanoseconds_count{%s}[%s]))`
	TEMPLATE_GET_ENDPOINTS               = `sum by(content_key) (increase(kindling_span_trace_duration_nanoseconds_count{%s}[%s]))`
	TEMPLATE_GET_SERVICE_INSTANCE        = `` /* 138-byte string literal not displayed */
	TEMPLATE_GET_ACTIVE_SERVICE_INSTANCE = `` /* 129-byte string literal not displayed */
	TEMPLATE_ERROR_RATE_INSTANCE         = "100*(" +
		"(sum by(%s)(increase(kindling_span_trace_duration_nanoseconds_count{%s, is_error='true'}[%s])) or 0)" +
		"/sum by(%s)(increase(kindling_span_trace_duration_nanoseconds_count{%s}[%s]))" +
		") or (sum by(%s)(increase(kindling_span_trace_duration_nanoseconds_count{%s}[%s])) * 0)" // or * 0补充中间缺失数据的场景
	TEMPLATE_GET_NAMESPACES = `sum(kindling_span_trace_duration_nanoseconds_count{namespace=~".+"}[%s]) by (namespace)`
)
View Source
const (
	ContentKeyPQLFilter     = "content_key="
	ServicePQLFilter        = "svc_name="
	NamespacePQLFilter      = "namespace="
	NamespaceRegexPQLFilter = "namespace=~"
	ContainerIdPQLFilter    = "container_id="
	IsErrorPQLFilter        = "is_error="

	ContentKeyRegexPQLFilter = "content_key=~"
	ServiceRegexPQLFilter    = "svc_name=~"
	DBNameRegexPQLFilter     = "name=~"

	ValueExistPQLValueFilter = ".+"
	LabelExistPQLValueFilter = ".*"

	PodRegexPQLFilter           = "pod=~"
	LogMetricPodRegexPQLFilter  = "pod_name=~"
	LogMetricNodeRegexPQLFilter = "host_name=~"
	LogMetricPidRegexPQLFilter  = "pid=~"
	ContainerIdRegexPQLFilter   = "container_id=~"
	PidRegexPQLFilter           = "pid=~"
)
View Source
const (
	// metricGroup
	REALTIME MGroupName = "realtime" // endpoint时刻瞬时值
	AVG      MGroupName = "avg"      // start~endpoint之间的平均值
	DOD      MGroupName = "dod"      // start~endpoint时段和昨日日同比
	WOW      MGroupName = "wow"      // start~endpoint时段和上周周同比

	// metricName
	DEP_LATENCY     MName = "dep_latency"
	LATENCY         MName = "latency"
	ERROR_RATE      MName = "error"
	THROUGHPUT      MName = "throughput"
	LOG_ERROR_COUNT MName = "log_error_count"
)
View Source
const (
	AVG_1MIN_ERROR_BY_SERVICE = `` /* 256-byte string literal not displayed */

	AVG_1MIN_ERROR = `` /* 223-byte string literal not displayed */

	AVG_1MIN_LATENCY_BY_SERVICE = `` /* 268-byte string literal not displayed */

	AVG_1MIN_LATENCY = `` /* 237-byte string literal not displayed */

	AVG_ERROR_BY_PID = `` /* 391-byte string literal not displayed */

	AVG_ERROR_BY_CONTAINERID = `` /* 425-byte string literal not displayed */

	AVG_ERROR_BY_POD = `` /* 423-byte string literal not displayed */

	AVG_ERROR_BY_SERVICE = `` /* 256-byte string literal not displayed */

	AVG_ERROR = `` /* 223-byte string literal not displayed */

	ERROR_DOD_BY_PID = `` /* 862-byte string literal not displayed */

	ERROR_DOD_BY_CONTAINERID = `` /* 906-byte string literal not displayed */

	ERROR_DOD_BY_POD = `` /* 906-byte string literal not displayed */

	ERROR_DOD_BY_SERVICE = `` /* 580-byte string literal not displayed */

	ERROR_DOD = `` /* 517-byte string literal not displayed */

	ERROR_WOW_BY_PID = `` /* 859-byte string literal not displayed */

	ERROR_WOW_BY_CONTAINERID = `` /* 903-byte string literal not displayed */

	ERROR_WOW_BY_POD = `` /* 903-byte string literal not displayed */

	ERROR_WOW_BY_SERVICE = `` /* 577-byte string literal not displayed */

	ERROR_WOW = `` /* 516-byte string literal not displayed */

	AVG_LATENCY_BY_PID = `` /* 364-byte string literal not displayed */

	AVG_LATENCY_BY_CONTAINERID = `` /* 394-byte string literal not displayed */

	AVG_LATENCY_BY_POD = `` /* 390-byte string literal not displayed */

	AVG_LATENCY_BY_SERVICE = `` /* 268-byte string literal not displayed */

	AVG_LATENCY = `` /* 237-byte string literal not displayed */

	LATENCY_DOD_BY_PID = `` /* 762-byte string literal not displayed */

	LATENCY_DOD_BY_CONTAINERID = `` /* 821-byte string literal not displayed */

	LATENCY_DOD_BY_POD = `` /* 818-byte string literal not displayed */

	LATENCY_DOD_BY_SERVICE = `` /* 569-byte string literal not displayed */

	LATENCY_DOD = `` /* 510-byte string literal not displayed */

	LATENCY_WOW_BY_PID = `` /* 758-byte string literal not displayed */

	LATENCY_WOW_BY_CONTAINERID = `` /* 803-byte string literal not displayed */

	LATENCY_WOW_BY_POD = `` /* 754-byte string literal not displayed */

	LATENCY_WOW_BY_SERVICE = `` /* 566-byte string literal not displayed */

	LATENCY_WOW = `` /* 506-byte string literal not displayed */

	AVG_TPS_BY_PID         = `` /* 179-byte string literal not displayed */
	AVG_TPS_BY_CONTAINERID = `` /* 195-byte string literal not displayed */
	AVG_TPS_BY_POD         = `` /* 194-byte string literal not displayed */
	AVG_TPS_BY_SERVICE     = `` /* 132-byte string literal not displayed */
	AVG_TPS                = `(sum by (content_key, svc_name) (increase(kindling_span_trace_duration_nanoseconds_count{content_key=~".*"}[%s])))/%s`
	TPS_DOD_BY_PID         = `` /* 700-byte string literal not displayed */

	TPS_DOD_BY_CONTAINERID = `` /* 743-byte string literal not displayed */

	TPS_DOD_BY_POD = `` /* 759-byte string literal not displayed */

	TPS_DOD_BY_SERVICE = `` /* 537-byte string literal not displayed */

	TPS_DOD = `` /* 494-byte string literal not displayed */

	TPS_WOW_BY_PID = `` /* 698-byte string literal not displayed */

	TPS_WOW_BY_CONTAINERID = `` /* 743-byte string literal not displayed */

	TPS_WOW_BY_POD = `` /* 746-byte string literal not displayed */

	TPS_WOW_BY_SERVICE = `` /* 535-byte string literal not displayed */

	TPS_WOW = `` /* 490-byte string literal not displayed */

	DELAY_SOURCE_BY_SERVICE = `` /* 1052-byte string literal not displayed */

	DELAY_SOURCE = `` /* 959-byte string literal not displayed */

	TPS_DATA = `
    (sum by (content_key, svc_name) (increase(kindling_span_trace_duration_nanoseconds_count{content_key=~"%s"}[%s])))/%s
`
	LATENCY_DATA = `` /* 238-byte string literal not displayed */

	ERROR_DATA = `` /* 259-byte string literal not displayed */

	TPS_DATA_BY_PID = `` /* 185-byte string literal not displayed */

	LATENCY_DATA_BY_PID = `` /* 364-byte string literal not displayed */

	ERROR_DATA_BY_PID = `` /* 350-byte string literal not displayed */

	TPS_DATA_BY_CONTAINERID = `` /* 196-byte string literal not displayed */

	LATENCY_DATA_BY_CONTAINERID = `` /* 386-byte string literal not displayed */

	ERROR_DATA_BY_CONTAINERID = `` /* 363-byte string literal not displayed */

	TPS_DATA_BY_POD = `` /* 183-byte string literal not displayed */

	LATENCY_DATA_BY_POD = `` /* 356-byte string literal not displayed */

	ERROR_DATA_BY_POD = `` /* 595-byte string literal not displayed */

)
View Source
const DefaultDepLatency int64 = -1
View Source
const (
	FillNodeName = `` /* 186-byte string literal not displayed */

)
View Source
const RES_MAX_VALUE float64 = 9999999

RES_MAX_VALUE 返回前端的最大值,同比为该值时表示最大值

View Source
const (
	TEMPLATE_LOG_SUM = `` /* 262-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func AdjustREDValue

func AdjustREDValue(metricGroup MGroupName, metricName MName, value float64) float64

func EscapeRegexp

func EscapeRegexp(s string) string

func PQLAvgDepLatencyWithFilters

func PQLAvgDepLatencyWithFilters(vector string, granularity string, filters []string) string

PQLAvgDepLatencyWithFilters 查询来自外部依赖的平均耗时 返回结果为 外部依赖的平均耗时

func PQLAvgErrorRateWithFilters

func PQLAvgErrorRateWithFilters(vector string, granularity string, filters []string) string

PQLAvgErrorRateWithFilters 查询SQL请求的平均错误率

func PQLAvgLatencyWithFilters

func PQLAvgLatencyWithFilters(vector string, granularity string, filters []string) string

PQLAvgLatencyWithFilters 查询自身平均耗时

func PQLAvgLogErrorCountWithFilters

func PQLAvgLogErrorCountWithFilters(vector string, granularity string, filters []string) string

func PQLAvgSQLErrorRateWithFilters

func PQLAvgSQLErrorRateWithFilters(vector string, granularity string, filters []string) string

PQLAvgSQLErrorRateWithFilters 查询SQL请求的平均错误率

func PQLAvgSQLLatencyWithFilters

func PQLAvgSQLLatencyWithFilters(vector string, granularity string, filters []string) string

func PQLAvgSQLTPSWithFilters

func PQLAvgSQLTPSWithFilters(vector string, granularity string, filters []string) string

PQLAvgTPSWithFilters 查询平均TPS

func PQLAvgTPSWithFilters

func PQLAvgTPSWithFilters(vector string, granularity string, filters []string) string

PQLAvgTPSWithFilters 查询平均TPS

func PQLDepLatencyRadioWithFilters

func PQLDepLatencyRadioWithFilters(vector string, granularity string, filters []string) string

PQLDepLatencyRadioWithFilters 查询来自外部依赖的耗时占比 返回结果为 外部依赖的耗时占总耗时的比例 (0~1)

func PQLInstanceLog

func PQLInstanceLog(pqlTemplate AggPQLWithFilters, startTime int64, endTime int64, granularity Granularity, podFilterKVs, vmFilterKVs []string) (string, error)

PQLInstanceLog 获取instance级别log指标的pql pod or vm

func PQLIsPolarisMetricExitsWithFilters

func PQLIsPolarisMetricExitsWithFilters(vector string, granularity string, filters []string) string

PQLIsPolarisMetricExitsWithFilters 采用北极星指标中的onCPU耗时判断是否存在北极星指标

func PQLMonitorStatus

func PQLMonitorStatus(vector string, granularity string, filters []string) string

PQLMonitorStatus uptime-kuma监控项状态

func PQLNormalLogCountWithFilters

func PQLNormalLogCountWithFilters(vector string, granularity string, filters []string) string

PQLNormalLogCountWithFilters 检查有无正常日志

func QueryContainerIdPromql

func QueryContainerIdPromql(duration string, queryType QueryType, serviceName string, contentKey string) string

func QueryContainerIdRangePromql

func QueryContainerIdRangePromql(duration string, queryType QueryType, contentKey string, serviceName string) string

func QueryEndPointPromql

func QueryEndPointPromql(duration string, queryType QueryType, serviceNames string) string

func QueryEndPointRangePromql

func QueryEndPointRangePromql(step string, duration string, queryType QueryType, contentKeys []string) string

func QueryLogByContainerIdPromql

func QueryLogByContainerIdPromql(duration string, queryType QueryType, containerIds []string) string

func QueryLogByPidPromql

func QueryLogByPidPromql(duration string, queryType QueryType, pids []string) string

func QueryLogPromql

func QueryLogPromql(duration string, queryType QueryType, pods []string) string

func QueryNodeName

func QueryNodeName(serviceName string, contentKey string) string

func QueryPidPromql

func QueryPidPromql(duration string, queryType QueryType, serviceName string, contentKey string) string

func QueryPidRangePromql

func QueryPidRangePromql(duration string, queryType QueryType, contentKey string, serviceName string) string

func QueryPodPromql

func QueryPodPromql(duration string, queryType QueryType, serviceName string, contentKey string) string

func QueryPodRangePromql

func QueryPodRangePromql(duration string, queryType QueryType, contentKey string, serviceName string) string

func RegexContainsValue

func RegexContainsValue(key string) string

RegexContainsValue 创建匹配单个目标值的正则表达式 需要配合 xxxRegexPQLFilter 使用

func RegexMultipleValue

func RegexMultipleValue(key ...string) string

RegexMultipleValue 创建匹配多个目标值的正则表达式 需要配合 xxxRegexPQLFilter 使用

func VecFromDuration

func VecFromDuration(duration time.Duration) (vec string)

func VecFromS2E

func VecFromS2E(startTime int64, endTime int64) (vec string)

VecFromS2E 根据起止时间戳获取时间范围 用于PromQL查询时的内置聚合

e.g. avg (xxx[${vec}])

Types

type AggPQLWithFilters

type AggPQLWithFilters func(vector string, granularity string, filterKVs []string) string

AggPQLWithFilters 生成PQL语句 使用vector和filterKVs生成PQL @ vector: 指定聚合时间范围 @ granularity: 指定聚合粒度 @ filterKVs: 过滤条件, 格式为 key1, value1, key2, value2

func DayOnDay

func DayOnDay(pqlTemplate AggPQLWithFilters) AggPQLWithFilters

计算指标日同比变化率

func WeekOnWeek

func WeekOnWeek(pqlTemplate AggPQLWithFilters) AggPQLWithFilters

计算指标周同比变化率

func WithDefaultIFPolarisMetricExits

func WithDefaultIFPolarisMetricExits(pqlTemplate AggPQLWithFilters, defaultValue int64) AggPQLWithFilters

type ConvertFromLabels

type ConvertFromLabels interface {
	ConvertFromLabels(labels Labels) ConvertFromLabels
}

type DescendantMetrics

type DescendantMetrics struct {
	ServiceName string         `json:"serviceName"` // 服务名
	EndPoint    string         `json:"endpoint"`    // Endpoint
	LatencyP90  []MetricsPoint `json:"latencyP90"`  // P90曲线值
}

type EndpointKey

type EndpointKey struct {
	ContentKey string // URL
	SvcName    string // url所属的服务名
}

func (EndpointKey) ConvertFromLabels

func (e EndpointKey) ConvertFromLabels(labels Labels) ConvertFromLabels

type EndpointMetrics

type EndpointMetrics struct {
	EndpointKey

	DelaySource   *float64 //延时主要来源
	AlertCount    int
	NamespaceList []string // 包含该端点的Namespace

	// TODO DelaySource值为nil和值为0是两种场景。
	//  nil表示没有查询到数据(可能没有这个指标),显示未知;0表示无网络占比,显示自身
	IsLatencyExceeded   bool
	IsErrorRateExceeded bool
	IsTPSExceeded       bool

	Avg1MinLatencyMutationRate float64 //延时突变率
	Avg1MinErrorMutationRate   float64 //错误率突变率

	REDMetrics REDMetrics

	LatencyData   []Points // 延时时间段的数据
	ErrorRateData []Points // 错误率时间段的数据
	TPMData       []Points // TPM 时间段的数据
}

func (*EndpointMetrics) AppendGroupIfNotExist

func (e *EndpointMetrics) AppendGroupIfNotExist(_ MGroupName, metricName MName) bool

func (*EndpointMetrics) InitEmptyGroup

func (e *EndpointMetrics) InitEmptyGroup(key ConvertFromLabels) MetricGroup

func (*EndpointMetrics) SetValue

func (e *EndpointMetrics) SetValue(metricGroup MGroupName, metricName MName, value float64)

type Granularity

type Granularity string
const (
	SVCGranularity        Granularity = "svc_name"
	EndpointGranularity   Granularity = "svc_name, content_key"
	NSEndpointGranularity Granularity = "namespace, svc_name, content_key"
	InstanceGranularity   Granularity = "svc_name, content_key, container_id, node_name, pid, pod, namespace, node_ip"

	LogGranularity         Granularity = "pid,host_name,host_ip,container_id,pod_name,namespace"
	DBOperationGranularity Granularity = "svc_name, db_system, db_name, name, db_url"
)

type InstanceKey

type InstanceKey struct {
	PID         string `json:"pid"`
	ContainerId string `json:"container_id"`
	Pod         string `json:"pod"`
	Namespace   string `json:"namespace"`
	NodeName    string `json:"node_name"`
	NodeIP      string `json:"node_ip"`
}

func (InstanceKey) ConvertFromLabels

func (i InstanceKey) ConvertFromLabels(labels Labels) ConvertFromLabels

func (InstanceKey) GenInstanceName

func (i InstanceKey) GenInstanceName() string

type InstanceMetrics

type InstanceMetrics struct {
	InstanceKey

	REDMetrics REDMetrics

	LogDayOverDay   *float64
	LogWeekOverWeek *float64
	LogAVGData      *float64

	LatencyData   []Points
	ErrorRateData []Points
	TPMData       []Points
	LogData       []Points
}

InstanceMetrics instance粒度的指标结果

func (*InstanceMetrics) AppendGroupIfNotExist

func (e *InstanceMetrics) AppendGroupIfNotExist(_ MGroupName, metricName MName) bool

func (*InstanceMetrics) InitEmptyGroup

func (e *InstanceMetrics) InitEmptyGroup(key ConvertFromLabels) MetricGroup

func (*InstanceMetrics) SetValue

func (e *InstanceMetrics) SetValue(metricGroup MGroupName, metricName MName, value float64)

type Labels

type Labels struct {
	ContainerID string `json:"container_id"`
	ContentKey  string `json:"content_key"`
	Instance    string `json:"instance"`
	IsError     string `json:"is_error"`
	Job         string `json:"job"`
	NodeName    string `json:"node_name"`
	POD         string `json:"pod"`
	SvcName     string `json:"svc_name"`
	TopSpan     string `json:"top_span"`
	PID         string `json:"pid"`
	PodName     string `json:"pod_name"` // TODO 统一为pod之后可以删除
	Namespace   string `json:"namespace"`
	NodeIP      string `json:"node_ip"`

	DBSystem string `json:"db_system"`
	DBName   string `json:"db_name"`
	// Name, currently represents the Opertaion section in SQL
	// e.g: SELECT trip
	Name  string `json:"name"`
	DBUrl string `json:"db_url"`

	MonitorName string `json:"monitor_name"`
}

func (*Labels) Extract

func (l *Labels) Extract(metric prommodel.Metric)

Extract 提取出需要的label 需要同步Labels字段的变化

type MGroupName

type MGroupName string

metricGroup Name

type MName

type MName string

metricName

type MetricGroup

type MetricGroup interface {
	InitEmptyGroup(key ConvertFromLabels) MetricGroup
	AppendGroupIfNotExist(metricGroup MGroupName, metricName MName) bool
	SetValue(metricGroup MGroupName, metricName MName, value float64)
}

type MetricGroupInterface

type MetricGroupInterface interface {
	MergeMetricResults(metricGroup MGroupName, metricName MName, metricResults []MetricResult)
}

type MetricGroupMap

type MetricGroupMap[K interface {
	comparable
	ConvertFromLabels
}, V MetricGroup] struct {
	// 用于返回列表
	MetricGroupList []V
	// 用于通过Key快速查询对应的MetricGroup
	MetricGroupMap map[K]V
}

func (*MetricGroupMap[K, V]) MergeMetricResults

func (m *MetricGroupMap[K, V]) MergeMetricResults(metricGroup MGroupName, metricName MName, metricResults []MetricResult)

type MetricResult

type MetricResult struct {
	Metric Labels   `json:"metric"`
	Values []Points `json:"values"`
}

type MetricsPoint

type MetricsPoint struct {
	Timestamp int64   `json:"timestamp"` // 时间(微秒)
	Value     float64 `json:"value"`     // 值
}

type P9xCondition

type P9xCondition struct {
	Key    string
	Values []string
}

type Points

type Points struct {
	TimeStamp int64
	Value     float64
}

type QueryType

type QueryType int
const (
	AvgError QueryType = iota //平均错误率
	ErrorDOD
	ErrorWOW
	ErrorData
	AvgLatency
	LatencyDOD
	LatencyWOW
	LatencyData
	AvgTPS
	TPSDOD
	TPSWOW
	TPSData
	DelaySource
	AvgLog
	LogDOD
	LogWOW
	LogNow
	LogYesterday
	LogLastWeek
	Avg1minError
	Avg1minLatency
)

atodo 将正则表达式转换

type REDMetric

type REDMetric struct {
	Latency   *float64
	ErrorRate *float64
	TPM       *float64
}

type REDMetrics

type REDMetrics struct {
	Realtime REDMetric
	Avg      REDMetric
	DOD      REDMetric
	WOW      REDMetric
}

func (*REDMetrics) AppendGroupIfNotExist

func (m *REDMetrics) AppendGroupIfNotExist(_ MGroupName, metricName MName) bool

func (*REDMetrics) InitEmptyGroup

func (m *REDMetrics) InitEmptyGroup(_ ConvertFromLabels) MetricGroup

func (*REDMetrics) SetValue

func (m *REDMetrics) SetValue(metricGroup MGroupName, metricName MName, value float64)

type Repo

type Repo interface {
	// ========== span_trace_duration_bucket Start ==========
	// 基于服务列表、URL列表和时段、步长,查询P90曲线
	QueryRangePercentile(startTime int64, endTime int64, step int64, nodes *model.TopologyNodes) ([]DescendantMetrics, error)
	// 查询实例的P90延时曲线
	QueryInstanceP90(startTime int64, endTime int64, step int64, endpoint string, instance *model.ServiceInstance) (map[int64]float64, error)

	// ========== span_trace_duration_count Start ==========
	// 查询服务列表
	GetServiceList(startTime int64, endTime int64, namespace []string) ([]string, error)
	// 查询服务实例列表, URL允许为空
	GetInstanceList(startTime int64, endTime int64, serviceName string, url string) (*model.ServiceInstances, error)
	// 查询活跃实例列表
	GetActiveInstanceList(startTime int64, endTime int64, serviceName string) (*model.ServiceInstances, error)
	// 查询服务Endpoint列表,服务允许为空
	GetServiceEndPointList(startTime int64, endTime int64, serviceName string) ([]string, error)
	GetMultiServicesInstanceList(startTime int64, endTime int64, services []string) (map[string]*model.ServiceInstances, error)
	// 查询服务实例失败率
	QueryInstanceErrorRate(startTime int64, endTime int64, step int64, endpoint string, instance *model.ServiceInstance) (map[int64]float64, error)
	FillMetric(res MetricGroupInterface, metricGroup MGroupName, startTime, endTime time.Time, filters []string, granularity Granularity)

	QueryData(searchTime time.Time, query string) ([]MetricResult, error)
	QueryRangeData(startTime time.Time, endTime time.Time, query string, step time.Duration) ([]MetricResult, error)
	QueryLatencyData(searchTime time.Time, query string) ([]MetricResult, error)
	QueryRangeLatencyData(startTime time.Time, endTime time.Time, query string, step time.Duration) ([]MetricResult, error)
	QueryErrorRateData(searchTime time.Time, query string) ([]MetricResult, error)
	QueryRangeErrorData(startTime time.Time, endTime time.Time, query string, step time.Duration) ([]MetricResult, error)

	// ========== originx_logparser_level_count_total Start ==========
	// 查询实例日志Error数
	QueryLogCountByInstanceId(instance *model.ServiceInstance, startTime int64, endTime int64, step int64) (map[int64]float64, error)
	// QueryInstanceLogRangeData 查询实例级别的日志曲线图
	QueryInstanceLogRangeData(pqlTemplate AggPQLWithFilters, startTime int64, endTime int64, stepMicroS int64, granularity Granularity, podFilterKVs, vmFilterKVs []string) ([]MetricResult, error)

	// ========== db_duration_bucket Start ==========
	// 基于服务列表、URL列表和时段、步长,查询P90曲线
	QueryDbRangePercentile(startTime int64, endTime int64, step int64, nodes *model.TopologyNodes) ([]DescendantMetrics, error)

	// ========== external_duration_bucket Start ==========
	// 基于服务列表、URL列表和时段、步长,查询P90曲线
	QueryExternalRangePercentile(startTime int64, endTime int64, step int64, nodes *model.TopologyNodes) ([]DescendantMetrics, error)

	// ========== mq_duration_bucket Start ==========
	// 基于服务列表、URL列表和时段、步长,查询P90曲线
	QueryMqRangePercentile(startTime int64, endTime int64, step int64, nodes *model.TopologyNodes) ([]DescendantMetrics, error)

	QueryAggMetricsWithFilter(pqlTemplate AggPQLWithFilters, startTime int64, endTime int64, granularity Granularity, filterKVs ...string) ([]MetricResult, error)
	QueryRangeAggMetricsWithFilter(pqlTemplate AggPQLWithFilters, startTime int64, endTime int64, step int64, granularity Granularity, filterKVs ...string) ([]MetricResult, error)
	// originx_process_start_time
	QueryProcessStartTime(startTime time.Time, endTime time.Time, instances []*model.ServiceInstance) (map[model.ServiceInstance]int64, error)
	GetApi() v1.API
	GetRange() string

	GetNamespaceList(startTime int64, endTime int64) ([]string, error)
}

func New

func New(
	logger *zap.Logger,
	address string,
	storage string) (Repo, error)

type SQLKey

type SQLKey struct {
	Service string `json:"service"`
	// DBSystem -> ${SQL Type}, e.g: Mysql
	DBSystem string `json:"dbSystem"`
	// DBName -> ${database}
	DBName string `json:"dbName"`
	// DBOperation -> ${operation} ${table}, e.g: SELECT trip
	DBOperation string `json:"dbOperation"`
	DBUrl       string `json:"dbUrl"`
}

func (SQLKey) ConvertFromLabels

func (k SQLKey) ConvertFromLabels(labels Labels) ConvertFromLabels

type ServiceKey

type ServiceKey struct {
	SvcName string // url所属的服务名
}

func (ServiceKey) ConvertFromLabels

func (S ServiceKey) ConvertFromLabels(labels Labels) ConvertFromLabels

type UnionP9xBuilder

type UnionP9xBuilder struct {
	// contains filtered or unexported fields
}

func NewUnionP9xBuilder

func NewUnionP9xBuilder(value string, tableName string, labels []string, duration time.Duration) *UnionP9xBuilder

func (*UnionP9xBuilder) AddCondition

func (p9x *UnionP9xBuilder) AddCondition(key string, values []string) error

func (*UnionP9xBuilder) AddExtraCondition

func (p9x *UnionP9xBuilder) AddExtraCondition(condition string)

func (*UnionP9xBuilder) ToString

func (p9x *UnionP9xBuilder) ToString() string

type WrappedApi

type WrappedApi struct {
	v1.API
	// contains filtered or unexported fields
}

func (*WrappedApi) Query

func (api *WrappedApi) Query(ctx context.Context, query string, ts time.Time, opts ...v1.Option) (model.Value, v1.Warnings, error)

func (*WrappedApi) QueryRange

func (api *WrappedApi) QueryRange(ctx context.Context, query string, r v1.Range, opts ...v1.Option) (model.Value, v1.Warnings, error)

Jump to

Keyboard shortcuts

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