Fix: specific entry unmarshal
This commit is contained in:
parent
b17711ed99
commit
bd28c2c1bc
|
@ -1,12 +1,31 @@
|
||||||
package loki
|
package loki
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
type Entry struct {
|
type Entry struct {
|
||||||
Timestamp time.Time
|
Timestamp time.Time
|
||||||
Line string
|
Line string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *Entry) UnmarshalJSON(b []byte) error {
|
||||||
|
var values []string
|
||||||
|
err := json.Unmarshal(b, &values)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
t, err := strconv.Atoi(values[0])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
e.Timestamp = time.Unix(int64(t), 0)
|
||||||
|
e.Line = values[1]
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type Stream struct {
|
type Stream struct {
|
||||||
Stream map[string]string `json:"stream"`
|
Stream map[string]string `json:"stream"`
|
||||||
Entries []Entry `json:"values"`
|
Entries []Entry `json:"values"`
|
||||||
|
|
Loading…
Reference in a new issue