Persist time series viewer metrics (#1752)

* WIP persisting time series viewer metrics. Closes #1478

* Remove unused var, move around initial collection
This commit is contained in:
Gabe Kangas
2022-03-06 19:43:57 -08:00
committed by GitHub
parent 1f05783d9a
commit 1ed1cc01eb
6 changed files with 69 additions and 21 deletions

View File

@@ -1,8 +1,21 @@
package metrics
import "time"
import (
"time"
"github.com/nakabonne/tstorage"
)
type timestampedValue struct {
Time time.Time `json:"time"`
Value int `json:"value"`
}
func makeTimestampedValuesFromDatapoints(dp []*tstorage.DataPoint) []timestampedValue {
tv := []timestampedValue{}
for _, d := range dp {
tv = append(tv, timestampedValue{Time: time.Unix(d.Timestamp, 0), Value: int(d.Value)})
}
return tv
}