add maxSeriesPoints for config.transfer.m3db (#609)

This commit is contained in:
yubo 2021-03-10 17:50:38 +08:00 committed by GitHub
parent bf1bd3ef5a
commit 3e426537c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 12 deletions

View File

@ -2,6 +2,7 @@ backend:
datasource: "tsdb" datasource: "tsdb"
m3db: m3db:
enabled: false enabled: false
maxSeriesPoints: 720 # default 720
name: "m3db" name: "m3db"
namespace: "default" namespace: "default"
seriesLimit: 0 seriesLimit: 0

View File

@ -121,7 +121,7 @@ func xcludeResp(iter ident.TagIterator) *dataobj.XcludeResp {
func resampleResp(data []*dataobj.TsdbQueryResponse, opts dataobj.QueryDataForUI) []*dataobj.TsdbQueryResponse { func resampleResp(data []*dataobj.TsdbQueryResponse, opts dataobj.QueryDataForUI) []*dataobj.TsdbQueryResponse {
for _, v := range data { for _, v := range data {
if len(v.Values) <= MAX_PONINTS { if len(v.Values) <= maxSeriesPoints {
continue continue
} }
v.Values = resample(v.Values, opts.Start, opts.End, int64(opts.Step), opts.ConsolFunc) v.Values = resample(v.Values, opts.Start, opts.End, int64(opts.Step), opts.ConsolFunc)

View File

@ -28,16 +28,21 @@ const (
MAX_PONINTS = 720 MAX_PONINTS = 720
) )
var (
maxSeriesPoints = 720
)
type M3dbSection struct { type M3dbSection struct {
Name string `yaml:"name"` Name string `yaml:"name"`
Enabled bool `yaml:"enabled"` Enabled bool `yaml:"enabled"`
Namespace string `yaml:"namespace"` Namespace string `yaml:"namespace"`
DaysLimit int `yaml:"daysLimit"` DaysLimit int `yaml:"daysLimit"`
SeriesLimit int `yaml:"seriesLimit"` SeriesLimit int `yaml:"seriesLimit"`
DocsLimit int `yaml:"docsLimit"` DocsLimit int `yaml:"docsLimit"`
MinStep int `yaml:"minStep"` MinStep int `yaml:"minStep"`
Config client.Configuration `yaml:",inline"` MaxSeriesPoints int `yaml:"maxSeriesPoints"`
timeLimit int64 `yaml:"-"` Config client.Configuration `yaml:",inline"`
timeLimit int64 `yaml:"-"`
} }
type Client struct { type Client struct {
@ -67,6 +72,10 @@ func NewClient(cfg M3dbSection) (*Client, error) {
cfg.MinStep = 1 cfg.MinStep = 1
} }
if cfg.MaxSeriesPoints > 0 {
maxSeriesPoints = cfg.MaxSeriesPoints
}
cfg.timeLimit = int64(86400 * cfg.DaysLimit) cfg.timeLimit = int64(86400 * cfg.DaysLimit)
ret := &Client{ ret := &Client{
@ -516,13 +525,13 @@ func (cfg M3dbSection) validateQueryDataForUI(in *dataobj.QueryDataForUI) (err e
} }
if in.Step > 0 { if in.Step > 0 {
if n := (in.End - in.Start) / int64(in.Step); n > MAX_PONINTS { if n := int(in.End-in.Start) / in.Step; n > maxSeriesPoints {
in.Step = 0 in.Step = 0
} }
} }
if in.Step <= 0 { if in.Step <= 0 {
in.Step = int((in.End - in.Start) / MAX_PONINTS) in.Step = int(in.End-in.Start) / maxSeriesPoints
} }
if in.Step < cfg.MinStep { if in.Step < cfg.MinStep {