api

package
v11.1.4-modfix Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 73 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.

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

View Source
const (
	Prometheus = "prometheus"
	Cortex     = "cortex"
	Mimir      = "mimir"
)
View Source
const (
	PrometheusDatasourceType = "prometheus"
	LokiDatasourceType       = "loki"
)

Variables

This section is empty.

Functions

func AlertQueriesFromApiAlertQueries

func AlertQueriesFromApiAlertQueries(queries []definitions.AlertQuery) []models.AlertQuery

AlertQueriesFromApiAlertQueries converts a collection of definitions.AlertQuery to collection of models.AlertQuery

func AlertQueryExportFromAlertQuery

func AlertQueryExportFromAlertQuery(query models.AlertQuery) (definitions.AlertQueryExport, error)

AlertQueryExportFromAlertQuery creates a definitions.AlertQueryExport DTO from models.AlertQuery.

func AlertRuleExportFromAlertRule

func AlertRuleExportFromAlertRule(rule models.AlertRule) (definitions.AlertRuleExport, error)

AlertRuleExportFromAlertRule creates a definitions.AlertRuleExport DTO from models.AlertRule.

func AlertRuleFromProvisionedAlertRule

func AlertRuleFromProvisionedAlertRule(a definitions.ProvisionedAlertRule) (models.AlertRule, error)

AlertRuleFromProvisionedAlertRule converts definitions.ProvisionedAlertRule to models.AlertRule

func AlertRuleGroupExportFromAlertRuleGroupWithFolderFullpath

func AlertRuleGroupExportFromAlertRuleGroupWithFolderFullpath(d models.AlertRuleGroupWithFolderFullpath) (definitions.AlertRuleGroupExport, error)

AlertRuleGroupExportFromAlertRuleGroupWithFolderFullpath creates a definitions.AlertRuleGroupExport DTO from models.AlertRuleGroup.

func AlertRuleGroupFromApiAlertRuleGroup

func AlertRuleGroupFromApiAlertRuleGroup(a definitions.AlertRuleGroup) (models.AlertRuleGroup, error)

func AlertRuleNotificationSettingsExportFromNotificationSettings

func AlertRuleNotificationSettingsExportFromNotificationSettings(ns []models.NotificationSettings) *definitions.AlertRuleNotificationSettingsExport

AlertRuleNotificationSettingsFromNotificationSettings converts []models.NotificationSettings to definitions.AlertRuleNotificationSettingsExport

func AlertRuleNotificationSettingsFromNotificationSettings

func AlertRuleNotificationSettingsFromNotificationSettings(ns []models.NotificationSettings) *definitions.AlertRuleNotificationSettings

AlertRuleNotificationSettingsFromNotificationSettings converts []models.NotificationSettings to definitions.AlertRuleNotificationSettings

func AlertRuleRecordExportFromRecord

func AlertRuleRecordExportFromRecord(r *models.Record) *definitions.AlertRuleRecordExport

func AlertingFileExportFromAlertRuleGroupWithFolderFullpath

func AlertingFileExportFromAlertRuleGroupWithFolderFullpath(groups []models.AlertRuleGroupWithFolderFullpath) (definitions.AlertingFileExport, error)

AlertingFileExportFromAlertRuleGroupWithFolderFullpath creates an definitions.AlertingFileExport DTO from []models.AlertRuleGroupWithFolderTitle.

func AlertingFileExportFromEmbeddedContactPoints

func AlertingFileExportFromEmbeddedContactPoints(orgID int64, ecps []definitions.EmbeddedContactPoint) (definitions.AlertingFileExport, error)

AlertingFileExportFromEmbeddedContactPoints creates a definitions.AlertingFileExport DTO from []definitions.EmbeddedContactPoint.

func AlertingFileExportFromMuteTimings

func AlertingFileExportFromMuteTimings(orgID int64, m []definitions.MuteTimeInterval) definitions.AlertingFileExport

func AlertingFileExportFromRoute

func AlertingFileExportFromRoute(orgID int64, route definitions.Route) (definitions.AlertingFileExport, error)

AlertingFileExportFromRoute creates a definitions.AlertingFileExport DTO from definitions.Route.

func ApiAlertQueriesFromAlertQueries

func ApiAlertQueriesFromAlertQueries(queries []models.AlertQuery) []definitions.AlertQuery

ApiAlertQueriesFromAlertQueries converts a collection of models.AlertQuery to collection of definitions.AlertQuery

func ApiAlertRuleGroupFromAlertRuleGroup

func ApiAlertRuleGroupFromAlertRuleGroup(d models.AlertRuleGroup) definitions.AlertRuleGroup

func ApiRecordFromModelRecord

func ApiRecordFromModelRecord(r *models.Record) *definitions.Record

func ContactPointFromContactPointExport

func ContactPointFromContactPointExport(rawContactPoint definitions.ContactPointExport) (definitions.ContactPoint, error)

ContactPointFromContactPointExport parses the database model of the contact point (group of integrations) where settings are represented in JSON, to strongly typed ContactPoint.

func ContactPointToContactPointExport

func ContactPointToContactPointExport(cp definitions.ContactPoint) (notify.APIReceiver, error)

ContactPointToContactPointExport converts definitions.ContactPoint to notify.APIReceiver. It uses special extension for json-iterator API that properly handles marshalling of some specific fields.

func ErrResp

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

ErrorResp creates a response with a visible error

func ModelRecordFromApiRecord

func ModelRecordFromApiRecord(r *definitions.Record) *models.Record

func MuteTimingIntervalToMuteTimeIntervalHclExport

func MuteTimingIntervalToMuteTimeIntervalHclExport(m definitions.MuteTimeIntervalExport) (definitions.MuteTimeIntervalExportHcl, error)

Converts definitions.MuteTimeIntervalExport to definitions.MuteTimeIntervalExportHcl using JSON marshalling. Returns error if structure could not be marshalled\unmarshalled

func NewFakeAlertInstanceManager

func NewFakeAlertInstanceManager(t *testing.T) *fakeAlertInstanceManager

func NilIfEmpty

func NilIfEmpty[T any](v *[]T) *[]T

NilIfEmpty returns nil if pointer to slice points to the empty slice.

func NotificationSettingsFromAlertRuleNotificationSettings

func NotificationSettingsFromAlertRuleNotificationSettings(ns *definitions.AlertRuleNotificationSettings) []models.NotificationSettings

NotificationSettingsFromAlertRuleNotificationSettings converts definitions.AlertRuleNotificationSettings to []models.NotificationSettings

func OmitDefault

func OmitDefault[T comparable](v *T) *T

OmitDefault returns nil if the value is the default.

func PostableSilenceToSilence

func PostableSilenceToSilence(s definitions.PostableSilence) models.Silence

func PrepareRuleGroupStatuses

func PrepareRuleGroupStatuses(log log.Logger, manager state.AlertInstanceManager, store ListAlertRulesStore, opts RuleGroupStatusesOptions) apimodels.RuleResponse

TODO: Refactor this function to reduce the cylomatic complexity

func ProvisionedAlertRuleFromAlertRule

func ProvisionedAlertRuleFromAlertRule(rule models.AlertRule, provenance models.Provenance) definitions.ProvisionedAlertRule

ProvisionedAlertRuleFromAlertRule converts models.AlertRule to definitions.ProvisionedAlertRule and sets provided provenance status

func ProvisionedAlertRuleFromAlertRules

func ProvisionedAlertRuleFromAlertRules(rules []*models.AlertRule, provenances map[string]models.Provenance) definitions.ProvisionedAlertRules

ProvisionedAlertRuleFromAlertRules converts a collection of models.AlertRule to definitions.ProvisionedAlertRules with provenance status models.ProvenanceNone

func ReceiverExportFromEmbeddedContactPoint

func ReceiverExportFromEmbeddedContactPoint(contact definitions.EmbeddedContactPoint) (definitions.ReceiverExport, error)

ReceiverExportFromEmbeddedContactPoint creates a definitions.ReceiverExport DTO from definitions.EmbeddedContactPoint.

func RouteExportFromRoute

func RouteExportFromRoute(route *definitions.Route) *definitions.RouteExport

RouteExportFromRoute creates a definitions.RouteExport DTO from definitions.Route.

func SilencesToGettableGrafanaSilences

func SilencesToGettableGrafanaSilences(silences []*models.SilenceWithMetadata) definitions.GettableGrafanaSilences

func TimeFromMillis

func TimeFromMillis(ms int64) time.Time

TimeFromMillis Copied from https://github.com/grafana/mimir/blob/main/pkg/util/time.go as it doesn't seem worth it to import Mimir. TimeFromMillis is a helper to turn milliseconds -> time.Time

func ValidateRuleGroup

func ValidateRuleGroup(
	ruleGroupConfig *apimodels.PostableRuleGroupConfig,
	orgId int64,
	namespaceUID string,
	limits RuleLimits) ([]*ngmodels.AlertRuleWithOptionals, error)

ValidateRuleGroup validates API model (definitions.PostableRuleGroupConfig) and converts it to a collection of models.AlertRule. Returns a slice that contains all rules described by API model or error if either group specification or an alert definition is not valid. It also returns a map containing current existing alerts that don't contain the is_paused field in the body of the call.

Types

type AMConfigStore

type AMConfigStore interface {
	GetLatestAlertmanagerConfiguration(ctx context.Context, orgID int64) (*ngmodels.AlertConfiguration, error)
}

type AMRefresher

type AMRefresher interface {
	ApplyConfig(ctx context.Context, orgId int64, dbConfig *ngmodels.AlertConfiguration) error
}

type API

type API struct {
	Cfg                  *setting.Cfg
	DatasourceCache      datasources.CacheService
	DatasourceService    datasources.DataSourceService
	RouteRegister        routing.RouteRegister
	QuotaService         quota.Service
	TransactionManager   provisioning.TransactionManager
	ProvenanceStore      provisioning.ProvisioningStore
	RuleStore            RuleStore
	AlertingStore        store.AlertingStore
	AdminConfigStore     store.AdminConfigurationStore
	DataProxy            *datasourceproxy.DataSourceProxyService
	MultiOrgAlertmanager *notifier.MultiOrgAlertmanager
	StateManager         *state.Manager
	AccessControl        ac.AccessControl
	Policies             *provisioning.NotificationPolicyService
	ReceiverService      *notifier.ReceiverService
	ContactPointService  *provisioning.ContactPointService
	Templates            *provisioning.TemplateService
	MuteTimings          *provisioning.MuteTimingService
	AlertRules           *provisioning.AlertRuleService
	AlertsRouter         *sender.AlertsRouter
	EvaluatorFactory     eval.EvaluatorFactory
	FeatureManager       featuremgmt.FeatureToggles
	Historian            Historian
	Tracer               tracing.Tracer
	AppUrl               *url.URL

	// Hooks can be used to replace API handlers for specific paths.
	Hooks *Hooks
}

API handlers.

func (*API) RegisterAPIEndpoints

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

RegisterAPIEndpoints registers API handlers

func (*API) RegisterAlertmanagerApiEndpoints

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

func (*API) RegisterConfigurationApiEndpoints

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

func (*API) RegisterHistoryApiEndpoints

func (api *API) RegisterHistoryApiEndpoints(srv HistoryApi, m *metrics.API)

func (*API) RegisterNotificationsApiEndpoints

func (api *API) RegisterNotificationsApiEndpoints(srv NotificationsApi, m *metrics.API)

func (*API) RegisterPrometheusApiEndpoints

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

func (*API) RegisterProvisioningApiEndpoints

func (api *API) RegisterProvisioningApiEndpoints(srv ProvisioningApi, m *metrics.API)

func (*API) RegisterRulerApiEndpoints

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

func (*API) RegisterTestingApiEndpoints

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

type AlertRuleService

type AlertRuleService interface {
	GetAlertRules(ctx context.Context, user identity.Requester) ([]*alerting_models.AlertRule, map[string]alerting_models.Provenance, error)
	GetAlertRule(ctx context.Context, user identity.Requester, ruleUID string) (alerting_models.AlertRule, alerting_models.Provenance, error)
	CreateAlertRule(ctx context.Context, user identity.Requester, rule alerting_models.AlertRule, provenance alerting_models.Provenance) (alerting_models.AlertRule, error)
	UpdateAlertRule(ctx context.Context, user identity.Requester, rule alerting_models.AlertRule, provenance alerting_models.Provenance) (alerting_models.AlertRule, error)
	DeleteAlertRule(ctx context.Context, user identity.Requester, ruleUID string, provenance alerting_models.Provenance) error
	GetRuleGroup(ctx context.Context, user identity.Requester, folder, group string) (alerting_models.AlertRuleGroup, error)
	ReplaceRuleGroup(ctx context.Context, user identity.Requester, group alerting_models.AlertRuleGroup, provenance alerting_models.Provenance) error
	DeleteRuleGroup(ctx context.Context, user identity.Requester, folder, group string, provenance alerting_models.Provenance) error
	GetAlertRuleWithFolderFullpath(ctx context.Context, u identity.Requester, ruleUID string) (provisioning.AlertRuleWithFolderFullpath, error)
	GetAlertRuleGroupWithFolderFullpath(ctx context.Context, u identity.Requester, folder, group string) (alerting_models.AlertRuleGroupWithFolderFullpath, error)
	GetAlertGroupsWithFolderFullpath(ctx context.Context, u identity.Requester, folderUIDs []string) ([]alerting_models.AlertRuleGroupWithFolderFullpath, error)
}

type AlertStatusesOptions

type AlertStatusesOptions struct {
	OrgID int64
	Query url.Values
}

type AlertingProxy

type AlertingProxy struct {
	DataProxy *datasourceproxy.DataSourceProxyService
	// contains filtered or unexported fields
}

type AlertingStore

type AlertingStore interface {
	GetLatestAlertmanagerConfiguration(ctx context.Context, orgID int64) (*models.AlertConfiguration, error)
}

type AlertmanagerApi

type AlertmanagerApi interface {
	RouteCreateGrafanaSilence(*contextmodel.ReqContext) response.Response
	RouteCreateSilence(*contextmodel.ReqContext) response.Response
	RouteDeleteAlertingConfig(*contextmodel.ReqContext) response.Response
	RouteDeleteGrafanaAlertingConfig(*contextmodel.ReqContext) response.Response
	RouteDeleteGrafanaSilence(*contextmodel.ReqContext) response.Response
	RouteDeleteSilence(*contextmodel.ReqContext) response.Response
	RouteGetAMAlertGroups(*contextmodel.ReqContext) response.Response
	RouteGetAMAlerts(*contextmodel.ReqContext) response.Response
	RouteGetAMStatus(*contextmodel.ReqContext) response.Response
	RouteGetAlertingConfig(*contextmodel.ReqContext) response.Response
	RouteGetGrafanaAMAlertGroups(*contextmodel.ReqContext) response.Response
	RouteGetGrafanaAMAlerts(*contextmodel.ReqContext) response.Response
	RouteGetGrafanaAMStatus(*contextmodel.ReqContext) response.Response
	RouteGetGrafanaAlertingConfig(*contextmodel.ReqContext) response.Response
	RouteGetGrafanaAlertingConfigHistory(*contextmodel.ReqContext) response.Response
	RouteGetGrafanaReceivers(*contextmodel.ReqContext) response.Response
	RouteGetGrafanaSilence(*contextmodel.ReqContext) response.Response
	RouteGetGrafanaSilences(*contextmodel.ReqContext) response.Response
	RouteGetSilence(*contextmodel.ReqContext) response.Response
	RouteGetSilences(*contextmodel.ReqContext) response.Response
	RoutePostAMAlerts(*contextmodel.ReqContext) response.Response
	RoutePostAlertingConfig(*contextmodel.ReqContext) response.Response
	RoutePostGrafanaAlertingConfig(*contextmodel.ReqContext) response.Response
	RoutePostGrafanaAlertingConfigHistoryActivate(*contextmodel.ReqContext) response.Response
	RoutePostTestGrafanaReceivers(*contextmodel.ReqContext) response.Response
	RoutePostTestGrafanaTemplates(*contextmodel.ReqContext) response.Response
}

type AlertmanagerApiHandler

type AlertmanagerApiHandler struct {
	AMSvc           *LotexAM
	GrafanaSvc      *AlertmanagerSrv
	DatasourceCache datasources.CacheService
}

func NewForkingAM

func NewForkingAM(datasourceCache datasources.CacheService, proxy *LotexAM, grafana *AlertmanagerSrv) *AlertmanagerApiHandler

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

func (*AlertmanagerApiHandler) RouteCreateGrafanaSilence

func (f *AlertmanagerApiHandler) RouteCreateGrafanaSilence(ctx *contextmodel.ReqContext) response.Response

func (*AlertmanagerApiHandler) RouteCreateSilence

func (f *AlertmanagerApiHandler) RouteCreateSilence(ctx *contextmodel.ReqContext) response.Response

func (*AlertmanagerApiHandler) RouteDeleteAlertingConfig

func (f *AlertmanagerApiHandler) RouteDeleteAlertingConfig(ctx *contextmodel.ReqContext) response.Response

func (*AlertmanagerApiHandler) RouteDeleteGrafanaAlertingConfig

func (f *AlertmanagerApiHandler) RouteDeleteGrafanaAlertingConfig(ctx *contextmodel.ReqContext) response.Response

func (*AlertmanagerApiHandler) RouteDeleteGrafanaSilence

func (f *AlertmanagerApiHandler) RouteDeleteGrafanaSilence(ctx *contextmodel.ReqContext) response.Response

func (*AlertmanagerApiHandler) RouteDeleteSilence

func (f *AlertmanagerApiHandler) RouteDeleteSilence(ctx *contextmodel.ReqContext) response.Response

func (*AlertmanagerApiHandler) RouteGetAMAlertGroups

func (f *AlertmanagerApiHandler) RouteGetAMAlertGroups(ctx *contextmodel.ReqContext) response.Response

func (*AlertmanagerApiHandler) RouteGetAMAlerts

func (*AlertmanagerApiHandler) RouteGetAMStatus

func (*AlertmanagerApiHandler) RouteGetAlertingConfig

func (f *AlertmanagerApiHandler) RouteGetAlertingConfig(ctx *contextmodel.ReqContext) response.Response

func (*AlertmanagerApiHandler) RouteGetGrafanaAMAlertGroups

func (f *AlertmanagerApiHandler) RouteGetGrafanaAMAlertGroups(ctx *contextmodel.ReqContext) response.Response

func (*AlertmanagerApiHandler) RouteGetGrafanaAMAlerts

func (f *AlertmanagerApiHandler) RouteGetGrafanaAMAlerts(ctx *contextmodel.ReqContext) response.Response

func (*AlertmanagerApiHandler) RouteGetGrafanaAMStatus

func (f *AlertmanagerApiHandler) RouteGetGrafanaAMStatus(ctx *contextmodel.ReqContext) response.Response

func (*AlertmanagerApiHandler) RouteGetGrafanaAlertingConfig

func (f *AlertmanagerApiHandler) RouteGetGrafanaAlertingConfig(ctx *contextmodel.ReqContext) response.Response

func (*AlertmanagerApiHandler) RouteGetGrafanaAlertingConfigHistory

func (f *AlertmanagerApiHandler) RouteGetGrafanaAlertingConfigHistory(ctx *contextmodel.ReqContext) response.Response

func (*AlertmanagerApiHandler) RouteGetGrafanaReceivers

func (f *AlertmanagerApiHandler) RouteGetGrafanaReceivers(ctx *contextmodel.ReqContext) response.Response

func (*AlertmanagerApiHandler) RouteGetGrafanaSilence

func (f *AlertmanagerApiHandler) RouteGetGrafanaSilence(ctx *contextmodel.ReqContext) response.Response

func (*AlertmanagerApiHandler) RouteGetGrafanaSilences

func (f *AlertmanagerApiHandler) RouteGetGrafanaSilences(ctx *contextmodel.ReqContext) response.Response

func (*AlertmanagerApiHandler) RouteGetSilence

func (*AlertmanagerApiHandler) RouteGetSilences

func (*AlertmanagerApiHandler) RoutePostAMAlerts

func (f *AlertmanagerApiHandler) RoutePostAMAlerts(ctx *contextmodel.ReqContext) response.Response

func (*AlertmanagerApiHandler) RoutePostAlertingConfig

func (f *AlertmanagerApiHandler) RoutePostAlertingConfig(ctx *contextmodel.ReqContext) response.Response

func (*AlertmanagerApiHandler) RoutePostGrafanaAlertingConfig

func (f *AlertmanagerApiHandler) RoutePostGrafanaAlertingConfig(ctx *contextmodel.ReqContext) response.Response

func (*AlertmanagerApiHandler) RoutePostGrafanaAlertingConfigHistoryActivate

func (f *AlertmanagerApiHandler) RoutePostGrafanaAlertingConfigHistoryActivate(ctx *contextmodel.ReqContext) response.Response

func (*AlertmanagerApiHandler) RoutePostTestGrafanaReceivers

func (f *AlertmanagerApiHandler) RoutePostTestGrafanaReceivers(ctx *contextmodel.ReqContext) response.Response

func (*AlertmanagerApiHandler) RoutePostTestGrafanaTemplates

func (f *AlertmanagerApiHandler) RoutePostTestGrafanaTemplates(ctx *contextmodel.ReqContext) response.Response

type AlertmanagerSrv

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

func (AlertmanagerSrv) AlertmanagerFor

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

func (AlertmanagerSrv) RouteCreateSilence

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

RouteCreateSilence is the silence POST (create + update) endpoint for Grafana AM.

func (AlertmanagerSrv) RouteDeleteAlertingConfig

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

func (AlertmanagerSrv) RouteDeleteSilence

func (srv AlertmanagerSrv) RouteDeleteSilence(c *contextmodel.ReqContext, silenceID string) response.Response

RouteDeleteSilence is the silence DELETE endpoint for Grafana AM.

func (AlertmanagerSrv) RouteGetAMAlertGroups

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

func (AlertmanagerSrv) RouteGetAMAlerts

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

func (AlertmanagerSrv) RouteGetAMStatus

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

func (AlertmanagerSrv) RouteGetAlertingConfig

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

func (AlertmanagerSrv) RouteGetAlertingConfigHistory

func (srv AlertmanagerSrv) RouteGetAlertingConfigHistory(c *contextmodel.ReqContext) response.Response

func (AlertmanagerSrv) RouteGetReceivers

func (srv AlertmanagerSrv) RouteGetReceivers(c *contextmodel.ReqContext) response.Response

func (AlertmanagerSrv) RouteGetSilence

func (srv AlertmanagerSrv) RouteGetSilence(c *contextmodel.ReqContext, silenceID string) response.Response

RouteGetSilence is the single silence GET endpoint for Grafana AM.

func (AlertmanagerSrv) RouteGetSilences

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

RouteGetSilences is the silence list GET endpoint for Grafana AM.

func (AlertmanagerSrv) RoutePostAlertingConfig

func (AlertmanagerSrv) RoutePostGrafanaAlertingConfigHistoryActivate

func (srv AlertmanagerSrv) RoutePostGrafanaAlertingConfigHistoryActivate(c *contextmodel.ReqContext, id string) response.Response

func (AlertmanagerSrv) RoutePostTestReceivers

func (AlertmanagerSrv) RoutePostTestTemplates

type ConditionValidator

type ConditionValidator interface {
	// Validate validates that the condition is correct. Returns nil if the condition is correct. Otherwise, error that describes the failure
	Validate(ctx eval.EvaluationContext, condition ngmodels.Condition) error
}

type ConfigSrv

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

func (ConfigSrv) RouteDeleteNGalertConfig

func (srv ConfigSrv) RouteDeleteNGalertConfig(c *contextmodel.ReqContext) response.Response

func (ConfigSrv) RouteGetAlertingStatus

func (srv ConfigSrv) RouteGetAlertingStatus(c *contextmodel.ReqContext) response.Response

func (ConfigSrv) RouteGetAlertmanagers

func (srv ConfigSrv) RouteGetAlertmanagers(c *contextmodel.ReqContext) response.Response

func (ConfigSrv) RouteGetNGalertConfig

func (srv ConfigSrv) RouteGetNGalertConfig(c *contextmodel.ReqContext) response.Response

func (ConfigSrv) RoutePostNGalertConfig

func (srv ConfigSrv) RoutePostNGalertConfig(c *contextmodel.ReqContext, body apimodels.PostableNGalertConfig) response.Response

type ConfigurationApi

type ConfigurationApi interface {
	RouteDeleteNGalertConfig(*contextmodel.ReqContext) response.Response
	RouteGetAlertmanagers(*contextmodel.ReqContext) response.Response
	RouteGetNGalertConfig(*contextmodel.ReqContext) response.Response
	RouteGetStatus(*contextmodel.ReqContext) response.Response
	RoutePostNGalertConfig(*contextmodel.ReqContext) response.Response
}

type ConfigurationApiHandler

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

ConfigurationApiHandler always forwards requests to grafana backend

func NewConfiguration

func NewConfiguration(grafana *ConfigSrv) *ConfigurationApiHandler

func (*ConfigurationApiHandler) RouteDeleteNGalertConfig

func (f *ConfigurationApiHandler) RouteDeleteNGalertConfig(ctx *contextmodel.ReqContext) response.Response

func (*ConfigurationApiHandler) RouteGetAlertmanagers

func (f *ConfigurationApiHandler) RouteGetAlertmanagers(ctx *contextmodel.ReqContext) response.Response

func (*ConfigurationApiHandler) RouteGetNGalertConfig

func (f *ConfigurationApiHandler) RouteGetNGalertConfig(ctx *contextmodel.ReqContext) response.Response

func (*ConfigurationApiHandler) RouteGetStatus

func (*ConfigurationApiHandler) RoutePostNGalertConfig

func (f *ConfigurationApiHandler) RoutePostNGalertConfig(ctx *contextmodel.ReqContext) response.Response

type ContactPointService

type ContactPointService interface {
	GetContactPoints(ctx context.Context, q provisioning.ContactPointQuery, user identity.Requester) ([]definitions.EmbeddedContactPoint, error)
	CreateContactPoint(ctx context.Context, orgID int64, contactPoint definitions.EmbeddedContactPoint, p alerting_models.Provenance) (definitions.EmbeddedContactPoint, error)
	UpdateContactPoint(ctx context.Context, orgID int64, contactPoint definitions.EmbeddedContactPoint, p alerting_models.Provenance) error
	DeleteContactPoint(ctx context.Context, orgID int64, uid string) error
}

type ExternalAlertmanagerProvider

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

type Historian

type Historian interface {
	Query(ctx context.Context, query models.HistoryQuery) (*data.Frame, error)
}

type HistoryApi

type HistoryApi interface {
	RouteGetStateHistory(*contextmodel.ReqContext) response.Response
}

type HistoryApiHandler

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

func NewStateHistoryApi

func NewStateHistoryApi(svc *HistorySrv) *HistoryApiHandler

func (*HistoryApiHandler) RouteGetStateHistory

func (f *HistoryApiHandler) RouteGetStateHistory(ctx *contextmodel.ReqContext) response.Response

type HistorySrv

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

func (*HistorySrv) RouteQueryStateHistory

func (srv *HistorySrv) RouteQueryStateHistory(c *contextmodel.ReqContext) response.Response

type Hooks

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

func NewHooks

func NewHooks(logger log.Logger) *Hooks

NewHooks creates an empty set of request handler hooks. Hooks can be used to replace handlers for specific paths.

func (*Hooks) Get

func (h *Hooks) Get(method string, url *url.URL) (RequestHandlerFunc, bool)

Get returns a hook if one is defined for the matching URL. Get also returns a bool indicating whether or not a matching hook exists.

func (*Hooks) Set

func (h *Hooks) Set(method string, path string, hook RequestHandlerFunc)

Add creates a new request hook for a path, causing requests to the path to be handled by the hook function, and not the original handler.

func (*Hooks) Wrap

Wrap returns a new handler which will intercept paths with hooks configured, and invoke the hooked in handler instead. If no hook is configured for a path, then the given handler is invoked.

type ListAlertRulesStore

type ListAlertRulesStore interface {
	ListAlertRules(ctx context.Context, query *ngmodels.ListAlertRulesQuery) (ngmodels.RulesGroup, error)
}

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 *contextmodel.ReqContext, silenceBody apimodels.PostableSilence) response.Response

func (*LotexAM) RouteDeleteAlertingConfig

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

func (*LotexAM) RouteDeleteSilence

func (am *LotexAM) RouteDeleteSilence(ctx *contextmodel.ReqContext, silenceID string) response.Response

func (*LotexAM) RouteGetAMAlertGroups

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

func (*LotexAM) RouteGetAMAlerts

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

func (*LotexAM) RouteGetAMStatus

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

func (*LotexAM) RouteGetAlertingConfig

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

func (*LotexAM) RouteGetSilence

func (am *LotexAM) RouteGetSilence(ctx *contextmodel.ReqContext, silenceID string) response.Response

func (*LotexAM) RouteGetSilences

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

func (*LotexAM) RoutePostAMAlerts

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

func (*LotexAM) RoutePostAlertingConfig

func (am *LotexAM) RoutePostAlertingConfig(ctx *contextmodel.ReqContext, config apimodels.PostableUserConfig) 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 *contextmodel.ReqContext) response.Response

func (*LotexProm) RouteGetRuleStatuses

func (p *LotexProm) RouteGetRuleStatuses(ctx *contextmodel.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 *contextmodel.ReqContext, namespace string) response.Response

func (*LotexRuler) RouteDeleteRuleGroupConfig

func (r *LotexRuler) RouteDeleteRuleGroupConfig(ctx *contextmodel.ReqContext, namespace string, group string) response.Response

func (*LotexRuler) RouteGetNamespaceRulesConfig

func (r *LotexRuler) RouteGetNamespaceRulesConfig(ctx *contextmodel.ReqContext, namespace string) response.Response

func (*LotexRuler) RouteGetRulegGroupConfig

func (r *LotexRuler) RouteGetRulegGroupConfig(ctx *contextmodel.ReqContext, namespace string, group string) response.Response

func (*LotexRuler) RouteGetRulesConfig

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

func (*LotexRuler) RoutePostNameRulesConfig

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

type MuteTimingService

type MuteTimingService interface {
	GetMuteTimings(ctx context.Context, orgID int64) ([]definitions.MuteTimeInterval, error)
	GetMuteTiming(ctx context.Context, name string, orgID int64) (definitions.MuteTimeInterval, error)
	CreateMuteTiming(ctx context.Context, mt definitions.MuteTimeInterval, orgID int64) (definitions.MuteTimeInterval, error)
	UpdateMuteTiming(ctx context.Context, mt definitions.MuteTimeInterval, orgID int64) (definitions.MuteTimeInterval, error)
	DeleteMuteTiming(ctx context.Context, name string, orgID int64, provenance definitions.Provenance, version string) error
}

type NotificationPolicyService

type NotificationPolicyService interface {
	GetPolicyTree(ctx context.Context, orgID int64) (definitions.Route, error)
	UpdatePolicyTree(ctx context.Context, orgID int64, tree definitions.Route, p alerting_models.Provenance) error
	ResetPolicyTree(ctx context.Context, orgID int64) (definitions.Route, error)
}

type NotificationSrv

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

func (*NotificationSrv) RouteGetReceiver

func (srv *NotificationSrv) RouteGetReceiver(c *contextmodel.ReqContext, name string) response.Response

func (*NotificationSrv) RouteGetReceivers

func (srv *NotificationSrv) RouteGetReceivers(c *contextmodel.ReqContext) response.Response

func (*NotificationSrv) RouteGetTimeInterval

func (srv *NotificationSrv) RouteGetTimeInterval(c *contextmodel.ReqContext, name string) response.Response

func (*NotificationSrv) RouteGetTimeIntervals

func (srv *NotificationSrv) RouteGetTimeIntervals(c *contextmodel.ReqContext) response.Response

type NotificationsApi

type NotificationsApi interface {
	RouteGetReceiver(*contextmodel.ReqContext) response.Response
	RouteGetReceivers(*contextmodel.ReqContext) response.Response
	RouteNotificationsGetTimeInterval(*contextmodel.ReqContext) response.Response
	RouteNotificationsGetTimeIntervals(*contextmodel.ReqContext) response.Response
}

type NotificationsApiHandler

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

func NewNotificationsApi

func NewNotificationsApi(notificationSrv *NotificationSrv) *NotificationsApiHandler

func (*NotificationsApiHandler) RouteGetReceiver

func (*NotificationsApiHandler) RouteGetReceivers

func (*NotificationsApiHandler) RouteNotificationsGetTimeInterval

func (f *NotificationsApiHandler) RouteNotificationsGetTimeInterval(ctx *contextmodel.ReqContext) response.Response

func (*NotificationsApiHandler) RouteNotificationsGetTimeIntervals

func (f *NotificationsApiHandler) RouteNotificationsGetTimeIntervals(ctx *contextmodel.ReqContext) response.Response

type PrometheusApi

type PrometheusApi interface {
	RouteGetAlertStatuses(*contextmodel.ReqContext) response.Response
	RouteGetGrafanaAlertStatuses(*contextmodel.ReqContext) response.Response
	RouteGetGrafanaRuleStatuses(*contextmodel.ReqContext) response.Response
	RouteGetRuleStatuses(*contextmodel.ReqContext) response.Response
}

type PrometheusApiHandler

type PrometheusApiHandler struct {
	ProxySvc        *LotexProm
	GrafanaSvc      *PrometheusSrv
	DatasourceCache datasources.CacheService
}

func NewForkingProm

func NewForkingProm(datasourceCache datasources.CacheService, proxy *LotexProm, grafana *PrometheusSrv) *PrometheusApiHandler

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

func (*PrometheusApiHandler) RouteGetAlertStatuses

func (f *PrometheusApiHandler) RouteGetAlertStatuses(ctx *contextmodel.ReqContext) response.Response

func (*PrometheusApiHandler) RouteGetGrafanaAlertStatuses

func (f *PrometheusApiHandler) RouteGetGrafanaAlertStatuses(ctx *contextmodel.ReqContext) response.Response

func (*PrometheusApiHandler) RouteGetGrafanaRuleStatuses

func (f *PrometheusApiHandler) RouteGetGrafanaRuleStatuses(ctx *contextmodel.ReqContext) response.Response

func (*PrometheusApiHandler) RouteGetRuleStatuses

func (f *PrometheusApiHandler) RouteGetRuleStatuses(ctx *contextmodel.ReqContext) response.Response

type PrometheusSrv

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

func (PrometheusSrv) RouteGetAlertStatuses

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

func (PrometheusSrv) RouteGetRuleStatuses

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

type ProvisioningApi

type ProvisioningApi interface {
	RouteDeleteAlertRule(*contextmodel.ReqContext) response.Response
	RouteDeleteAlertRuleGroup(*contextmodel.ReqContext) response.Response
	RouteDeleteContactpoints(*contextmodel.ReqContext) response.Response
	RouteDeleteMuteTiming(*contextmodel.ReqContext) response.Response
	RouteDeleteTemplate(*contextmodel.ReqContext) response.Response
	RouteExportMuteTiming(*contextmodel.ReqContext) response.Response
	RouteExportMuteTimings(*contextmodel.ReqContext) response.Response
	RouteGetAlertRule(*contextmodel.ReqContext) response.Response
	RouteGetAlertRuleExport(*contextmodel.ReqContext) response.Response
	RouteGetAlertRuleGroup(*contextmodel.ReqContext) response.Response
	RouteGetAlertRuleGroupExport(*contextmodel.ReqContext) response.Response
	RouteGetAlertRules(*contextmodel.ReqContext) response.Response
	RouteGetAlertRulesExport(*contextmodel.ReqContext) response.Response
	RouteGetContactpoints(*contextmodel.ReqContext) response.Response
	RouteGetContactpointsExport(*contextmodel.ReqContext) response.Response
	RouteGetMuteTiming(*contextmodel.ReqContext) response.Response
	RouteGetMuteTimings(*contextmodel.ReqContext) response.Response
	RouteGetPolicyTree(*contextmodel.ReqContext) response.Response
	RouteGetPolicyTreeExport(*contextmodel.ReqContext) response.Response
	RouteGetTemplate(*contextmodel.ReqContext) response.Response
	RouteGetTemplates(*contextmodel.ReqContext) response.Response
	RoutePostAlertRule(*contextmodel.ReqContext) response.Response
	RoutePostContactpoints(*contextmodel.ReqContext) response.Response
	RoutePostMuteTiming(*contextmodel.ReqContext) response.Response
	RoutePutAlertRule(*contextmodel.ReqContext) response.Response
	RoutePutAlertRuleGroup(*contextmodel.ReqContext) response.Response
	RoutePutContactpoint(*contextmodel.ReqContext) response.Response
	RoutePutMuteTiming(*contextmodel.ReqContext) response.Response
	RoutePutPolicyTree(*contextmodel.ReqContext) response.Response
	RoutePutTemplate(*contextmodel.ReqContext) response.Response
	RouteResetPolicyTree(*contextmodel.ReqContext) response.Response
}

type ProvisioningApiHandler

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

func NewProvisioningApi

func NewProvisioningApi(svc *ProvisioningSrv) *ProvisioningApiHandler

func (*ProvisioningApiHandler) RouteDeleteAlertRule

func (f *ProvisioningApiHandler) RouteDeleteAlertRule(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RouteDeleteAlertRuleGroup

func (f *ProvisioningApiHandler) RouteDeleteAlertRuleGroup(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RouteDeleteContactpoints

func (f *ProvisioningApiHandler) RouteDeleteContactpoints(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RouteDeleteMuteTiming

func (f *ProvisioningApiHandler) RouteDeleteMuteTiming(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RouteDeleteTemplate

func (f *ProvisioningApiHandler) RouteDeleteTemplate(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RouteExportMuteTiming

func (f *ProvisioningApiHandler) RouteExportMuteTiming(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RouteExportMuteTimings

func (f *ProvisioningApiHandler) RouteExportMuteTimings(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RouteGetAlertRule

func (f *ProvisioningApiHandler) RouteGetAlertRule(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RouteGetAlertRuleExport

func (f *ProvisioningApiHandler) RouteGetAlertRuleExport(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RouteGetAlertRuleGroup

func (f *ProvisioningApiHandler) RouteGetAlertRuleGroup(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RouteGetAlertRuleGroupExport

func (f *ProvisioningApiHandler) RouteGetAlertRuleGroupExport(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RouteGetAlertRules

func (f *ProvisioningApiHandler) RouteGetAlertRules(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RouteGetAlertRulesExport

func (f *ProvisioningApiHandler) RouteGetAlertRulesExport(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RouteGetContactpoints

func (f *ProvisioningApiHandler) RouteGetContactpoints(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RouteGetContactpointsExport

func (f *ProvisioningApiHandler) RouteGetContactpointsExport(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RouteGetMuteTiming

func (f *ProvisioningApiHandler) RouteGetMuteTiming(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RouteGetMuteTimings

func (f *ProvisioningApiHandler) RouteGetMuteTimings(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RouteGetPolicyTree

func (f *ProvisioningApiHandler) RouteGetPolicyTree(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RouteGetPolicyTreeExport

func (f *ProvisioningApiHandler) RouteGetPolicyTreeExport(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RouteGetTemplate

func (*ProvisioningApiHandler) RouteGetTemplates

func (f *ProvisioningApiHandler) RouteGetTemplates(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RoutePostAlertRule

func (f *ProvisioningApiHandler) RoutePostAlertRule(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RoutePostContactpoints

func (f *ProvisioningApiHandler) RoutePostContactpoints(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RoutePostMuteTiming

func (f *ProvisioningApiHandler) RoutePostMuteTiming(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RoutePutAlertRule

func (f *ProvisioningApiHandler) RoutePutAlertRule(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RoutePutAlertRuleGroup

func (f *ProvisioningApiHandler) RoutePutAlertRuleGroup(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RoutePutContactpoint

func (f *ProvisioningApiHandler) RoutePutContactpoint(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RoutePutMuteTiming

func (f *ProvisioningApiHandler) RoutePutMuteTiming(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RoutePutPolicyTree

func (f *ProvisioningApiHandler) RoutePutPolicyTree(ctx *contextmodel.ReqContext) response.Response

func (*ProvisioningApiHandler) RoutePutTemplate

func (*ProvisioningApiHandler) RouteResetPolicyTree

func (f *ProvisioningApiHandler) RouteResetPolicyTree(ctx *contextmodel.ReqContext) response.Response

type ProvisioningSrv

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

func (*ProvisioningSrv) RouteDeleteAlertRule

func (srv *ProvisioningSrv) RouteDeleteAlertRule(c *contextmodel.ReqContext, UID string) response.Response

func (*ProvisioningSrv) RouteDeleteAlertRuleGroup

func (srv *ProvisioningSrv) RouteDeleteAlertRuleGroup(c *contextmodel.ReqContext, folderUID string, group string) response.Response

func (*ProvisioningSrv) RouteDeleteContactPoint

func (srv *ProvisioningSrv) RouteDeleteContactPoint(c *contextmodel.ReqContext, UID string) response.Response

func (*ProvisioningSrv) RouteDeleteMuteTiming

func (srv *ProvisioningSrv) RouteDeleteMuteTiming(c *contextmodel.ReqContext, name string) response.Response

func (*ProvisioningSrv) RouteDeleteTemplate

func (srv *ProvisioningSrv) RouteDeleteTemplate(c *contextmodel.ReqContext, name string) response.Response

func (*ProvisioningSrv) RouteGetAlertRuleExport

func (srv *ProvisioningSrv) RouteGetAlertRuleExport(c *contextmodel.ReqContext, UID string) response.Response

RouteGetAlertRuleExport retrieves the given alert rule in a format compatible with file provisioning.

func (*ProvisioningSrv) RouteGetAlertRuleGroup

func (srv *ProvisioningSrv) RouteGetAlertRuleGroup(c *contextmodel.ReqContext, folder string, group string) response.Response

func (*ProvisioningSrv) RouteGetAlertRuleGroupExport

func (srv *ProvisioningSrv) RouteGetAlertRuleGroupExport(c *contextmodel.ReqContext, folder string, group string) response.Response

RouteGetAlertRuleGroupExport retrieves the given alert rule group in a format compatible with file provisioning.

func (*ProvisioningSrv) RouteGetAlertRules

func (srv *ProvisioningSrv) RouteGetAlertRules(c *contextmodel.ReqContext) response.Response

func (*ProvisioningSrv) RouteGetAlertRulesExport

func (srv *ProvisioningSrv) RouteGetAlertRulesExport(c *contextmodel.ReqContext) response.Response

RouteGetAlertRulesExport retrieves all alert rules in a format compatible with file provisioning.

func (*ProvisioningSrv) RouteGetContactPoints

func (srv *ProvisioningSrv) RouteGetContactPoints(c *contextmodel.ReqContext) response.Response

func (*ProvisioningSrv) RouteGetContactPointsExport

func (srv *ProvisioningSrv) RouteGetContactPointsExport(c *contextmodel.ReqContext) response.Response

func (*ProvisioningSrv) RouteGetMuteTiming

func (srv *ProvisioningSrv) RouteGetMuteTiming(c *contextmodel.ReqContext, name string) response.Response

func (*ProvisioningSrv) RouteGetMuteTimingExport

func (srv *ProvisioningSrv) RouteGetMuteTimingExport(c *contextmodel.ReqContext, name string) response.Response

func (*ProvisioningSrv) RouteGetMuteTimings

func (srv *ProvisioningSrv) RouteGetMuteTimings(c *contextmodel.ReqContext) response.Response

func (*ProvisioningSrv) RouteGetMuteTimingsExport

func (srv *ProvisioningSrv) RouteGetMuteTimingsExport(c *contextmodel.ReqContext) response.Response

func (*ProvisioningSrv) RouteGetPolicyTree

func (srv *ProvisioningSrv) RouteGetPolicyTree(c *contextmodel.ReqContext) response.Response

func (*ProvisioningSrv) RouteGetPolicyTreeExport

func (srv *ProvisioningSrv) RouteGetPolicyTreeExport(c *contextmodel.ReqContext) response.Response

func (*ProvisioningSrv) RouteGetTemplate

func (srv *ProvisioningSrv) RouteGetTemplate(c *contextmodel.ReqContext, name string) response.Response

func (*ProvisioningSrv) RouteGetTemplates

func (srv *ProvisioningSrv) RouteGetTemplates(c *contextmodel.ReqContext) response.Response

func (*ProvisioningSrv) RoutePostAlertRule

func (*ProvisioningSrv) RoutePostContactPoint

func (*ProvisioningSrv) RoutePostMuteTiming

func (*ProvisioningSrv) RoutePutAlertRule

func (*ProvisioningSrv) RoutePutAlertRuleGroup

func (srv *ProvisioningSrv) RoutePutAlertRuleGroup(c *contextmodel.ReqContext, ag definitions.AlertRuleGroup, folderUID string, group string) response.Response

func (*ProvisioningSrv) RoutePutContactPoint

func (*ProvisioningSrv) RoutePutMuteTiming

func (*ProvisioningSrv) RoutePutPolicyTree

func (srv *ProvisioningSrv) RoutePutPolicyTree(c *contextmodel.ReqContext, tree definitions.Route) response.Response

func (*ProvisioningSrv) RoutePutTemplate

func (*ProvisioningSrv) RouteResetPolicyTree

func (srv *ProvisioningSrv) RouteResetPolicyTree(c *contextmodel.ReqContext) response.Response

func (*ProvisioningSrv) RouteRouteGetAlertRule

func (srv *ProvisioningSrv) RouteRouteGetAlertRule(c *contextmodel.ReqContext, UID string) response.Response

type RequestHandlerFunc

type RequestHandlerFunc func(*contextmodel.ReqContext) response.Response

type RuleAccessControlService

type RuleAccessControlService interface {
	HasAccessToRuleGroup(ctx context.Context, user identity.Requester, rules models.RulesGroup) (bool, error)
	AuthorizeAccessToRuleGroup(ctx context.Context, user identity.Requester, rules models.RulesGroup) error
	AuthorizeRuleChanges(ctx context.Context, user identity.Requester, change *store.GroupDelta) error
	AuthorizeDatasourceAccessForRule(ctx context.Context, user identity.Requester, rule *models.AlertRule) error
	AuthorizeDatasourceAccessForRuleGroup(ctx context.Context, user identity.Requester, rules models.RulesGroup) error
	AuthorizeAccessInFolder(ctx context.Context, user identity.Requester, namespaced accesscontrol.Namespaced) error
}

type RuleGroupStatusesOptions

type RuleGroupStatusesOptions struct {
	Ctx                context.Context
	OrgID              int64
	Query              url.Values
	Namespaces         map[string]string
	AuthorizeRuleGroup func(rules []*ngmodels.AlertRule) (bool, error)
}

type RuleLimits

type RuleLimits struct {
	// The default interval if not specified.
	DefaultRuleEvaluationInterval time.Duration
	// All intervals must be an integer multiple of this duration.
	BaseInterval time.Duration
	// Whether recording rules are allowed.
	RecordingRulesAllowed bool
}

type RuleStore

type RuleStore interface {
	// TODO after deprecating namespace_id field in GettableGrafanaRule we can simplify this interface
	// by returning map[string]struct{} instead of map[string]*folder.Folder
	GetUserVisibleNamespaces(context.Context, int64, identity.Requester) (map[string]*folder.Folder, error)
	GetNamespaceByUID(ctx context.Context, uid string, orgID int64, user identity.Requester) (*folder.Folder, error)

	GetAlertRuleByUID(ctx context.Context, query *ngmodels.GetAlertRuleByUIDQuery) (*ngmodels.AlertRule, error)
	GetAlertRulesGroupByRuleUID(ctx context.Context, query *ngmodels.GetAlertRulesGroupByRuleUIDQuery) ([]*ngmodels.AlertRule, error)
	ListAlertRules(ctx context.Context, query *ngmodels.ListAlertRulesQuery) (ngmodels.RulesGroup, error)

	// InsertAlertRules will insert all alert rules passed into the function
	// and return the map of uuid to id.
	InsertAlertRules(ctx context.Context, rule []ngmodels.AlertRule) ([]ngmodels.AlertRuleKeyWithId, error)
	UpdateAlertRules(ctx context.Context, rule []ngmodels.UpdateRule) error
	DeleteAlertRulesByUID(ctx context.Context, orgID int64, ruleUID ...string) error

	// IncreaseVersionForAllRulesInNamespace Increases version for all rules that have specified namespace. Returns all rules that belong to the namespace
	IncreaseVersionForAllRulesInNamespace(ctx context.Context, orgID int64, namespaceUID string) ([]ngmodels.AlertRuleKeyWithVersion, error)

	accesscontrol.RuleUIDToNamespaceStore
}

RuleStore is the interface for persisting alert rules and instances

type RulerApi

type RulerApi interface {
	RouteDeleteGrafanaRuleGroupConfig(*contextmodel.ReqContext) response.Response
	RouteDeleteNamespaceGrafanaRulesConfig(*contextmodel.ReqContext) response.Response
	RouteDeleteNamespaceRulesConfig(*contextmodel.ReqContext) response.Response
	RouteDeleteRuleGroupConfig(*contextmodel.ReqContext) response.Response
	RouteGetGrafanaRuleGroupConfig(*contextmodel.ReqContext) response.Response
	RouteGetGrafanaRulesConfig(*contextmodel.ReqContext) response.Response
	RouteGetNamespaceGrafanaRulesConfig(*contextmodel.ReqContext) response.Response
	RouteGetNamespaceRulesConfig(*contextmodel.ReqContext) response.Response
	RouteGetRuleByUID(*contextmodel.ReqContext) response.Response
	RouteGetRulegGroupConfig(*contextmodel.ReqContext) response.Response
	RouteGetRulesConfig(*contextmodel.ReqContext) response.Response
	RouteGetRulesForExport(*contextmodel.ReqContext) response.Response
	RoutePostNameGrafanaRulesConfig(*contextmodel.ReqContext) response.Response
	RoutePostNameRulesConfig(*contextmodel.ReqContext) response.Response
	RoutePostRulesGroupForExport(*contextmodel.ReqContext) response.Response
}

type RulerApiHandler

type RulerApiHandler struct {
	LotexRuler      *LotexRuler
	GrafanaRuler    *RulerSrv
	DatasourceCache datasources.CacheService
}

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

func NewForkingRuler

func NewForkingRuler(datasourceCache datasources.CacheService, lotex *LotexRuler, grafana *RulerSrv) *RulerApiHandler

func (*RulerApiHandler) RouteDeleteGrafanaRuleGroupConfig

func (f *RulerApiHandler) RouteDeleteGrafanaRuleGroupConfig(ctx *contextmodel.ReqContext) response.Response

func (*RulerApiHandler) RouteDeleteNamespaceGrafanaRulesConfig

func (f *RulerApiHandler) RouteDeleteNamespaceGrafanaRulesConfig(ctx *contextmodel.ReqContext) response.Response

func (*RulerApiHandler) RouteDeleteNamespaceRulesConfig

func (f *RulerApiHandler) RouteDeleteNamespaceRulesConfig(ctx *contextmodel.ReqContext) response.Response

func (*RulerApiHandler) RouteDeleteRuleGroupConfig

func (f *RulerApiHandler) RouteDeleteRuleGroupConfig(ctx *contextmodel.ReqContext) response.Response

func (*RulerApiHandler) RouteGetGrafanaRuleGroupConfig

func (f *RulerApiHandler) RouteGetGrafanaRuleGroupConfig(ctx *contextmodel.ReqContext) response.Response

func (*RulerApiHandler) RouteGetGrafanaRulesConfig

func (f *RulerApiHandler) RouteGetGrafanaRulesConfig(ctx *contextmodel.ReqContext) response.Response

func (*RulerApiHandler) RouteGetNamespaceGrafanaRulesConfig

func (f *RulerApiHandler) RouteGetNamespaceGrafanaRulesConfig(ctx *contextmodel.ReqContext) response.Response

func (*RulerApiHandler) RouteGetNamespaceRulesConfig

func (f *RulerApiHandler) RouteGetNamespaceRulesConfig(ctx *contextmodel.ReqContext) response.Response

func (*RulerApiHandler) RouteGetRuleByUID

func (f *RulerApiHandler) RouteGetRuleByUID(ctx *contextmodel.ReqContext) response.Response

func (*RulerApiHandler) RouteGetRulegGroupConfig

func (f *RulerApiHandler) RouteGetRulegGroupConfig(ctx *contextmodel.ReqContext) response.Response

func (*RulerApiHandler) RouteGetRulesConfig

func (f *RulerApiHandler) RouteGetRulesConfig(ctx *contextmodel.ReqContext) response.Response

func (*RulerApiHandler) RouteGetRulesForExport

func (f *RulerApiHandler) RouteGetRulesForExport(ctx *contextmodel.ReqContext) response.Response

func (*RulerApiHandler) RoutePostNameGrafanaRulesConfig

func (f *RulerApiHandler) RoutePostNameGrafanaRulesConfig(ctx *contextmodel.ReqContext) response.Response

func (*RulerApiHandler) RoutePostNameRulesConfig

func (f *RulerApiHandler) RoutePostNameRulesConfig(ctx *contextmodel.ReqContext) response.Response

func (*RulerApiHandler) RoutePostRulesGroupForExport

func (f *RulerApiHandler) RoutePostRulesGroupForExport(ctx *contextmodel.ReqContext) response.Response

type RulerSrv

type RulerSrv struct {
	QuotaService quota.Service
	// contains filtered or unexported fields
}

func (RulerSrv) ExportFromPayload

func (srv RulerSrv) ExportFromPayload(c *contextmodel.ReqContext, ruleGroupConfig apimodels.PostableRuleGroupConfig, namespaceUID string) response.Response

ExportFromPayload converts the rule groups from the argument `ruleGroupConfig` to export format. All rules are expected to be fully specified. The access to data sources mentioned in the rules is not enforced. Can return 403 StatusForbidden if user is not authorized to read folder `namespaceUID`

func (RulerSrv) ExportRules

func (srv RulerSrv) ExportRules(c *contextmodel.ReqContext) response.Response

ExportRules reads alert rules that user has access to from database according to the filters.

func (RulerSrv) RouteDeleteAlertRules

func (srv RulerSrv) RouteDeleteAlertRules(c *contextmodel.ReqContext, namespaceUID string, group string) response.Response

RouteDeleteAlertRules deletes all alert rules the user is authorized to access in the given namespace or, if non-empty, a specific group of rules in the namespace. Returns http.StatusForbidden if user does not have access to any of the rules that match the filter. Returns http.StatusBadRequest if all rules that match the filter and the user is authorized to delete are provisioned.

func (RulerSrv) RouteGetNamespaceRulesConfig

func (srv RulerSrv) RouteGetNamespaceRulesConfig(c *contextmodel.ReqContext, namespaceUID string) response.Response

RouteGetNamespaceRulesConfig returns all rules in a specific folder that user has access to

func (RulerSrv) RouteGetRuleByUID

func (srv RulerSrv) RouteGetRuleByUID(c *contextmodel.ReqContext, ruleUID string) response.Response

RouteGetRuleByUID returns the alert rule with the given UID

func (RulerSrv) RouteGetRulesConfig

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

RouteGetRulesConfig returns all alert rules that are available to the current user

func (RulerSrv) RouteGetRulesGroupConfig

func (srv RulerSrv) RouteGetRulesGroupConfig(c *contextmodel.ReqContext, namespaceUID string, ruleGroup string) response.Response

RouteGetRulesGroupConfig returns rules that belong to a specific group in a specific namespace (folder). If user does not have access to at least one of the rule in the group, returns status 403 Forbidden

func (RulerSrv) RoutePostNameRulesConfig

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

type SilenceService

type SilenceService interface {
	GetSilence(ctx context.Context, user identity.Requester, silenceID string) (*models.Silence, error)
	ListSilences(ctx context.Context, user identity.Requester, filter []string) ([]*models.Silence, error)
	CreateSilence(ctx context.Context, user identity.Requester, ps models.Silence) (string, error)
	UpdateSilence(ctx context.Context, user identity.Requester, ps models.Silence) (string, error)
	DeleteSilence(ctx context.Context, user identity.Requester, silenceID string) error
	WithAccessControlMetadata(ctx context.Context, user identity.Requester, silencesWithMetadata ...*models.SilenceWithMetadata) error
	WithRuleMetadata(ctx context.Context, user identity.Requester, silences ...*models.SilenceWithMetadata) error
}

SilenceService is the service for managing and authenticating silences access in Grafana AM.

type TemplateService

type TemplateService interface {
	GetTemplates(ctx context.Context, orgID int64) ([]definitions.NotificationTemplate, error)
	SetTemplate(ctx context.Context, orgID int64, tmpl definitions.NotificationTemplate) (definitions.NotificationTemplate, error)
	DeleteTemplate(ctx context.Context, orgID int64, name string) error
}

type TestingApi

type TestingApi interface {
	BacktestConfig(*contextmodel.ReqContext) response.Response
	RouteEvalQueries(*contextmodel.ReqContext) response.Response
	RouteTestRuleConfig(*contextmodel.ReqContext) response.Response
	RouteTestRuleGrafanaConfig(*contextmodel.ReqContext) response.Response
}

type TestingApiHandler

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

TestingApiHandler always forwards requests to grafana backend

func NewTestingApi

func NewTestingApi(svc *TestingApiSrv) *TestingApiHandler

func (*TestingApiHandler) BacktestConfig

func (f *TestingApiHandler) BacktestConfig(ctx *contextmodel.ReqContext) response.Response

func (*TestingApiHandler) RouteEvalQueries

func (f *TestingApiHandler) RouteEvalQueries(ctx *contextmodel.ReqContext) response.Response

func (*TestingApiHandler) RouteTestRuleConfig

func (f *TestingApiHandler) RouteTestRuleConfig(ctx *contextmodel.ReqContext) response.Response

func (*TestingApiHandler) RouteTestRuleGrafanaConfig

func (f *TestingApiHandler) RouteTestRuleGrafanaConfig(ctx *contextmodel.ReqContext) response.Response

type TestingApiSrv

type TestingApiSrv struct {
	*AlertingProxy
	DatasourceCache datasources.CacheService
	// contains filtered or unexported fields
}

func (TestingApiSrv) BacktestAlertRule

func (TestingApiSrv) RouteEvalQueries

func (TestingApiSrv) RouteTestGrafanaRuleConfig

RouteTestGrafanaRuleConfig returns a list of potential alerts for a given rule configuration. This is intended to be as true as possible to what would be generated by the ruler except that the resulting alerts are not filtered to only Resolved / Firing and ready to send.

func (TestingApiSrv) RouteTestRuleConfig

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

type UnknownReceiverError

type UnknownReceiverError struct {
	UID string
}

func (UnknownReceiverError) Error

func (e UnknownReceiverError) Error() string

Directories

Path Synopsis
tooling
definitions
Grafana Alerting API.
Grafana Alerting API.

Jump to

Keyboard shortcuts

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