http

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2020 License: MIT Imports: 10 Imported by: 0

README

= HTTP plugin
:toc: macro

The HTTP plugin provides checks for HTTP services, and HTTP-based alerts.

== Checks

=== http.get

[source,goplum]
----
check http.get "example" {
  url = "https://www.example.com/"
  content = "Example Domain"
  content_expected = true
  certificate_validity = 10d
  auth {
    username = "acidburn"
    password = "HackThePlanet"
  }
}
----

Sends an HTTP GET request to the given URL. The check passes if a response is received with
an error code less than 400.

If the `content` parameter is specified then the response body is checked for the exact string.
By default the string must be present, and the check will fail if it is not. If `content_expected`
is set to `false` then the string must NOT be present, and the check will fail if it is.

If the `certificate_validity` parameter is specified, then the connection must have
been made over TLS, and the returned certificate must be valid for at least the given duration
from now. (An expired or untrusted certificate will cause a failure regardless of this setting.)

If the `auth` settings are provided, they will be sent in a Basic authentication header. Note
that basic authentication isn't encrypted, so shouldn't be used over an insecure connection.

=== http.healthcheck

[source,goplum]
----
check http.healthcheck "example" {
  url = "https://www.example.com/health"
  check_components = true
  auth {
    username = "acidburn"
    password = "HackThePlanet"
  }
}
----

Retrieves the current status from a HTTP healthcheck endpoint. The endpoint is expected
to return JSON in a manner compatible with
https://tools.ietf.org/id/draft-inadarei-api-health-check-04.html[draft-inadarei-api-health-check-04].

If the `check_components` setting is enabled, the state of each component/dependency
reported in the healthcheck response will also be verified. This means if the overall service
status is `pass` but a component is `fail` then the Goplum check will fail.

If the `auth` settings are provided, they will be sent in a Basic authentication header. Note
that basic authentication isn't encrypted, so shouldn't be used over an insecure connection.

== Alerts

=== http.webhook

[source,goplum]
----
alert http.webhook "example" {
  url = "https://www.example.com/incoming"
}
----

Sends alerts as a POST request to the given webhook URL with a JSON payload:

[source,json]
----
{
  "text": "Check 'Testing' is now good, was failing.",
  "name": "Testing",
  "type": "debug.random",
  "config": {
    "percent_good": 0.8
  },
  "last_result": {
    "state": "failing",
    "time": "2020-09-17T17:55:02.224973486+01:00",
    "detail": "Random value 0.813640 greater than percent_good 0.800000"
  },
  "previous_state": "failing",
  "new_state": "good"
}
----

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseCheck added in v0.3.0

type BaseCheck struct {
	Url  string
	Auth Credentials
}

type Credentials added in v0.3.0

type Credentials struct {
	Username string
	Password string
}

type GetCheck

type GetCheck struct {
	BaseCheck           `config:",squash"`
	Content             string
	ContentExpected     bool          `config:"content_expected"`
	CertificateValidity time.Duration `config:"certificate_validity"`
}

func (GetCheck) Execute

func (g GetCheck) Execute(ctx context.Context) goplum.Result

func (GetCheck) Validate added in v0.2.0

func (g GetCheck) Validate() error

type HealthCheck added in v0.3.0

type HealthCheck struct {
	BaseCheck       `config:",squash"`
	CheckComponents bool `config:"check_components"`
}

func (HealthCheck) Execute added in v0.3.0

func (h HealthCheck) Execute(ctx context.Context) goplum.Result

func (HealthCheck) Validate added in v0.3.0

func (h HealthCheck) Validate() error

type Plugin

type Plugin struct{}

func (Plugin) Alert added in v0.2.0

func (p Plugin) Alert(kind string) goplum.Alert

func (Plugin) Check added in v0.2.0

func (p Plugin) Check(kind string) goplum.Check

type WebHookAlert

type WebHookAlert struct {
	Url string
}

func (WebHookAlert) Send

func (w WebHookAlert) Send(details goplum.AlertDetails) error

func (WebHookAlert) Validate added in v0.2.0

func (w WebHookAlert) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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