prober

package
v1.33.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2022 License: BSD-3-Clause Imports: 15 Imported by: 0

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

This section is empty.

Types

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.

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. If the URL is HTTPS, the probe further checks that the TLS certificate is good for at least the next 7 days.

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(hostname string) ProbeFunc

TLS returns a Probe that healthchecks a TLS endpoint.

The ProbeFunc connects to hostname, does a TLS handshake, verifies that the hostname matches the presented certificate, and that the certificate expires in more than 7 days from the probe time.

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

func (p *Prober) Expvar() expvar.Var

Expvar returns the metrics for running probes.

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.

Jump to

Keyboard shortcuts

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