Skip to content

Commit

Permalink
fix: get metrics failed if values contain NaN
Browse files Browse the repository at this point in the history
feat: set retention time to 2h to reduce memory usage of prometheus

Signed-off-by: Feng Kun <[email protected]>
  • Loading branch information
kevinfeng authored and QianChenglong committed Mar 26, 2020
1 parent 8609e2f commit 2adf668
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/monitor/storage/thanos/metric/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package metric
import (
"context"
"fmt"
"math"
"strings"
"time"
"tkestack.io/tke/api/monitor"
Expand Down Expand Up @@ -222,7 +223,9 @@ func MergeResult(results model.Matrix, timestamp string, groupByWithoutTimestamp
}
}
values[index].([]interface{})[0] = sp.Timestamp.Unix() * 1000
values[index].([]interface{})[fieldIndex+1] = float64(sp.Value)
if !math.IsNaN(float64(sp.Value)) {
values[index].([]interface{})[fieldIndex+1] = float64(sp.Value)
}
for j, tag := range tags {
values[index].([]interface{})[len(fieldIndexes)+1+j] = tag
}
Expand Down
1 change: 1 addition & 0 deletions pkg/platform/controller/addon/prometheus/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,7 @@ func createPrometheusCRD(components images.Components, clusterName string, remot
ScrapeInterval: "60s",
RemoteRead: remoteReadSpecs,
RemoteWrite: remoteWriteSpecs,
Retention: "2h",
EvaluationInterval: "1m",
AdditionalScrapeConfigs: &corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{Name: prometheusSecret},
Expand Down

0 comments on commit 2adf668

Please sign in to comment.