api

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 18 Imported by: 49

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 API. 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 added in v0.17.0

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.

type V1DeprecationRouter added in v0.27.0

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

V1DeprecationRouter is the router to signal v1 users that the API v1 is now removed.

func NewV1DeprecationRouter added in v0.27.0

func NewV1DeprecationRouter(l log.Logger) *V1DeprecationRouter

NewV1DeprecationRouter returns a new V1DeprecationRouter.

func (*V1DeprecationRouter) Register added in v0.27.0

func (dr *V1DeprecationRouter) Register(r *route.Router)

Register registers all the API v1 routes with an endpoint that returns a JSON deprecation notice and a logs a warning.

Jump to

Keyboard shortcuts

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