mirror of
https://github.com/ClusterCockpit/cc-metric-store.git
synced 2024-12-26 16:59:07 +01:00
fix NaN too null conversion and restore duration
This commit is contained in:
parent
371afe5ab5
commit
407e650745
@ -129,7 +129,7 @@ JWT="eyJ0eXAiOiJKV1QiLCJhbGciOiJFZERTQSJ9.eyJ1c2VyIjoiYWRtaW4iLCJyb2xlcyI6WyJST0
|
||||
# If the collector and store and nats-server have been running for at least 60 seconds on the same host, you may run:
|
||||
curl -H "Authorization: Bearer $JWT" -D - "http://localhost:8080/api/query" -d "{ \"cluster\": \"testcluster\", \"from\": $(expr $(date +%s) - 60), \"to\": $(date +%s), \"queries\": [{
|
||||
\"metric\": \"load_one\",
|
||||
\"hostname\": \"$(hostname)\"
|
||||
\"host\": \"$(hostname)\"
|
||||
}] }"
|
||||
|
||||
# ...
|
||||
|
11
float.go
11
float.go
@ -46,11 +46,16 @@ type FloatArray []Float
|
||||
func (fa FloatArray) MarshalJSON() ([]byte, error) {
|
||||
buf := make([]byte, 0, 2+len(fa)*8)
|
||||
buf = append(buf, '[')
|
||||
if len(fa) > 0 {
|
||||
buf = strconv.AppendFloat(buf, float64(fa[0]), 'f', 1, 32)
|
||||
for i := 1; i < len(fa); i++ {
|
||||
for i := 0; i < len(fa); i++ {
|
||||
if i != 0 {
|
||||
buf = append(buf, ',')
|
||||
}
|
||||
|
||||
if fa[i].IsNaN() {
|
||||
buf = append(buf, `null`...)
|
||||
} else {
|
||||
buf = strconv.AppendFloat(buf, float64(fa[i]), 'f', 1, 32)
|
||||
|
||||
}
|
||||
}
|
||||
buf = append(buf, ']')
|
||||
|
@ -157,7 +157,7 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
restoreFrom := startupTime.Add(d)
|
||||
restoreFrom := startupTime.Add(-d)
|
||||
log.Printf("Loading checkpoints newer than %s\n", restoreFrom.Format(time.RFC3339))
|
||||
files, err := memoryStore.FromCheckpoint(conf.Checkpoints.RootDir, restoreFrom.Unix())
|
||||
if err != nil {
|
||||
|
@ -114,5 +114,5 @@ func (l *level) findBuffers(selector Selector, offset int, f func(b *buffer) err
|
||||
return nil
|
||||
}
|
||||
|
||||
panic("impossible")
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user