mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 06:09:39 +08:00
feat(monitor): influxQuery add P95 reduce
This commit is contained in:
@@ -134,6 +134,20 @@ func (s *queryReducer) Reduce(series *tsdb.TimeSeries) (*float64, []string) {
|
||||
if value > 0 {
|
||||
allNull = false
|
||||
}
|
||||
case "P95":
|
||||
var values []float64
|
||||
for _, v := range series.Points {
|
||||
if v.IsValid() {
|
||||
allNull = false
|
||||
values = append(values, v.Value())
|
||||
}
|
||||
}
|
||||
if len(values) >= 1 {
|
||||
sort.Float64s(values)
|
||||
length := len(values)
|
||||
index := math.Floor(float64(length) * 0.95)
|
||||
value = values[int64(index)]
|
||||
}
|
||||
}
|
||||
|
||||
if allNull {
|
||||
|
||||
Reference in New Issue
Block a user