package metrics import "time" // HostSample is one point-in-time reading of whole-host resource usage. // Every field is a pointer because a missing reading (a parser in parse.go // returning nil) must stay distinguishable from a real zero all the way out // to whatever renders or alerts on it. type HostSample struct { CPUFrac *float64 `json:"cpu"` Load1 *float64 `json:"load1"` Load5 *float64 `json:"load5"` Load15 *float64 `json:"load15"` MemFrac *float64 `json:"mem"` DiskFrac *float64 `json:"disk"` } // UnitSample is one point-in-time reading for a single systemd unit's // cgroup. ReadBytes and WriteBytes are cumulative counters (not deltas) — // callers wanting a rate diff consecutive samples themselves. type UnitSample struct { CPUFrac *float64 `json:"cpu"` MemBytes *int64 `json:"mem_bytes"` MemPeakBytes *int64 `json:"mem_peak_bytes"` ReadBytes *int64 `json:"read_bytes"` // cumulative WriteBytes *int64 `json:"write_bytes"` // cumulative } // Sample is one point-in-time reading of a box: the host as a whole plus // every monitored unit, keyed by unit name: systemd unit names (e.g. // carlos-app@x.example.com.service) and delegated exec-child cgroup names // (e.g. carlos-exec@x.example.com — no .service suffix; written by the // sampler's exec-subtree scan since exec-child accounting). type Sample struct { At time.Time `json:"at"` Host HostSample `json:"host"` Units map[string]UnitSample `json:"units"` } // RawChunk is an hour's worth of raw samples for one box, the unit of // storage under metrics/boxes//raw/. V is the wire-shape version (1 // today); Hour is UTC, formatted 2006-01-02-15. type RawChunk struct { V int `json:"v"` // 1 Box string `json:"box"` Hour string `json:"hour"` // UTC, 2006-01-02-15 Samples []Sample `json:"samples"` }