prober

package
v1.62.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: BSD-3-Clause Imports: 36 Imported by: 5

Documentation

Overview

Package prober implements a simple blackbox prober. Each probe runs in its own goroutine, and run results are recorded as Prometheus metrics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DERP added in v1.34.0

func DERP(p *Prober, derpMapURL string, opts ...DERPOpt) (*derpProber, error)

DERP creates a new derpProber.

func SendAlert added in v1.34.0

func SendAlert(summary, details string) error

SendAlert sends an alert to the incident response system, to page a human responder immediately. summary should be short and state the nature of the emergency. details can be longer, up to 29 KBytes.

func SendWarning added in v1.34.0

func SendWarning(details string) error

SendWarning will post a message to Slack. details should be a description of the issue.

Types

type DERPOpt added in v1.62.0

type DERPOpt func(*derpProber)

func WithBandwidthProbing added in v1.62.0

func WithBandwidthProbing(interval time.Duration, size int64) DERPOpt

WithBandwidthProbing enables bandwidth probing. When enabled, a payload of `size` bytes will be regularly transferred through each DERP server, and each pair of DERP servers in every region.

func WithMeshProbing added in v1.62.0

func WithMeshProbing(interval time.Duration) DERPOpt

WithMeshProbing enables mesh probing. When enabled, a small message will be transferred through each DERP server and each pair of DERP servers.

func WithSTUNProbing added in v1.62.0

func WithSTUNProbing(interval time.Duration) DERPOpt

WithSTUNProbing enables STUN/UDP probing, with a STUN request being sent to each DERP server every `interval`.

func WithTLSProbing added in v1.62.0

func WithTLSProbing(interval time.Duration) DERPOpt

WithTLSProbing enables TLS probing that will check TLS certificate on port 443 of each DERP server every `interval`.

type Probe

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

Probe is a probe that healthchecks something and updates Prometheus metrics with the results.

func (*Probe) Close

func (p *Probe) Close() error

Close shuts down the Probe and unregisters it from its Prober. It is safe to Run a new probe of the same name after Close returns.

func (*Probe) Collect added in v1.40.0

func (p *Probe) Collect(ch chan<- prometheus.Metric)

Collect implements prometheus.Collector.

func (*Probe) Describe added in v1.40.0

func (p *Probe) Describe(ch chan<- *prometheus.Desc)

Describe implements prometheus.Collector.

type ProbeFunc

type ProbeFunc func(context.Context) error

ProbeFunc is a function that probes something and reports whether the probe succeeded. The provided context's deadline must be obeyed for correct probe scheduling.

func HTTP

func HTTP(url, wantText string) ProbeFunc

HTTP returns a Probe that healthchecks an HTTP URL.

The ProbeFunc sends a GET request for url, expects an HTTP 200 response, and verifies that want is present in the response body.

func TCP

func TCP(addr string) ProbeFunc

TCP returns a Probe that healthchecks a TCP endpoint.

The ProbeFunc reports whether it can successfully connect to addr.

func TLS

func TLS(hostPort string) ProbeFunc

TLS returns a Probe that healthchecks a TLS endpoint.

The ProbeFunc connects to a hostPort (host:port string), does a TLS handshake, verifies that the hostname matches the presented certificate, checks certificate validity time and OCSP revocation status.

func TLSWithIP added in v1.62.0

func TLSWithIP(certDomain string, dialAddr netip.AddrPort) ProbeFunc

TLSWithIP is like TLS, but dials the provided dialAddr instead of using DNS resolution. The certDomain is the expected name in the cert (and the SNI name to send).

type ProbeInfo added in v1.38.0

type ProbeInfo struct {
	Start   time.Time
	End     time.Time
	Latency string
	Result  bool
	Error   string
}

ProbeInfo is the state of a Probe.

type Prober

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

a Prober manages a set of probes and keeps track of their results.

func New

func New() *Prober

New returns a new Prober.

func (*Prober) ProbeInfo added in v1.38.0

func (p *Prober) ProbeInfo() map[string]ProbeInfo

func (*Prober) Run

func (p *Prober) Run(name string, interval time.Duration, labels map[string]string, fun ProbeFunc) *Probe

Run executes fun every interval, and exports probe results under probeName.

Registering a probe under an already-registered name panics.

func (*Prober) Wait added in v1.38.0

func (p *Prober) Wait()

Wait blocks until all probes have finished execution. It should typically be used with the `once` mode to wait for probes to finish before collecting their results.

func (*Prober) WithMetricNamespace added in v1.40.0

func (p *Prober) WithMetricNamespace(n string) *Prober

WithMetricNamespace allows changing metric name prefix from the default `prober`.

func (*Prober) WithOnce added in v1.38.0

func (p *Prober) WithOnce(s bool) *Prober

WithOnce mode can be used if you want to run all configured probes once rather than on a schedule.

func (*Prober) WithSpread added in v1.34.0

func (p *Prober) WithSpread(s bool) *Prober

WithSpread is used to enable random delay before the first run of each added probe.

Jump to

Keyboard shortcuts

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