Documentation
¶
Overview ¶
Package health provides system health metrics collection and reporting.
Index ¶
Constants ¶
const MAX_WINDOW_SECONDS = 900
MAX_WINDOW_SECONDS is the maximum number of samples to keep in memory (15 minutes, as used by the Report type)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector is used to sample and store system metrics for reporting rolling averages over a period of time.
func NewCollector ¶
NewCollector creates a new metrics Collector. @param internval - the number of seconds between samples, zero means 5 secs.
func (Collector) Averages ¶
Averages returns a Metrics struct containing the averages of each metric over the sampling window `windowSeconds`.
func (*Collector) Sample ¶
Sample adds a sample to the Collector metrics, and unshifts the relevant slices if the window size is reached.
type Metrics ¶
type Metrics struct {
// CPU Usage (percentage)
CPUUsage float64 `json:"cpu_usage"`
CPUCoreUsage []float64 `json:"cpu_core_usage"`
// Memory Usage (percentage)
MemoryUsage float64 `json:"memory_usage"`
// Network I/O (bytes)
NetworkBytesSent float64 `json:"network_bytes_sent"`
NetworkBytesReceived float64 `json:"network_bytes_received"`
// Disk Usage (percentage)
DiskUsed float64 `json:"disk_used"`
DiskInodesUsed float64 `json:"disk_inodes_used"`
// Disk I/O (bytes)
DiskBytesRead float64 `json:"disk_bytes_read"`
DiskBytesWritten float64 `json:"disk_bytes_written"`
}
Metrics holds metrics averages for a period of time e.g. last 1 minute
type Report ¶
type Report struct {
InstanceID string
Version string `json:"version"`
Timestamp time.Time `json:"timestamp"`
Count int `json:"count"`
Started time.Time `json:"started"`
WindowStart time.Time `json:"window_start"`
WindowEnd time.Time `json:"window_end"`
Uptime uint64 `json:"uptime"`
OneMinute Metrics `json:"one_minute"`
FiveMinutes Metrics `json:"five_minutes"`
FifteenMinutes Metrics `json:"fifteen_minutes"`
Files map[string]string `json:"files"`
TerminationNotice *TerminationNotice `json:"termination_notice,omitempty"`
ConfigHash string `json:"config_hash,omitempty"` // Runtime config hash
}
Report hold a report of metrics to be serialised to JSON by JSONPusher
type ReportConfig ¶
type ReportConfig struct {
InstanceID string
RecvDir string
IdentityDir string // Path to identity directory for reading config.hash
// GetTerminationNotice returns the current spot termination notice, if any
GetTerminationNotice func() *TerminationNotice
}
ReportConfig provides the runtime config required to build metrics reports.
type TerminationNotice ¶
type TerminationNotice struct {
Action string `json:"action"`
Deadline time.Time `json:"deadline,omitempty"`
}
TerminationNotice represents a spot instance termination notice