carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package metrics
2
3import "time"
4
5// HostSample is one point-in-time reading of whole-host resource usage.
6// Every field is a pointer because a missing reading (a parser in parse.go
7// returning nil) must stay distinguishable from a real zero all the way out
8// to whatever renders or alerts on it.
9type HostSample struct {
10 CPUFrac *float64 `json:"cpu"`
11 Load1 *float64 `json:"load1"`
12 Load5 *float64 `json:"load5"`
13 Load15 *float64 `json:"load15"`
14 MemFrac *float64 `json:"mem"`
15 DiskFrac *float64 `json:"disk"`
16}
17
18// UnitSample is one point-in-time reading for a single systemd unit's
19// cgroup. ReadBytes and WriteBytes are cumulative counters (not deltas) —
20// callers wanting a rate diff consecutive samples themselves.
21type UnitSample struct {
22 CPUFrac *float64 `json:"cpu"`
23 MemBytes *int64 `json:"mem_bytes"`
24 MemPeakBytes *int64 `json:"mem_peak_bytes"`
25 ReadBytes *int64 `json:"read_bytes"` // cumulative
26 WriteBytes *int64 `json:"write_bytes"` // cumulative
27}
28
29// Sample is one point-in-time reading of a box: the host as a whole plus
30// every monitored unit, keyed by unit name: systemd unit names (e.g.
31// carlos-app@x.example.com.service) and delegated exec-child cgroup names
32// (e.g. carlos-exec@x.example.com — no .service suffix; written by the
33// sampler's exec-subtree scan since exec-child accounting).
34type Sample struct {
35 At time.Time `json:"at"`
36 Host HostSample `json:"host"`
37 Units map[string]UnitSample `json:"units"`
38}
39
40// RawChunk is an hour's worth of raw samples for one box, the unit of
41// storage under metrics/boxes/<box>/raw/. V is the wire-shape version (1
42// today); Hour is UTC, formatted 2006-01-02-15.
43type RawChunk struct {
44 V int `json:"v"` // 1
45 Box string `json:"box"`
46 Hour string `json:"hour"` // UTC, 2006-01-02-15
47 Samples []Sample `json:"samples"`
48}
49