api

package
v0.0.0-...-a7839fa Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

API represents all APIs of Alertmanager.

func New

func New(opts Options) (*API, error)

New creates a new API object combining all API versions. Note that an Update call is also needed to get the APIs into an operational state.

func (*API) Register

func (api *API) Register(r *route.Router, routePrefix string) *http.ServeMux

Register all APIs. It registers APIv1 with the provided router directly. As APIv2 works on the http.Handler level, this method also creates a new http.ServeMux and then uses it to register both the provided router (to handle "/") and APIv2 (to handle "<routePrefix>/api/v2"). The method returns the newly created http.ServeMux. If a timeout has been set on construction of API, it is enforced for all HTTP request going through this mux. The same is true for the concurrency limit, with the exception that it is only applied to GET requests.

func (*API) Update

func (api *API) Update(cfg *config.Config, setAlertStatus func(model.LabelSet))

Update config and resolve timeout of each API. APIv2 also needs setAlertStatus to be updated.

type Options

type Options struct {
	// Alerts to be used by the API. Mandatory.
	Alerts provider.Alerts
	// Silences to be used by the API. Mandatory.
	Silences *silence.Silences
	// StatusFunc is used be the API to retrieve the AlertStatus of an
	// alert. Mandatory.
	StatusFunc func(model.Fingerprint) types.AlertStatus
	// Peer from the gossip cluster. If nil, no clustering will be used.
	Peer cluster.ClusterPeer
	// Timeout for all HTTP connections. The zero value (and negative
	// values) result in no timeout.
	Timeout time.Duration
	// Concurrency limit for GET requests. The zero value (and negative
	// values) result in a limit of GOMAXPROCS or 8, whichever is
	// larger. Status code 503 is served for GET requests that would exceed
	// the concurrency limit.
	Concurrency int
	// Logger is used for logging, if nil, no logging will happen.
	Logger log.Logger
	// Registry is used to register Prometheus metrics. If nil, no metrics
	// registration will happen.
	Registry prometheus.Registerer
	// GroupFunc returns a list of alert groups. The alerts are grouped
	// according to the current active configuration. Alerts returned are
	// filtered by the arguments provided to the function.
	GroupFunc func(func(*dispatch.Route) bool, func(*types.Alert, time.Time) bool) (dispatch.AlertGroups, map[model.Fingerprint][]string)
}

Options for the creation of an API object. Alerts, Silences, and StatusFunc are mandatory to set. The zero value for everything else is a safe default.

Directories

Path Synopsis
v2
restapi
Package restapi Alertmanager API API of the Prometheus Alertmanager (https://github.com/prometheus/alertmanager) Schemes: http Host: localhost BasePath: /api/v2/ Version: 0.0.1 License: Apache 2.0 http://www.apache.org/licenses/LICENSE-2.0.html Consumes: - application/json Produces: - application/json swagger:meta
Package restapi Alertmanager API API of the Prometheus Alertmanager (https://github.com/prometheus/alertmanager) Schemes: http Host: localhost BasePath: /api/v2/ Version: 0.0.1 License: Apache 2.0 http://www.apache.org/licenses/LICENSE-2.0.html Consumes: - application/json Produces: - application/json swagger:meta

Jump to

Keyboard shortcuts

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