status

package
v0.3.0-rc.55 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
const (
	// Days is how many days a page's history holds, today included.
	Days = 90
)

Variables

View Source
var ErrNotFound = errors.New("no such status page")

ErrNotFound means there is no such page, incident or component.

Functions

func Lang

func Lang(p catalog.StatusPage, want string) string

Lang is the language a page is shown in when asked for want: want if the page has it, else its first.

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.

func (Component) Services

func (c Component) Services() []string

Services are the services the component's state is made from, as the configuration in force names them.

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 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.
	Footer string        `json:"footer,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.

func (*Page) Component

func (p *Page) Component(name string) (Component, bool)

Component returns the page's component called name.

func (*Page) Incident

func (p *Page) Incident(id string) (Incident, bool)

Incident returns the page's incident with id, as far back as the history reaches.

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

type PublicationNote struct {
	IncidentID, Title string
	Update            Update
}

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 New

func New(d Deps) *Service

New makes the service.

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

func (s *Service) Page(ctx context.Context, name, lang string) (*Page, error)

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

func (s *Service) Run(ctx context.Context)

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.

func (*Service) UpdateSettings

func (s *Service) UpdateSettings(publicURL string, loc *time.Location, vm Querier)

UpdateSettings updates PublicURL, timezone location and VictoriaMetrics querier, invalidating cached pages.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL