Documentation
¶
Overview ¶
Package adminhealth builds the read-only "is everything OK?" summary for the admin home: firing alerts (Alertmanager), the kill switch, Rivian call health over the last 24 h, streaming vs leased vehicles, disk, backup age and version.
Every section is independent and degrades to {"status":"unavailable"} with a short reason; nothing here can turn the endpoint into a 500. The two outside sources (Alertmanager, Prometheus) are reached only at URLs from the environment, with fixed paths and fixed queries (no caller input reaches them), a short timeout and a capped response size.
Index ¶
Constants ¶
const ( OK = "ok" )
Status of one section.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
DB *sql.DB
Flags *flags.Store
Version string
AlertmanagerURL string // e.g. http://alertmanager-operated.monitoring:9093
PrometheusURL string // e.g. http://prometheus-operated.monitoring:9090
// Namespace scopes the database disk and backup queries to this
// release's cluster (default "rivolt").
Namespace string
Client *http.Client // nil: a client with a short timeout
}
Config wires the sources. Empty URLs mean "not configured": the sections that need them read unavailable.
type KillSwitch ¶
type Rivian ¶
type Rivian struct {
Section
Window string `json:"window"`
// Results counts Rivian calls by outcome class over the window.
Results map[string]float64 `json:"results"`
// ErrorRate is the share of calls that were not "success" (0..1); null
// when there were no calls.
ErrorRate *float64 `json:"error_rate"`
// BreakerState: 0 closed, 1 half open, 2 open (worst across pods).
BreakerState *float64 `json:"breaker_state"`
BreakerTrips map[string]float64 `json:"breaker_trips"`
RateLimited map[string]float64 `json:"rate_limited"`
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service computes summaries, caching one for a few seconds so a refreshing admin page cannot hammer Alertmanager or Prometheus.
type Summary ¶
type Summary struct {
GeneratedAt time.Time `json:"generated_at"`
Version string `json:"version"`
Alerts Alerts `json:"alerts"`
KillSwitch KillSwitch `json:"kill_switch"`
Rivian Rivian `json:"rivian"`
Vehicles Vehicles `json:"vehicles"`
Disk Disk `json:"disk"`
Backup Backup `json:"backup"`
}
Summary is the response body.