health

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 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 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

View Source
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 LatencyPoint struct {
	At        int64   `json:"t"` // unix ms
	LatencyMs float64 `json:"ms"`
	OK        bool    `json:"ok"`
}

type Monitor

type Monitor struct {
	// contains filtered or unexported fields
}

func New

func New(st *store.Store, wl *workload.Manager, bus *events.Bus, log *slog.Logger, cfg Config) *Monitor

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) Run

func (m *Monitor) Run(ctx context.Context)

Run checks and evaluates every service until ctx ends.

func (*Monitor) RunTaskProbes

func (m *Monitor) RunTaskProbes(ctx context.Context)

RunTaskProbes probes every running task until ctx ends.

func (*Monitor) TaskCheckOf

func (m *Monitor) TaskCheckOf(taskID string) *TaskCheck

TaskCheckOf returns the controller's latest probe of a task.

func (*Monitor) TaskReachable

func (m *Monitor) TaskReachable(taskID string) bool

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.

type TaskCheck

type TaskCheck struct {
	State   string    `json:"state"` // ok | failing | unreachable
	Target  string    `json:"target"`
	Error   string    `json:"error,omitempty"`
	Fails   int       `json:"fails"`
	Checked time.Time `json:"checked"`
}

TaskCheck is the controller's view of one task.

Jump to

Keyboard shortcuts

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