health

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

README

Nurse healthcheck service

nurse leverages Go's pprof tooling to monitor various system and application metrics. The operator can configure per-resource thresholds which, when surpassed, trigger the gathering of a suite of metrics which are then dumped to disk along with a nurse.log file describing the reason for the dump.

To enable nurse, set the NURSE_TOML_PATH environment variable and create a nurse.toml file with the following schema:

profile-root           = "/tmp/nurse" # where the profiles will be dumped
poll-interval          = "1m"         # frequency with which to check thresholds
gather-duration        = "60s"        # how long to gather samples when profiling
max-profile-size       = "100mb"      # maximum size of the profile
cpu-profile-rate       = "5"          # samples per second
mem-profile-rate       = "5"          # samples per second
block-profile-rate     = "..."        # samples per second
mutex-profile-fraction = "..."        # fraction of mutex events that are reports (1 / rate)
mem-threshold          = "..."        # maximum memory usage of the process before a dump is triggered
goroutine-threshold    = "..."        # maximum number of goroutines before a dump is triggered

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckFunc

type CheckFunc func() (unwell bool, meta Meta)

type Meta

type Meta map[string]any

type Nurse

type Nurse struct {
	log.Logger
	// contains filtered or unexported fields
}

func NewNurse

func NewNurse(cfg NurseConfig) *Nurse

func (*Nurse) AddCheck

func (n *Nurse) AddCheck(reason string, checkFunc CheckFunc)

func (*Nurse) Close

func (n *Nurse) Close() error

func (*Nurse) GatherVitals

func (n *Nurse) GatherVitals(reason string, meta Meta)

func (*Nurse) Start

func (n *Nurse) Start() error

type NurseConfig

type NurseConfig struct {
	ProfileRoot          string         `toml:"profile-root"`
	PollInterval         time.Duration  `toml:"poll-interval"`
	GatherDuration       time.Duration  `toml:"gather-duration"`
	MaxProfileSize       utils.ByteSize `toml:"max-profile-size"`
	CPUProfileRate       int            `toml:"cpu-profile-rate"`
	MemProfileRate       int            `toml:"mem-profile-rate"`
	BlockProfileRate     int            `toml:"block-profile-rate"`
	MutexProfileFraction int            `toml:"mutex-profile-fraction"`
	MemThreshold         utils.ByteSize `toml:"mem-threshold"`
	GoroutineThreshold   int            `toml:"goroutine-threshold"`

	Logger log.Logger `toml:"-"`
}

func MustReadConfigTOML

func MustReadConfigTOML(path string) NurseConfig

func ReadConfigTOML

func ReadConfigTOML(path string) (NurseConfig, error)

Jump to

Keyboard shortcuts

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