Documentation
¶
Overview ¶
Package health is the controller's central health layer (§5.6): it checks every routed service end to end through Traefik, derives service health from task state and those checks, records uptime, and opens and closes incidents. State lives in memory; only incident transitions are stored.
Index ¶
Constants ¶
const ( Healthy = "healthy" Degraded = "degraded" Down = "down" Deploying = "deploying" Stopped = "stopped" // TopicHealth carries a ServiceHealth when a service's state changes. TopicHealth = "service.health" )
Service health states.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Check ¶
type Check struct {
At time.Time `json:"at"`
OK bool `json:"ok"`
Status int `json:"status"`
LatencyMs float64 `json:"latencyMs"`
Error string `json:"error,omitempty"`
URL string `json:"url"`
}
Check is one end-to-end probe result.
type Config ¶
type Config struct {
// BaseDomain returns the base domain ("" in development).
BaseDomain func() string
// HTTPAddr and HTTPSAddr are where Traefik listens on this host.
HTTPAddr, HTTPSAddr string
// VictoriaMetricsURL stores check samples for 7d/30d uptime ("" disables).
VictoriaMetricsURL string
// ProbeToken marks probes so Traefik keeps them out of the services'
// traffic (traefik.Provider.ProbeToken).
ProbeToken string
}
Config wires the monitor to the platform.
type LatencyPoint ¶
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
func (*Monitor) List ¶
func (m *Monitor) List(ctx context.Context) ([]ServiceHealth, error)
List returns every service's health, with 7d/30d uptime from VictoriaMetrics.
func (*Monitor) RunTaskProbes ¶
RunTaskProbes probes every running task until ctx ends.
func (*Monitor) TaskCheckOf ¶
TaskCheckOf returns the controller's latest probe of a task.
func (*Monitor) TaskReachable ¶
TaskReachable reports whether routing may use a task: true unless the controller failed to reach it three times in a row.
type ServiceHealth ¶
type ServiceHealth struct {
ServiceID string `json:"serviceId"`
Project string `json:"project"`
Environment string `json:"environment"`
Service string `json:"service"`
State string `json:"state"`
Reason string `json:"reason"`
Serving int `json:"serving"`
Desired int `json:"desired"`
Uptime24h *float64 `json:"uptime24h"` // percent; nil without checks
Uptime7d *float64 `json:"uptime7d"`
Uptime30d *float64 `json:"uptime30d"`
LastCheck *Check `json:"lastCheck"`
Latency []LatencyPoint `json:"latency"` // last hour, for sparklines
Incident *store.Incident `json:"incident"`
}
ServiceHealth is a service's current health for the API.