Skip to content

Commit fe267b8

Browse files
committed
fix disk blk_read_bytes being negative due to diffps
1 parent 2d3bcf5 commit fe267b8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

internal/tools/monitor/core/metric/query/es-tsql/influxql/ckFunctions.go

+5
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ var CkAggFunctions = map[string]*SQlAggFuncDefine{
210210
}
211211
seconds := float64(ctx.interval*int64(ctx.targetTimeUnit)) / float64(tsql.Second)
212212
nextValue := nextV[id].(float64)
213+
// diffps return value should not be negative
214+
// erda issue: https://erda.cloud/erda/dop/projects/387/issues/all?id=581160&iterationID=12783&tab=BUG&type=BUG
215+
if nextValue < currentV {
216+
return 0, true
217+
}
213218
return (nextValue - currentV) / seconds, true
214219
}
215220
}

internal/tools/monitor/core/metric/query/es-tsql/influxql/ckFunctions_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ func TestAggregationHandlerFunction(t *testing.T) {
283283
nextRow: map[string]interface{}{
284284
"0e4b5b1082a11703": float64(111),
285285
},
286-
want: (111.0 - 222.0) / 60.0,
286+
want: 0,
287287
},
288288

289289
{

0 commit comments

Comments
 (0)