fix: missing data when processing multiple time series in a g… (#127)
* fix: address missing data when processing multiple time series in a group with insight data API * chore: update release notes
This commit is contained in:
parent
c76875c1c2
commit
1ee6c59d2c
|
@ -15,6 +15,7 @@ Information about release notes of INFINI Console is provided here.
|
|||
- Support alerts based on bucket diff state (#119)
|
||||
|
||||
### Bug fix
|
||||
- Fixed missing data when processing multiple time series in a group with insight data API (#127)
|
||||
|
||||
### Improvements
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ title: "版本历史"
|
|||
### Features
|
||||
- 告警功能支持根据桶之间文档数差值和内容差异告警 (#119)
|
||||
### Bug fix
|
||||
- 修复 Insight API 处理多时间序列数据时数据丢失的问题 (#127)
|
||||
|
||||
### Improvements
|
||||
|
||||
|
|
|
@ -296,7 +296,11 @@ func getMetricData(metric *insight.Metric) (interface{}, error) {
|
|||
Groups: md.Groups,
|
||||
Data: map[string][]insight.MetricDataItem{},
|
||||
}
|
||||
retMetricDataItem := insight.MetricDataItem{}
|
||||
//merge metric data by timestamp
|
||||
var timeMetricData = map[interface{}]*insight.MetricDataItem{}
|
||||
//non time series data
|
||||
grpMetricData := &insight.MetricDataItem{}
|
||||
isTimeSeries := false
|
||||
for _, formula = range metric.Formulas {
|
||||
tpl, err := template.New("insight_formula").Parse(formula)
|
||||
if err != nil {
|
||||
|
@ -347,6 +351,19 @@ func getMetricData(metric *insight.Metric) (interface{}, error) {
|
|||
continue
|
||||
}
|
||||
}
|
||||
var retMetricDataItem *insight.MetricDataItem
|
||||
//time series data
|
||||
if timestamp != nil {
|
||||
isTimeSeries = true
|
||||
if v, ok := timeMetricData[timestamp]; !ok {
|
||||
retMetricDataItem = &insight.MetricDataItem{}
|
||||
} else {
|
||||
retMetricDataItem = v
|
||||
}
|
||||
} else {
|
||||
//non time series data
|
||||
retMetricDataItem = grpMetricData
|
||||
}
|
||||
retMetricDataItem.Timestamp = timestamp
|
||||
if len(metric.Formulas) <= 1 && metric.Formula != "" {
|
||||
//support older versions by returning the result for a single formula.
|
||||
|
@ -358,9 +375,18 @@ func getMetricData(metric *insight.Metric) (interface{}, error) {
|
|||
retMetricDataItem.Value = map[string]interface{}{formula: result}
|
||||
}
|
||||
}
|
||||
if timestamp != nil {
|
||||
timeMetricData[timestamp] = retMetricDataItem
|
||||
}
|
||||
}
|
||||
}
|
||||
if !isTimeSeries {
|
||||
targetData.Data["result"] = append(targetData.Data["result"], *grpMetricData)
|
||||
} else {
|
||||
for _, v := range timeMetricData {
|
||||
targetData.Data["result"] = append(targetData.Data["result"], *v)
|
||||
}
|
||||
}
|
||||
targetData.Data["result"] = append(targetData.Data["result"], retMetricDataItem)
|
||||
targetMetricData = append(targetMetricData, targetData)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue