Documentation
¶
Overview ¶
Package status computes the public status pages from what Beacon already has: the pages' definitions in the catalogue (catalog.StatusPage), the probes' results in VictoriaMetrics (history.go), the alert groups as incidents, and the maintenance windows. Package web serves them as HTML, JSON, an Atom feed and badges, without signing in; the API and MCP hand agents the same JSON.
A component's state now is the worst of: a maintenance window on its services; the incidents firing on them (ServiceDown is down, the other availability alerts degraded); and the probes' agreement in the last minutes, by the reference rules' logic. So the page never says a service works while an alert about it fires, and shows a failure the probes agree on a minute or two before the alert, which waits to be sure. Its history is 90 days of that agreement, minute by minute, with the incidents and the maintenance windows laid over it.
Index ¶
- Constants
- Variables
- func Lang(p catalog.StatusPage, want string) string
- type Announcement
- type Component
- type Day
- type Deps
- type Group
- type Incident
- type Links
- type Page
- type Publication
- type PublicationNote
- type Querier
- type Service
- func (s *Service) ByHost(host string) (catalog.StatusPage, bool)
- func (s *Service) Def(name string) (catalog.StatusPage, bool)
- func (s *Service) Page(ctx context.Context, name, lang string) (*Page, error)
- func (s *Service) Pages() []catalog.StatusPage
- func (s *Service) Run(ctx context.Context)
- func (s *Service) URL(def catalog.StatusPage, file string) string
- func (s *Service) UpdateSettings(publicURL string, loc *time.Location, vm Querier)
- type Update
- type Window
Constants ¶
const ( Operational = "operational" Degraded = "degraded" Down = "down" Maintenance = "maintenance" NoData = "no_data" )
The states a component, a day or a page is in, as the JSON names them.
const (
// Days is how many days a page's history holds, today included.
Days = 90
)
Variables ¶
var ErrNotFound = errors.New("no such status page")
ErrNotFound means there is no such page, incident or component.
Functions ¶
Types ¶
type Announcement ¶
type Announcement struct {
Title string `json:"title"`
Body string `json:"body,omitempty"`
Style string `json:"style"` // info, warning, danger, success
}
Announcement is a note pinned to the top of a page.
type Component ¶
type Component struct {
Name string `json:"name"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Group string `json:"group,omitempty"` // the title of its group
Status string `json:"status"`
Availability *float64 `json:"availability,omitempty"` // percent over the history, without maintenance; none without data
History []Day `json:"history"` // oldest first, today last
// contains filtered or unexported fields
}
Component is one line of the page.
type Day ¶
type Day struct {
Date string `json:"date"` // YYYY-MM-DD
Status string `json:"status"`
Availability *float64 `json:"availability,omitempty"`
DownMinutes int `json:"down_minutes,omitempty"`
DegradedMinutes int `json:"degraded_minutes,omitempty"`
Incidents []string `json:"incidents,omitempty"` // ids
Maintenance bool `json:"maintenance,omitempty"`
}
Day is one day of a component's history. Availability is the share of the minutes with data, outside maintenance, that were not down.
type Deps ¶
type Deps struct {
Config *configdb.Service
Bridge *bridge.Bridge
Store *store.Store
VM Querier
PublicURL string
Location *time.Location
Log *slog.Logger
Now func() time.Time
}
Deps are what the pages are made from. VM may be nil (then there is no probe data); PublicURL is where Beacon is, for the pages' links; Location is where days begin.
type Group ¶
type Group struct {
Title string `json:"title"`
Description string `json:"description,omitempty"`
Components []string `json:"components"`
}
Group puts components under a heading.
type Incident ¶
type Incident struct {
ID string `json:"id"`
Title string `json:"title"`
Status string `json:"status"` // active or resolved
Impact string `json:"impact"` // down or degraded
Components []string `json:"components"`
Started time.Time `json:"started"`
Resolved *time.Time `json:"resolved,omitempty"`
URL string `json:"url"`
Updates []Update `json:"updates"`
}
Incident is an alert group on the page's components: what it did to them (Impact: down or degraded), when, and its updates, the newest first.
type Links ¶
type Links struct {
Feed string `json:"feed"`
JSON string `json:"json"`
Badge string `json:"badge"`
Home string `json:"home,omitempty"`
Docs string `json:"docs,omitempty"`
Abuse string `json:"abuse,omitempty"`
Privacy string `json:"privacy,omitempty"`
}
Links are where the page points people.
type Page ¶
type Page struct {
Name string `json:"name"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
URL string `json:"url"`
Language string `json:"language"`
Languages []string `json:"languages"`
Status string `json:"status"`
Summary string `json:"summary"`
Updated time.Time `json:"updated"`
Days int `json:"days"` // how many days the history holds
Timezone string `json:"timezone"` // the days begin at midnight here
Locations []string `json:"locations"` // where the probes check from, by public name
Components []Component `json:"components"`
Groups []Group `json:"groups"`
Incidents []Incident `json:"incidents"`
Maintenance []Window `json:"maintenance"`
Links Links `json:"links"`
// Logo, Footer and Pinned are the page's own: an image for its header, a line for its foot, and an
// announcement at its top.
Logo string `json:"logo,omitempty"`
Pinned *Announcement `json:"pinned,omitempty"`
// contains filtered or unexported fields
}
Page is a status page as the public JSON, the HTML and the agents' API show it: the state of each component now and over the last 90 days, the incidents (active, then those of the last 30 days) and the maintenance windows (active and scheduled, then those of the last 30 days). Its shape is stable: fields are added, never changed or removed. Texts are in Language.
type Publication ¶
type Publication struct {
Windows []Window
Notes []PublicationNote
Revision uint64
}
Publication holds the newly visible content and the revision the publication must check.
type PublicationNote ¶
PublicationNote is an existing incident update the proposed page would newly disclose.
type Querier ¶
type Querier interface {
QueryRange(ctx context.Context, query string, start, end time.Time, step time.Duration) ([]vm.Series, error)
}
Querier is what the pages need of VictoriaMetrics; *vm.Client has it.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service computes the pages and keeps them for a little while.
func (*Service) ByHost ¶
func (s *Service) ByHost(host string) (catalog.StatusPage, bool)
ByHost returns the definition of the page served at host.
func (*Service) Def ¶
func (s *Service) Def(name string) (catalog.StatusPage, bool)
Def returns the definition of the page called name; "" is the default page.
func (*Service) Page ¶
Page returns the page called name in the language asked for ("": the page's default), computed at most cacheFor ago.
func (*Service) Pages ¶
func (s *Service) Pages() []catalog.StatusPage
Pages are the definitions of every page, sorted by name.
func (*Service) Run ¶
Run keeps the incidents and the probes' history up to date, so that pages are quick and an incident outlives its alert group.
func (*Service) URL ¶
func (s *Service) URL(def catalog.StatusPage, file string) string
URL is the address of a page's file ("" the page, ".json" its JSON, "feed.atom", "badge.svg", "incidents/<id>", "components/<name>/badge.svg"): on the page's own host when it has one, else under /status where Beacon is.
type Update ¶
type Update struct {
At time.Time `json:"at"`
Kind string `json:"kind"` // detected, acknowledged, note, resolved
Text string `json:"text"`
By string `json:"by,omitempty"` // agent or person, for a note
}
Update is one step of an incident: detected, acknowledged, a note (By says whether an agent or a person left it), resolved.
type Window ¶
type Window struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Status string `json:"status"` // scheduled, active or completed
Components []string `json:"components"`
Starts time.Time `json:"starts"`
Ends time.Time `json:"ends"`
}
Window is a maintenance window on the page's components.