指标图表可以设置忽略空值和其他对象值

This commit is contained in:
GoEdgeLab
2021-07-26 16:44:29 +08:00
parent 7c9afcd130
commit 844ece8e95
7 changed files with 224 additions and 75 deletions

View File

@@ -751,7 +751,7 @@ func (this *AdminService) findMetricDataCharts(tx *dbs.Tx) (result []*pb.MetricD
var pbStats = []*pb.MetricStat{}
switch chart.Type {
case serverconfigs.MetricChartTypeTimeLine:
itemStats, err := models.SharedMetricStatDAO.FindLatestItemStats(tx, itemId, types.Int32(item.Version), 10)
itemStats, err := models.SharedMetricStatDAO.FindLatestItemStats(tx, itemId, chart.IgnoreEmptyKeys == 1, chart.DecodeIgnoredKeys(), types.Int32(item.Version), 10)
if err != nil {
return nil, err
}
@@ -780,7 +780,7 @@ func (this *AdminService) findMetricDataCharts(tx *dbs.Tx) (result []*pb.MetricD
})
}
default:
itemStats, err := models.SharedMetricStatDAO.FindItemStatsAtLastTime(tx, itemId, types.Int32(item.Version), 10)
itemStats, err := models.SharedMetricStatDAO.FindItemStatsAtLastTime(tx, itemId, chart.IgnoreEmptyKeys == 1, chart.DecodeIgnoredKeys(), types.Int32(item.Version), 10)
if err != nil {
return nil, err
}

View File

@@ -31,7 +31,7 @@ func (this *MetricChartService) CreateMetricChart(ctx context.Context, req *pb.C
return nil, err
}
}
chartId, err := models.SharedMetricChartDAO.CreateChart(tx, req.MetricItemId, req.Name, req.Type, req.WidthDiv, req.MaxItems, params)
chartId, err := models.SharedMetricChartDAO.CreateChart(tx, req.MetricItemId, req.Name, req.Type, req.WidthDiv, req.MaxItems, params, req.IgnoreEmptyKeys, req.IgnoredKeys)
if err != nil {
return nil, err
}
@@ -53,7 +53,7 @@ func (this *MetricChartService) UpdateMetricChart(ctx context.Context, req *pb.U
return nil, err
}
}
err = models.SharedMetricChartDAO.UpdateChart(tx, req.MetricChartId, req.Name, req.Type, req.WidthDiv, req.MaxItems, params, req.IsOn)
err = models.SharedMetricChartDAO.UpdateChart(tx, req.MetricChartId, req.Name, req.Type, req.WidthDiv, req.MaxItems, params, req.IgnoreEmptyKeys, req.IgnoredKeys, req.IsOn)
if err != nil {
return nil, err
}
@@ -77,14 +77,16 @@ func (this *MetricChartService) FindEnabledMetricChart(ctx context.Context, req
}
return &pb.FindEnabledMetricChartResponse{
MetricChart: &pb.MetricChart{
Id: int64(chart.Id),
Name: chart.Name,
Type: chart.Type,
WidthDiv: types.Int32(chart.WidthDiv),
MaxItems: types.Int32(chart.MaxItems),
ParamsJSON: []byte(chart.Params),
IsOn: chart.IsOn == 1,
MetricItem: &pb.MetricItem{Id: int64(chart.ItemId)},
Id: int64(chart.Id),
Name: chart.Name,
Type: chart.Type,
WidthDiv: types.Int32(chart.WidthDiv),
MaxItems: types.Int32(chart.MaxItems),
ParamsJSON: []byte(chart.Params),
IgnoreEmptyKeys: chart.IgnoreEmptyKeys == 1,
IgnoredKeys: chart.DecodeIgnoredKeys(),
IsOn: chart.IsOn == 1,
MetricItem: &pb.MetricItem{Id: int64(chart.ItemId)},
},
}, nil
}
@@ -119,13 +121,15 @@ func (this *MetricChartService) ListEnabledMetricCharts(ctx context.Context, req
var pbCharts []*pb.MetricChart
for _, chart := range charts {
pbCharts = append(pbCharts, &pb.MetricChart{
Id: int64(chart.Id),
Name: chart.Name,
Type: chart.Type,
WidthDiv: types.Int32(chart.WidthDiv),
MaxItems: types.Int32(chart.MaxItems),
ParamsJSON: []byte(chart.Params),
IsOn: chart.IsOn == 1,
Id: int64(chart.Id),
Name: chart.Name,
Type: chart.Type,
WidthDiv: types.Int32(chart.WidthDiv),
MaxItems: types.Int32(chart.MaxItems),
ParamsJSON: []byte(chart.Params),
IgnoreEmptyKeys: chart.IgnoreEmptyKeys == 1,
IgnoredKeys: chart.DecodeIgnoredKeys(),
IsOn: chart.IsOn == 1,
})
}
return &pb.ListEnabledMetricChartsResponse{MetricCharts: pbCharts}, nil

View File

@@ -605,11 +605,11 @@ func (this *ServerStatBoardService) findNodeClusterMetricDataCharts(tx *dbs.Tx,
case serverconfigs.MetricChartTypeTimeLine:
var itemStats []*models.MetricStat
if serverId > 0 {
itemStats, err = models.SharedMetricStatDAO.FindLatestItemStatsWithServerId(tx, serverId, itemId, types.Int32(item.Version), 10)
itemStats, err = models.SharedMetricStatDAO.FindLatestItemStatsWithServerId(tx, serverId, itemId, chart.IgnoreEmptyKeys == 1, chart.DecodeIgnoredKeys(), types.Int32(item.Version), 10)
} else if nodeId > 0 {
itemStats, err = models.SharedMetricStatDAO.FindLatestItemStatsWithNodeId(tx, nodeId, itemId, types.Int32(item.Version), 10)
itemStats, err = models.SharedMetricStatDAO.FindLatestItemStatsWithNodeId(tx, nodeId, itemId, chart.IgnoreEmptyKeys == 1, chart.DecodeIgnoredKeys(), types.Int32(item.Version), 10)
} else {
itemStats, err = models.SharedMetricStatDAO.FindLatestItemStatsWithClusterId(tx, clusterId, itemId, types.Int32(item.Version), 10)
itemStats, err = models.SharedMetricStatDAO.FindLatestItemStatsWithClusterId(tx, clusterId, itemId, chart.IgnoreEmptyKeys == 1, chart.DecodeIgnoredKeys(), types.Int32(item.Version), 10)
}
if err != nil {
return nil, err
@@ -649,11 +649,11 @@ func (this *ServerStatBoardService) findNodeClusterMetricDataCharts(tx *dbs.Tx,
default:
var itemStats []*models.MetricStat
if serverId > 0 {
itemStats, err = models.SharedMetricStatDAO.FindItemStatsWithServerIdAndLastTime(tx, serverId, itemId, types.Int32(item.Version), 10)
itemStats, err = models.SharedMetricStatDAO.FindItemStatsWithServerIdAndLastTime(tx, serverId, itemId, chart.IgnoreEmptyKeys == 1, chart.DecodeIgnoredKeys(), types.Int32(item.Version), 10)
} else if nodeId > 0 {
itemStats, err = models.SharedMetricStatDAO.FindItemStatsWithNodeIdAndLastTime(tx, nodeId, itemId, types.Int32(item.Version), 10)
itemStats, err = models.SharedMetricStatDAO.FindItemStatsWithNodeIdAndLastTime(tx, nodeId, itemId, chart.IgnoreEmptyKeys == 1, chart.DecodeIgnoredKeys(), types.Int32(item.Version), 10)
} else {
itemStats, err = models.SharedMetricStatDAO.FindItemStatsWithClusterIdAndLastTime(tx, clusterId, itemId, types.Int32(item.Version), 10)
itemStats, err = models.SharedMetricStatDAO.FindItemStatsWithClusterIdAndLastTime(tx, clusterId, itemId, chart.IgnoreEmptyKeys == 1, chart.DecodeIgnoredKeys(), types.Int32(item.Version), 10)
}
if err != nil {
return nil, err