mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-01 15:07:17 +08:00
fix(cloudmon): cloudpods collect metric interval (#22765)
This commit is contained in:
@@ -107,6 +107,9 @@ type SimpleQueryInput struct {
|
||||
EndTime time.Time `json:"end_time"`
|
||||
// 指定标签
|
||||
Tags map[string]string `json:"tag_pairs"`
|
||||
// 间隔周期
|
||||
// default: 5m
|
||||
Interval string `json:"interval"`
|
||||
}
|
||||
|
||||
type SimpleQueryOutput struct {
|
||||
|
||||
@@ -563,6 +563,7 @@ func (cli *SCloudpodsClient) GetMetrics(opts *cloudprovider.MetricListOptions) (
|
||||
"metric_name": opts.MetricType,
|
||||
"start_time": opts.StartTime,
|
||||
"end_time": opts.EndTime,
|
||||
"interval": "1m",
|
||||
"tag_pairs": map[string]interface{}{
|
||||
"brand": brandArr[i],
|
||||
},
|
||||
|
||||
@@ -560,7 +560,14 @@ func (self *SUnifiedMonitorManager) GetPropertySimpleQuery(ctx context.Context,
|
||||
for k, v := range input.Tags {
|
||||
where.Equal(k, v)
|
||||
}
|
||||
data.From(input.StartTime).To(input.EndTime).Interval("5m")
|
||||
if len(input.Interval) == 0 {
|
||||
input.Interval = "5m"
|
||||
}
|
||||
_, err := time.ParseDuration(input.Interval)
|
||||
if err != nil {
|
||||
return nil, httperrors.NewInputParameterError("invalid interval %s", input.Interval)
|
||||
}
|
||||
data.From(input.StartTime).To(input.EndTime).Interval(input.Interval)
|
||||
|
||||
queryData := data.ToQueryData()
|
||||
dbRtn, err := self.performQuery(ctx, userCred, queryData)
|
||||
|
||||
Reference in New Issue
Block a user