api

package
v0.0.0-test Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2021 License: AGPL-3.0 Imports: 45 Imported by: 0

Documentation

Overview

Package api contains base API implementation of unified alerting

*
*Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*
*Do not manually edit these files, please find ngalert/api/swagger-codegen/ for commands on how to generate them.

Package api contains base API implementation of unified alerting

*
*Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*
*Do not manually edit these files, please find ngalert/api/swagger-codegen/ for commands on how to generate them.

Package api contains base API implementation of unified alerting

*
*Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*
*Do not manually edit these files, please find ngalert/api/swagger-codegen/ for commands on how to generate them.

Package api contains base API implementation of unified alerting

*
*Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*
*Do not manually edit these files, please find ngalert/api/swagger-codegen/ for commands on how to generate them.

Package api contains base API implementation of unified alerting

*
*Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*
*Do not manually edit these files, please find ngalert/api/swagger-codegen/ for commands on how to generate them.

Index

Constants

This section is empty.

Variables

View Source
var NotImplementedResp = ErrResp(http.StatusNotImplemented, errors.New("endpoint not implemented"), "")

Functions

func ErrResp

func ErrResp(status int, err error, msg string, args ...interface{}) *response.NormalResponse

ErrorResp creates a response with a visible error

Types

type API

type API struct {
	Cfg                  *setting.Cfg
	DatasourceCache      datasources.CacheService
	RouteRegister        routing.RouteRegister
	ExpressionService    *expr.Service
	QuotaService         *quota.QuotaService
	Schedule             schedule.ScheduleService
	RuleStore            store.RuleStore
	InstanceStore        store.InstanceStore
	AlertingStore        store.AlertingStore
	AdminConfigStore     store.AdminConfigurationStore
	DataProxy            *datasourceproxy.DataSourceProxyService
	MultiOrgAlertmanager *notifier.MultiOrgAlertmanager
	StateManager         *state.Manager
	SecretsService       secrets.Service
}

API handlers.

func (*API) RegisterAPIEndpoints

func (api *API) RegisterAPIEndpoints(m *metrics.API)

RegisterAPIEndpoints registers API handlers

func (*API) RegisterAlertmanagerApiEndpoints

func (api *API) RegisterAlertmanagerApiEndpoints(srv AlertmanagerApiService, m *metrics.API)

func (*API) RegisterConfigurationApiEndpoints

func (api *API) RegisterConfigurationApiEndpoints(srv ConfigurationApiService, m *metrics.API)

func (*API) RegisterPrometheusApiEndpoints

func (api *API) RegisterPrometheusApiEndpoints(srv PrometheusApiService, m *metrics.API)

func (*API) RegisterRulerApiEndpoints

func (api *API) RegisterRulerApiEndpoints(srv RulerApiService, m *metrics.API)

func (*API) RegisterTestingApiEndpoints

func (api *API) RegisterTestingApiEndpoints(srv TestingApiService, m *metrics.API)

type AdminSrv

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

func (AdminSrv) RouteDeleteNGalertConfig

func (srv AdminSrv) RouteDeleteNGalertConfig(c *models.ReqContext) response.Response

func (AdminSrv) RouteGetAlertmanagers

func (srv AdminSrv) RouteGetAlertmanagers(c *models.ReqContext) response.Response

func (AdminSrv) RouteGetNGalertConfig

func (srv AdminSrv) RouteGetNGalertConfig(c *models.ReqContext) response.Response

func (AdminSrv) RoutePostNGalertConfig

func (srv AdminSrv) RoutePostNGalertConfig(c *models.ReqContext, body apimodels.PostableNGalertConfig) response.Response

type AlertingProxy

type AlertingProxy struct {
	DataProxy *datasourceproxy.DataSourceProxyService
}

type Alertmanager

type Alertmanager interface {
	// Configuration
	SaveAndApplyConfig(config *apimodels.PostableUserConfig) error
	SaveAndApplyDefaultConfig() error
	GetStatus() apimodels.GettableStatus

	// Silences
	CreateSilence(ps *apimodels.PostableSilence) (string, error)
	DeleteSilence(silenceID string) error
	GetSilence(silenceID string) (apimodels.GettableSilence, error)
	ListSilences(filter []string) (apimodels.GettableSilences, error)

	// Alerts
	GetAlerts(active, silenced, inhibited bool, filter []string, receiver string) (apimodels.GettableAlerts, error)
	GetAlertGroups(active, silenced, inhibited bool, filter []string, receiver string) (apimodels.AlertGroups, error)

	// Testing
	TestReceivers(ctx context.Context, c apimodels.TestReceiversConfigParams) (*notifier.TestReceiversResult, error)
}

type AlertmanagerApiService

type AlertmanagerApiService interface {
	RouteCreateSilence(*models.ReqContext, apimodels.PostableSilence) response.Response
	RouteDeleteAlertingConfig(*models.ReqContext) response.Response
	RouteDeleteSilence(*models.ReqContext) response.Response
	RouteGetAMAlertGroups(*models.ReqContext) response.Response
	RouteGetAMAlerts(*models.ReqContext) response.Response
	RouteGetAMStatus(*models.ReqContext) response.Response
	RouteGetAlertingConfig(*models.ReqContext) response.Response
	RouteGetSilence(*models.ReqContext) response.Response
	RouteGetSilences(*models.ReqContext) response.Response
	RoutePostAMAlerts(*models.ReqContext, apimodels.PostableAlerts) response.Response
	RoutePostAlertingConfig(*models.ReqContext, apimodels.PostableUserConfig) response.Response
	RoutePostTestReceivers(*models.ReqContext, apimodels.TestReceiversConfigParams) response.Response
}

type AlertmanagerSrv

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

func (AlertmanagerSrv) AlertmanagerFor

func (srv AlertmanagerSrv) AlertmanagerFor(orgID int64) (Alertmanager, *response.NormalResponse)

func (AlertmanagerSrv) RouteCreateSilence

func (srv AlertmanagerSrv) RouteCreateSilence(c *models.ReqContext, postableSilence apimodels.PostableSilence) response.Response

func (AlertmanagerSrv) RouteDeleteAlertingConfig

func (srv AlertmanagerSrv) RouteDeleteAlertingConfig(c *models.ReqContext) response.Response

func (AlertmanagerSrv) RouteDeleteSilence

func (srv AlertmanagerSrv) RouteDeleteSilence(c *models.ReqContext) response.Response

func (AlertmanagerSrv) RouteGetAMAlertGroups

func (srv AlertmanagerSrv) RouteGetAMAlertGroups(c *models.ReqContext) response.Response

func (AlertmanagerSrv) RouteGetAMAlerts

func (srv AlertmanagerSrv) RouteGetAMAlerts(c *models.ReqContext) response.Response

func (AlertmanagerSrv) RouteGetAMStatus

func (srv AlertmanagerSrv) RouteGetAMStatus(c *models.ReqContext) response.Response

func (AlertmanagerSrv) RouteGetAlertingConfig

func (srv AlertmanagerSrv) RouteGetAlertingConfig(c *models.ReqContext) response.Response

func (AlertmanagerSrv) RouteGetSilence

func (srv AlertmanagerSrv) RouteGetSilence(c *models.ReqContext) response.Response

func (AlertmanagerSrv) RouteGetSilences

func (srv AlertmanagerSrv) RouteGetSilences(c *models.ReqContext) response.Response

func (AlertmanagerSrv) RoutePostAMAlerts

func (AlertmanagerSrv) RoutePostAlertingConfig

func (srv AlertmanagerSrv) RoutePostAlertingConfig(c *models.ReqContext, body apimodels.PostableUserConfig) response.Response

func (AlertmanagerSrv) RoutePostTestReceivers

type ConfigurationApiService

type ConfigurationApiService interface {
	RouteDeleteNGalertConfig(*models.ReqContext) response.Response
	RouteGetAlertmanagers(*models.ReqContext) response.Response
	RouteGetNGalertConfig(*models.ReqContext) response.Response
	RoutePostNGalertConfig(*models.ReqContext, apimodels.PostableNGalertConfig) response.Response
}

type ForkedAMSvc

type ForkedAMSvc struct {
	AMSvc, GrafanaSvc AlertmanagerApiService
	DatasourceCache   datasources.CacheService
}

func NewForkedAM

func NewForkedAM(datasourceCache datasources.CacheService, proxy, grafana AlertmanagerApiService) *ForkedAMSvc

NewForkedAM implements a set of routes that proxy to various Alertmanager-compatible backends.

func (*ForkedAMSvc) RouteCreateSilence

func (am *ForkedAMSvc) RouteCreateSilence(ctx *models.ReqContext, body apimodels.PostableSilence) response.Response

func (*ForkedAMSvc) RouteDeleteAlertingConfig

func (am *ForkedAMSvc) RouteDeleteAlertingConfig(ctx *models.ReqContext) response.Response

func (*ForkedAMSvc) RouteDeleteSilence

func (am *ForkedAMSvc) RouteDeleteSilence(ctx *models.ReqContext) response.Response

func (*ForkedAMSvc) RouteGetAMAlertGroups

func (am *ForkedAMSvc) RouteGetAMAlertGroups(ctx *models.ReqContext) response.Response

func (*ForkedAMSvc) RouteGetAMAlerts

func (am *ForkedAMSvc) RouteGetAMAlerts(ctx *models.ReqContext) response.Response

func (*ForkedAMSvc) RouteGetAMStatus

func (am *ForkedAMSvc) RouteGetAMStatus(ctx *models.ReqContext) response.Response

func (*ForkedAMSvc) RouteGetAlertingConfig

func (am *ForkedAMSvc) RouteGetAlertingConfig(ctx *models.ReqContext) response.Response

func (*ForkedAMSvc) RouteGetSilence

func (am *ForkedAMSvc) RouteGetSilence(ctx *models.ReqContext) response.Response

func (*ForkedAMSvc) RouteGetSilences

func (am *ForkedAMSvc) RouteGetSilences(ctx *models.ReqContext) response.Response

func (*ForkedAMSvc) RoutePostAMAlerts

func (am *ForkedAMSvc) RoutePostAMAlerts(ctx *models.ReqContext, body apimodels.PostableAlerts) response.Response

func (*ForkedAMSvc) RoutePostAlertingConfig

func (am *ForkedAMSvc) RoutePostAlertingConfig(ctx *models.ReqContext, body apimodels.PostableUserConfig) response.Response

func (*ForkedAMSvc) RoutePostTestReceivers

func (am *ForkedAMSvc) RoutePostTestReceivers(ctx *models.ReqContext, body apimodels.TestReceiversConfigParams) response.Response

type ForkedPromSvc

type ForkedPromSvc struct {
	ProxySvc, GrafanaSvc PrometheusApiService
	DatasourceCache      datasources.CacheService
}

func NewForkedProm

func NewForkedProm(datasourceCache datasources.CacheService, proxy, grafana PrometheusApiService) *ForkedPromSvc

NewForkedProm implements a set of routes that proxy to various Prometheus-compatible backends.

func (*ForkedPromSvc) RouteGetAlertStatuses

func (p *ForkedPromSvc) RouteGetAlertStatuses(ctx *models.ReqContext) response.Response

func (*ForkedPromSvc) RouteGetRuleStatuses

func (p *ForkedPromSvc) RouteGetRuleStatuses(ctx *models.ReqContext) response.Response

type ForkedRuler

type ForkedRuler struct {
	LotexRuler, GrafanaRuler RulerApiService
	DatasourceCache          datasources.CacheService
}

ForkedRuler will validate and proxy requests to the correct backend type depending on the datasource.

func NewForkedRuler

func NewForkedRuler(datasourceCache datasources.CacheService, lotex, grafana RulerApiService) *ForkedRuler

NewForkedRuler implements a set of routes that proxy to various Cortex Ruler-compatible backends.

func (*ForkedRuler) RouteDeleteNamespaceRulesConfig

func (r *ForkedRuler) RouteDeleteNamespaceRulesConfig(ctx *models.ReqContext) response.Response

func (*ForkedRuler) RouteDeleteRuleGroupConfig

func (r *ForkedRuler) RouteDeleteRuleGroupConfig(ctx *models.ReqContext) response.Response

func (*ForkedRuler) RouteGetNamespaceRulesConfig

func (r *ForkedRuler) RouteGetNamespaceRulesConfig(ctx *models.ReqContext) response.Response

func (*ForkedRuler) RouteGetRulegGroupConfig

func (r *ForkedRuler) RouteGetRulegGroupConfig(ctx *models.ReqContext) response.Response

func (*ForkedRuler) RouteGetRulesConfig

func (r *ForkedRuler) RouteGetRulesConfig(ctx *models.ReqContext) response.Response

func (*ForkedRuler) RoutePostNameRulesConfig

func (r *ForkedRuler) RoutePostNameRulesConfig(ctx *models.ReqContext, conf apimodels.PostableRuleGroupConfig) response.Response

type LotexAM

type LotexAM struct {
	*AlertingProxy
	// contains filtered or unexported fields
}

func NewLotexAM

func NewLotexAM(proxy *AlertingProxy, log log.Logger) *LotexAM

func (*LotexAM) RouteCreateSilence

func (am *LotexAM) RouteCreateSilence(ctx *models.ReqContext, silenceBody apimodels.PostableSilence) response.Response

func (*LotexAM) RouteDeleteAlertingConfig

func (am *LotexAM) RouteDeleteAlertingConfig(ctx *models.ReqContext) response.Response

func (*LotexAM) RouteDeleteSilence

func (am *LotexAM) RouteDeleteSilence(ctx *models.ReqContext) response.Response

func (*LotexAM) RouteGetAMAlertGroups

func (am *LotexAM) RouteGetAMAlertGroups(ctx *models.ReqContext) response.Response

func (*LotexAM) RouteGetAMAlerts

func (am *LotexAM) RouteGetAMAlerts(ctx *models.ReqContext) response.Response

func (*LotexAM) RouteGetAMStatus

func (am *LotexAM) RouteGetAMStatus(ctx *models.ReqContext) response.Response

func (*LotexAM) RouteGetAlertingConfig

func (am *LotexAM) RouteGetAlertingConfig(ctx *models.ReqContext) response.Response

func (*LotexAM) RouteGetSilence

func (am *LotexAM) RouteGetSilence(ctx *models.ReqContext) response.Response

func (*LotexAM) RouteGetSilences

func (am *LotexAM) RouteGetSilences(ctx *models.ReqContext) response.Response

func (*LotexAM) RoutePostAMAlerts

func (am *LotexAM) RoutePostAMAlerts(ctx *models.ReqContext, alerts apimodels.PostableAlerts) response.Response

func (*LotexAM) RoutePostAlertingConfig

func (am *LotexAM) RoutePostAlertingConfig(ctx *models.ReqContext, config apimodels.PostableUserConfig) response.Response

func (*LotexAM) RoutePostTestReceivers

func (am *LotexAM) RoutePostTestReceivers(ctx *models.ReqContext, config apimodels.TestReceiversConfigParams) response.Response

type LotexProm

type LotexProm struct {
	*AlertingProxy
	// contains filtered or unexported fields
}

func NewLotexProm

func NewLotexProm(proxy *AlertingProxy, log log.Logger) *LotexProm

func (*LotexProm) RouteGetAlertStatuses

func (p *LotexProm) RouteGetAlertStatuses(ctx *models.ReqContext) response.Response

func (*LotexProm) RouteGetRuleStatuses

func (p *LotexProm) RouteGetRuleStatuses(ctx *models.ReqContext) response.Response

type LotexRuler

type LotexRuler struct {
	*AlertingProxy
	// contains filtered or unexported fields
}

func NewLotexRuler

func NewLotexRuler(proxy *AlertingProxy, log log.Logger) *LotexRuler

func (*LotexRuler) RouteDeleteNamespaceRulesConfig

func (r *LotexRuler) RouteDeleteNamespaceRulesConfig(ctx *models.ReqContext) response.Response

func (*LotexRuler) RouteDeleteRuleGroupConfig

func (r *LotexRuler) RouteDeleteRuleGroupConfig(ctx *models.ReqContext) response.Response

func (*LotexRuler) RouteGetNamespaceRulesConfig

func (r *LotexRuler) RouteGetNamespaceRulesConfig(ctx *models.ReqContext) response.Response

func (*LotexRuler) RouteGetRulegGroupConfig

func (r *LotexRuler) RouteGetRulegGroupConfig(ctx *models.ReqContext) response.Response

func (*LotexRuler) RouteGetRulesConfig

func (r *LotexRuler) RouteGetRulesConfig(ctx *models.ReqContext) response.Response

func (*LotexRuler) RoutePostNameRulesConfig

func (r *LotexRuler) RoutePostNameRulesConfig(ctx *models.ReqContext, conf apimodels.PostableRuleGroupConfig) response.Response

type PrometheusApiService

type PrometheusApiService interface {
	RouteGetAlertStatuses(*models.ReqContext) response.Response
	RouteGetRuleStatuses(*models.ReqContext) response.Response
}

type PrometheusSrv

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

func (PrometheusSrv) RouteGetAlertStatuses

func (srv PrometheusSrv) RouteGetAlertStatuses(c *models.ReqContext) response.Response

func (PrometheusSrv) RouteGetRuleStatuses

func (srv PrometheusSrv) RouteGetRuleStatuses(c *models.ReqContext) response.Response

type RulerApiService

type RulerApiService interface {
	RouteDeleteNamespaceRulesConfig(*models.ReqContext) response.Response
	RouteDeleteRuleGroupConfig(*models.ReqContext) response.Response
	RouteGetNamespaceRulesConfig(*models.ReqContext) response.Response
	RouteGetRulegGroupConfig(*models.ReqContext) response.Response
	RouteGetRulesConfig(*models.ReqContext) response.Response
	RoutePostNameRulesConfig(*models.ReqContext, apimodels.PostableRuleGroupConfig) response.Response
}

type RulerSrv

type RulerSrv struct {
	DatasourceCache datasources.CacheService
	QuotaService    *quota.QuotaService
	// contains filtered or unexported fields
}

func (RulerSrv) RouteDeleteNamespaceRulesConfig

func (srv RulerSrv) RouteDeleteNamespaceRulesConfig(c *models.ReqContext) response.Response

func (RulerSrv) RouteDeleteRuleGroupConfig

func (srv RulerSrv) RouteDeleteRuleGroupConfig(c *models.ReqContext) response.Response

func (RulerSrv) RouteGetNamespaceRulesConfig

func (srv RulerSrv) RouteGetNamespaceRulesConfig(c *models.ReqContext) response.Response

func (RulerSrv) RouteGetRulegGroupConfig

func (srv RulerSrv) RouteGetRulegGroupConfig(c *models.ReqContext) response.Response

func (RulerSrv) RouteGetRulesConfig

func (srv RulerSrv) RouteGetRulesConfig(c *models.ReqContext) response.Response

func (RulerSrv) RoutePostNameRulesConfig

func (srv RulerSrv) RoutePostNameRulesConfig(c *models.ReqContext, ruleGroupConfig apimodels.PostableRuleGroupConfig) response.Response

type Scheduler

type Scheduler interface {
	AlertmanagersFor(orgID int64) []*url.URL
	DroppedAlertmanagersFor(orgID int64) []*url.URL
}

type TestingApiService

type TestingApiService interface {
	RouteEvalQueries(*models.ReqContext, apimodels.EvalQueriesPayload) response.Response
	RouteTestRuleConfig(*models.ReqContext, apimodels.TestRulePayload) response.Response
}

type TestingApiSrv

type TestingApiSrv struct {
	*AlertingProxy
	Cfg               *setting.Cfg
	ExpressionService *expr.Service
	DatasourceCache   datasources.CacheService
	// contains filtered or unexported fields
}

func (TestingApiSrv) RouteEvalQueries

func (TestingApiSrv) RouteTestRuleConfig

func (srv TestingApiSrv) RouteTestRuleConfig(c *models.ReqContext, body apimodels.TestRulePayload) response.Response

type UnknownReceiverError

type UnknownReceiverError struct {
	UID string
}

func (UnknownReceiverError) Error

func (e UnknownReceiverError) Error() string

Directories

Path Synopsis
tooling
definitions
Package definitions includes the types required for generating or consuming an OpenAPI spec for the Unified Alerting API.
Package definitions includes the types required for generating or consuming an OpenAPI spec for the Unified Alerting API.

Jump to

Keyboard shortcuts

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