Documentation ¶
Index ¶
- Constants
- type BackendReader
- func (br *BackendReader) AddQueryRule(key string, rule QueryRule)
- func (br *BackendReader) Close()
- func (br *BackendReader) GetBackendMetrics() []byte
- func (br *BackendReader) GetQueryResult(key string) QueryResult
- func (br *BackendReader) OnElected()
- func (br *BackendReader) OnRetired()
- func (br *BackendReader) PreClose()
- func (br *BackendReader) ReadMetrics(ctx context.Context) error
- func (br *BackendReader) RemoveQueryRule(key string)
- func (br *BackendReader) Start(ctx context.Context) error
- type DefaultMetricsReader
- func (dmr *DefaultMetricsReader) AddQueryExpr(key string, queryExpr QueryExpr, queryRule QueryRule)
- func (dmr *DefaultMetricsReader) Close()
- func (dmr *DefaultMetricsReader) GetBackendMetrics() []byte
- func (dmr *DefaultMetricsReader) GetQueryResult(key string) QueryResult
- func (dmr *DefaultMetricsReader) PreClose()
- func (dmr *DefaultMetricsReader) RemoveQueryExpr(key string)
- func (dmr *DefaultMetricsReader) Start(ctx context.Context) error
- type MetricsReader
- type PromInfoFetcher
- type PromReader
- type QueryExpr
- type QueryResult
- type QueryRule
- type TopologyFetcher
Constants ¶
View Source
const (
LabelNameInstance = "instance"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackendReader ¶ added in v1.2.0
func NewBackendReader ¶ added in v1.2.0
func NewBackendReader(lg *zap.Logger, cfgGetter config.ConfigGetter, httpCli *http.Client, etcdCli *clientv3.Client, backendFetcher TopologyFetcher, cfg *config.HealthCheck) *BackendReader
func (*BackendReader) AddQueryRule ¶ added in v1.2.0
func (br *BackendReader) AddQueryRule(key string, rule QueryRule)
func (*BackendReader) Close ¶ added in v1.2.0
func (br *BackendReader) Close()
func (*BackendReader) GetBackendMetrics ¶ added in v1.2.0
func (br *BackendReader) GetBackendMetrics() []byte
func (*BackendReader) GetQueryResult ¶ added in v1.2.0
func (br *BackendReader) GetQueryResult(key string) QueryResult
func (*BackendReader) OnElected ¶ added in v1.2.0
func (br *BackendReader) OnElected()
func (*BackendReader) OnRetired ¶ added in v1.2.0
func (br *BackendReader) OnRetired()
func (*BackendReader) PreClose ¶ added in v1.2.0
func (br *BackendReader) PreClose()
func (*BackendReader) ReadMetrics ¶ added in v1.2.0
func (br *BackendReader) ReadMetrics(ctx context.Context) error
func (*BackendReader) RemoveQueryRule ¶ added in v1.2.0
func (br *BackendReader) RemoveQueryRule(key string)
type DefaultMetricsReader ¶
type DefaultMetricsReader struct {
// contains filtered or unexported fields
}
func NewDefaultMetricsReader ¶
func NewDefaultMetricsReader(lg *zap.Logger, promFetcher PromInfoFetcher, backendFetcher TopologyFetcher, httpCli *http.Client, etcdCli *clientv3.Client, cfg *config.HealthCheck, cfgGetter config.ConfigGetter) *DefaultMetricsReader
func (*DefaultMetricsReader) AddQueryExpr ¶
func (dmr *DefaultMetricsReader) AddQueryExpr(key string, queryExpr QueryExpr, queryRule QueryRule)
func (*DefaultMetricsReader) Close ¶
func (dmr *DefaultMetricsReader) Close()
func (*DefaultMetricsReader) GetBackendMetrics ¶ added in v1.2.0
func (dmr *DefaultMetricsReader) GetBackendMetrics() []byte
func (*DefaultMetricsReader) GetQueryResult ¶
func (dmr *DefaultMetricsReader) GetQueryResult(key string) QueryResult
GetQueryResult returns an empty result if the key or the result is not found.
func (*DefaultMetricsReader) PreClose ¶ added in v1.2.0
func (dmr *DefaultMetricsReader) PreClose()
func (*DefaultMetricsReader) RemoveQueryExpr ¶
func (dmr *DefaultMetricsReader) RemoveQueryExpr(key string)
type MetricsReader ¶
type PromInfoFetcher ¶
type PromInfoFetcher interface {
GetPromInfo(ctx context.Context) (*infosync.PrometheusInfo, error)
}
PromInfoFetcher is an interface to fetch the Prometheus info from ETCD.
type PromReader ¶ added in v1.2.0
func NewPromReader ¶ added in v1.2.0
func NewPromReader(lg *zap.Logger, promFetcher PromInfoFetcher, cfg *config.HealthCheck) *PromReader
func (*PromReader) AddQueryExpr ¶ added in v1.2.0
func (pr *PromReader) AddQueryExpr(key string, queryExpr QueryExpr)
func (*PromReader) Close ¶ added in v1.2.0
func (pr *PromReader) Close()
func (*PromReader) GetQueryResult ¶ added in v1.2.0
func (pr *PromReader) GetQueryResult(key string) QueryResult
func (*PromReader) ReadMetrics ¶ added in v1.2.0
func (pr *PromReader) ReadMetrics(ctx context.Context) error
func (*PromReader) RemoveQueryExpr ¶ added in v1.2.0
func (pr *PromReader) RemoveQueryExpr(key string)
type QueryResult ¶
func (QueryResult) Empty ¶
func (qr QueryResult) Empty() bool
func (QueryResult) GetSample4Backend ¶
func (qr QueryResult) GetSample4Backend(backend policy.BackendCtx) *model.Sample
GetSample4Backend returns metric of a backend from a vector.
func (QueryResult) GetSamplePair4Backend ¶
func (qr QueryResult) GetSamplePair4Backend(backend policy.BackendCtx) []model.SamplePair
GetSamplePair4Backend returns metric of a backend from a matrix.
type QueryRule ¶ added in v1.2.0
type QueryRule struct { // Names are the metric names that to be extracted from backend metrics. Names []string // Retention is the retention time of the metrics. Older metrics are expired. Retention time.Duration // Metric2Value defines the process from backend metrics (at a timepoint) to a float value. // E.g. division or aggregation. Metric2Value func(mfs map[string]*dto.MetricFamily) model.SampleValue // Range2Value defines the process from a time range of values to a float value. // E.g. irate[30s] or increase[1m]. Range2Value func(pairs []model.SamplePair) model.SampleValue // ResultType indicates returning a vector or matrix as the final result. ResultType model.ValueType }
QueryRule is used for processing the result from backend HTTP metrics API. It's too complicated for the BackendReader to parse PromQL, so let the caller to define the process function.
type TopologyFetcher ¶ added in v1.2.0
type TopologyFetcher interface {
GetTiDBTopology(ctx context.Context) (map[string]*infosync.TiDBTopologyInfo, error)
}
TopologyFetcher is an interface to fetch the tidb topology from ETCD.
Click to show internal directories.
Click to hide internal directories.