diff --git a/README.md b/README.md index ace9b46..3c8833e 100644 --- a/README.md +++ b/README.md @@ -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)\" }] }" # ... diff --git a/float.go b/float.go index 818661a..df1336c 100644 --- a/float.go +++ b/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, ']') diff --git a/metric-store.go b/metric-store.go index 358ae5d..01ef0fd 100644 --- a/metric-store.go +++ b/metric-store.go @@ -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 { diff --git a/selector.go b/selector.go index 55577b8..a2ff52e 100644 --- a/selector.go +++ b/selector.go @@ -114,5 +114,5 @@ func (l *level) findBuffers(selector Selector, offset int, f func(b *buffer) err return nil } - panic("impossible") + return nil }