diff --git a/sysdb/store.go b/sysdb/store.go
index 4e78d44f6633737cc9f9d1d422169f895493e1ea..73fe0b530c73cdf5d194c2d7de0dc8b8ecf5c8de 100644 (file)
--- a/sysdb/store.go
+++ b/sysdb/store.go
// sequence of decimal numbers with a unit suffix).
type Duration time.Duration
+// Common durations. All values greater than or equal to a day are not exact
+// values but subject to daylight savings time changes, leap years, etc. They
+// are available mostly for providing human readable display formats.
const (
Second = Duration(1000000000)
Minute = 60 * Second
Year = Duration(3652425 * 24 * 60 * 60 * 100000)
)
-// MarshalJSON implements the json.Marshaler interface. The time is a quoted
-// string in the SysDB JSON format.
+// MarshalJSON implements the json.Marshaler interface. The duration is a
+// quoted string in the SysDB JSON format.
func (d Duration) MarshalJSON() ([]byte, error) {
if d == 0 {
return []byte(`"0s"`), nil
// (YYYY-MM-DD hh:mm:ss +-zzzz).
type Time time.Time
+// MarshalJSON implements the json.Marshaler interface. The time is a quoted
+// string in the SysDB JSON format.
func (t Time) MarshalJSON() ([]byte, error) {
return []byte(time.Time(t).Format(jsonTime)), nil
}
// A Metric describes a metric known to SysDB.
type Metric struct {
Name string `json:"name"`
+ Timeseries bool `json:"timeseries"`
LastUpdate Time `json:"last_update"`
UpdateInterval Duration `json:"update_interval"`
Backends []string `json:"backends"`
// A DataPoint describes a datum at a certain point of time.
type DataPoint struct {
Timestamp Time `json:"timestamp"`
- Value float64 `json:"value"`
+ Value float64 `json:"value,string"`
}
// A Timeseries describes a sequence of data-points.
type Timeseries struct {
- Start Time `json:"start"`
- End Time `json:"end"`
- Data map[string][]DataPoint
+ Start Time `json:"start"`
+ End Time `json:"end"`
+ Data map[string][]DataPoint `json:"data"`
}
// vim: set tw=78 sw=4 sw=4 noexpandtab :