api

package
v0.0.0-...-56fe054 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: AGPL-3.0 Imports: 81 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"
)

Variables

This section is empty.

Functions

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 NewFakeAlertInstanceManager

func NewFakeAlertInstanceManager(t *testing.T) *fakeAlertInstanceManager

func PostableSilenceToSilence

func PostableSilenceToSilence(s definitions.PostableSilence) models.Silence

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

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
	Scheduler            apiprometheus.StatusReader
	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
	ConditionValidator   *eval.ConditionValidator
	FeatureManager       featuremgmt.FeatureToggles
	Historian            Historian
	Tracer               tracing.Tracer
	AppUrl               *url.URL
	UserService          user.Service

	// 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) RegisterConvertPrometheusApiEndpoints

func (api *API) RegisterConvertPrometheusApiEndpoints(srv ConvertPrometheusApi, m *metrics.API)

func (*API) RegisterHistoryApiEndpoints

func (api *API) RegisterHistoryApiEndpoints(srv HistoryApi, 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
	DeleteRuleGroups(ctx context.Context, user identity.Requester, provenance alerting_models.Provenance, opts *provisioning.FilterOptions) 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, opts *provisioning.FilterOptions) ([]alerting_models.AlertRuleGroupWithFolderFullpath, error)
}

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 Alertmanager

type Alertmanager interface {
	DeleteExtraConfiguration(ctx context.Context, org int64, identifier string) error
	SaveAndApplyExtraConfiguration(ctx context.Context, org int64, extraConfig apimodels.ExtraConfiguration) error
	GetAlertmanagerConfiguration(ctx context.Context, org int64, withAutogen bool, withMergedExtraConfig bool) (apimodels.GettableUserConfig, 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
	RoutePostGrafanaAlertingConfigHistoryActivate(*contextmodel.ReqContext) response.Response
	RoutePostTestGrafanaReceivers(*contextmodel.ReqContext) response.Response
	RoutePostTestGrafanaTemplates(*contextmodel.ReqContext) response.Response
}

type AlertmanagerApiHandler

type AlertmanagerApiHandler struct {
	AMSvc           *LotexAM
	GrafanaSvc      *AlertmanagerSrv
	ConvertSvc      ConvertService
	DatasourceCache datasources.CacheService
	FeatureManager  featuremgmt.FeatureToggles
}

func NewForkingAM

func NewForkingAM(datasourceCache datasources.CacheService, proxy *LotexAM, grafana *AlertmanagerSrv, convertSvc ConvertService, featureManager featuremgmt.FeatureToggles) *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) 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) 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, user identity.Requester, 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 ConvertPrometheusApi

type ConvertPrometheusApi interface {
	RouteConvertPrometheusCortexDeleteNamespace(*contextmodel.ReqContext) response.Response
	RouteConvertPrometheusCortexDeleteRuleGroup(*contextmodel.ReqContext) response.Response
	RouteConvertPrometheusCortexGetNamespace(*contextmodel.ReqContext) response.Response
	RouteConvertPrometheusCortexGetRuleGroup(*contextmodel.ReqContext) response.Response
	RouteConvertPrometheusCortexGetRules(*contextmodel.ReqContext) response.Response
	RouteConvertPrometheusCortexPostRuleGroup(*contextmodel.ReqContext) response.Response
	RouteConvertPrometheusCortexPostRuleGroups(*contextmodel.ReqContext) response.Response
	RouteConvertPrometheusDeleteAlertmanagerConfig(*contextmodel.ReqContext) response.Response
	RouteConvertPrometheusDeleteNamespace(*contextmodel.ReqContext) response.Response
	RouteConvertPrometheusDeleteRuleGroup(*contextmodel.ReqContext) response.Response
	RouteConvertPrometheusGetAlertmanagerConfig(*contextmodel.ReqContext) response.Response
	RouteConvertPrometheusGetNamespace(*contextmodel.ReqContext) response.Response
	RouteConvertPrometheusGetRuleGroup(*contextmodel.ReqContext) response.Response
	RouteConvertPrometheusGetRules(*contextmodel.ReqContext) response.Response
	RouteConvertPrometheusPostAlertmanagerConfig(*contextmodel.ReqContext) response.Response
	RouteConvertPrometheusPostRuleGroup(*contextmodel.ReqContext) response.Response
	RouteConvertPrometheusPostRuleGroups(*contextmodel.ReqContext) response.Response
}

type ConvertPrometheusApiHandler

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

func (*ConvertPrometheusApiHandler) RouteConvertPrometheusCortexDeleteNamespace

func (f *ConvertPrometheusApiHandler) RouteConvertPrometheusCortexDeleteNamespace(ctx *contextmodel.ReqContext) response.Response

func (*ConvertPrometheusApiHandler) RouteConvertPrometheusCortexDeleteRuleGroup

func (f *ConvertPrometheusApiHandler) RouteConvertPrometheusCortexDeleteRuleGroup(ctx *contextmodel.ReqContext) response.Response

func (*ConvertPrometheusApiHandler) RouteConvertPrometheusCortexGetNamespace

func (f *ConvertPrometheusApiHandler) RouteConvertPrometheusCortexGetNamespace(ctx *contextmodel.ReqContext) response.Response

func (*ConvertPrometheusApiHandler) RouteConvertPrometheusCortexGetRuleGroup

func (f *ConvertPrometheusApiHandler) RouteConvertPrometheusCortexGetRuleGroup(ctx *contextmodel.ReqContext) response.Response

func (*ConvertPrometheusApiHandler) RouteConvertPrometheusCortexGetRules

func (f *ConvertPrometheusApiHandler) RouteConvertPrometheusCortexGetRules(ctx *contextmodel.ReqContext) response.Response

func (*ConvertPrometheusApiHandler) RouteConvertPrometheusCortexPostRuleGroup

func (f *ConvertPrometheusApiHandler) RouteConvertPrometheusCortexPostRuleGroup(ctx *contextmodel.ReqContext) response.Response

func (*ConvertPrometheusApiHandler) RouteConvertPrometheusCortexPostRuleGroups

func (f *ConvertPrometheusApiHandler) RouteConvertPrometheusCortexPostRuleGroups(ctx *contextmodel.ReqContext) response.Response

func (*ConvertPrometheusApiHandler) RouteConvertPrometheusDeleteAlertmanagerConfig

func (f *ConvertPrometheusApiHandler) RouteConvertPrometheusDeleteAlertmanagerConfig(ctx *contextmodel.ReqContext) response.Response

func (*ConvertPrometheusApiHandler) RouteConvertPrometheusDeleteNamespace

func (f *ConvertPrometheusApiHandler) RouteConvertPrometheusDeleteNamespace(ctx *contextmodel.ReqContext) response.Response

func (*ConvertPrometheusApiHandler) RouteConvertPrometheusDeleteRuleGroup

func (f *ConvertPrometheusApiHandler) RouteConvertPrometheusDeleteRuleGroup(ctx *contextmodel.ReqContext) response.Response

func (*ConvertPrometheusApiHandler) RouteConvertPrometheusGetAlertmanagerConfig

func (f *ConvertPrometheusApiHandler) RouteConvertPrometheusGetAlertmanagerConfig(ctx *contextmodel.ReqContext) response.Response

func (*ConvertPrometheusApiHandler) RouteConvertPrometheusGetNamespace

func (f *ConvertPrometheusApiHandler) RouteConvertPrometheusGetNamespace(ctx *contextmodel.ReqContext) response.Response

func (*ConvertPrometheusApiHandler) RouteConvertPrometheusGetRuleGroup

func (f *ConvertPrometheusApiHandler) RouteConvertPrometheusGetRuleGroup(ctx *contextmodel.ReqContext) response.Response

func (*ConvertPrometheusApiHandler) RouteConvertPrometheusGetRules

func (f *ConvertPrometheusApiHandler) RouteConvertPrometheusGetRules(ctx *contextmodel.ReqContext) response.Response

func (*ConvertPrometheusApiHandler) RouteConvertPrometheusPostAlertmanagerConfig

func (f *ConvertPrometheusApiHandler) RouteConvertPrometheusPostAlertmanagerConfig(ctx *contextmodel.ReqContext) response.Response

func (*ConvertPrometheusApiHandler) RouteConvertPrometheusPostRuleGroup

func (f *ConvertPrometheusApiHandler) RouteConvertPrometheusPostRuleGroup(ctx *contextmodel.ReqContext) response.Response

func (*ConvertPrometheusApiHandler) RouteConvertPrometheusPostRuleGroups

func (f *ConvertPrometheusApiHandler) RouteConvertPrometheusPostRuleGroups(ctx *contextmodel.ReqContext) response.Response

type ConvertPrometheusSrv

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

ConvertPrometheusSrv converts Prometheus rules to Grafana rules and retrieves them in a Prometheus-compatible format.

It is designed to support mimirtool integration, so that rules that work with Mimir can be imported into Grafana. It works similarly to the provisioning API, where once a rule group is created, it is marked as "provisioned" (via provenance mechanism) and is not editable in the UI.

This service returns only rule groups that were initially imported from Prometheus-compatible sources. Rule groups not imported from Prometheus are excluded because their original rule definitions are unavailable. When a rule group is converted from Prometheus to Grafana, the original definition is preserved alongside the Grafana rule and used for reading requests here.

Folder Structure Handling: mimirtool does not support nested folder structures, while Grafana allows folder nesting. To keep compatibility, this service only returns direct child folders of the working folder as namespaces, and rule groups and rules that are directly in these child folders.

For example, given this folder structure in Grafana:

grafana/
├── production/
│   ├── service1/
│   │   └── alerts/
│   └── service2/
└── testing/
    └── service3/

If the working folder is "grafana":

  • Only namespaces "production" and "testing" are returned
  • Only rule groups directly within these folders are included

If the working folder is "production":

  • Only namespaces "service1" and "service2" are returned
  • Only rule groups directly within these folders are included

The "working folder" is specified by the X-Grafana-Alerting-Folder-UID header, which can be set to any folder UID, and defaults to the root folder if not provided.

func NewConvertPrometheusSrv

func NewConvertPrometheusSrv(
	cfg *setting.UnifiedAlertingSettings,
	logger log.Logger,
	ruleStore RuleStore,
	datasourceCache datasources.CacheService,
	alertRuleService *provisioning.AlertRuleService,
	featureToggles featuremgmt.FeatureToggles,
	am Alertmanager,
) *ConvertPrometheusSrv

func (*ConvertPrometheusSrv) RouteConvertPrometheusDeleteAlertmanagerConfig

func (srv *ConvertPrometheusSrv) RouteConvertPrometheusDeleteAlertmanagerConfig(c *contextmodel.ReqContext) response.Response

func (*ConvertPrometheusSrv) RouteConvertPrometheusDeleteNamespace

func (srv *ConvertPrometheusSrv) RouteConvertPrometheusDeleteNamespace(c *contextmodel.ReqContext, namespaceTitle string) response.Response

RouteConvertPrometheusDeleteNamespace deletes all rule groups that were imported from a Prometheus-compatible source within a specified namespace.

func (*ConvertPrometheusSrv) RouteConvertPrometheusDeleteRuleGroup

func (srv *ConvertPrometheusSrv) RouteConvertPrometheusDeleteRuleGroup(c *contextmodel.ReqContext, namespaceTitle string, group string) response.Response

RouteConvertPrometheusDeleteRuleGroup deletes a specific rule group if it was imported from a Prometheus-compatible source.

func (*ConvertPrometheusSrv) RouteConvertPrometheusGetAlertmanagerConfig

func (srv *ConvertPrometheusSrv) RouteConvertPrometheusGetAlertmanagerConfig(c *contextmodel.ReqContext) response.Response

func (*ConvertPrometheusSrv) RouteConvertPrometheusGetNamespace

func (srv *ConvertPrometheusSrv) RouteConvertPrometheusGetNamespace(c *contextmodel.ReqContext, namespaceTitle string) response.Response

RouteConvertPrometheusGetNamespace returns the Grafana-managed alert rules for a specified namespace (folder). It responds with JSON or YAML containing a mapping of a single folder to an array of Prometheus rule groups.

func (*ConvertPrometheusSrv) RouteConvertPrometheusGetRuleGroup

func (srv *ConvertPrometheusSrv) RouteConvertPrometheusGetRuleGroup(c *contextmodel.ReqContext, namespaceTitle string, group string) response.Response

RouteConvertPrometheusGetRuleGroup retrieves a single rule group for a given namespace (folder) in Prometheus-compatible JSON or YAML format if it was imported from a Prometheus-compatible source.

func (*ConvertPrometheusSrv) RouteConvertPrometheusGetRules

func (srv *ConvertPrometheusSrv) RouteConvertPrometheusGetRules(c *contextmodel.ReqContext) response.Response

RouteConvertPrometheusGetRules returns all Grafana-managed alert rules in all namespaces (folders) that were imported from a Prometheus-compatible source. It responds with JSON or YAML containing a mapping of folders to arrays of Prometheus rule groups.

func (*ConvertPrometheusSrv) RouteConvertPrometheusPostAlertmanagerConfig

func (srv *ConvertPrometheusSrv) RouteConvertPrometheusPostAlertmanagerConfig(c *contextmodel.ReqContext, amCfg apimodels.AlertmanagerUserConfig) response.Response

func (*ConvertPrometheusSrv) RouteConvertPrometheusPostRuleGroup

func (srv *ConvertPrometheusSrv) RouteConvertPrometheusPostRuleGroup(c *contextmodel.ReqContext, namespaceTitle string, promGroup apimodels.PrometheusRuleGroup) response.Response

RouteConvertPrometheusPostRuleGroup converts a Prometheus rule group into a Grafana rule group and creates or updates it within the specified namespace (folder).

If the group already exists and was not imported from a Prometheus-compatible source initially, it will not be replaced and an error will be returned.

func (*ConvertPrometheusSrv) RouteConvertPrometheusPostRuleGroups

func (srv *ConvertPrometheusSrv) RouteConvertPrometheusPostRuleGroups(c *contextmodel.ReqContext, promNamespaces map[string][]apimodels.PrometheusRuleGroup) response.Response

type ConvertService

type ConvertService interface {
	RouteConvertPrometheusGetAlertmanagerConfig(ctx *contextmodel.ReqContext) response.Response
}

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 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, string, error)
	UpdatePolicyTree(ctx context.Context, orgID int64, tree definitions.Route, p alerting_models.Provenance, version string) (definitions.Route, string, error)
	ResetPolicyTree(ctx context.Context, orgID int64, provenance alerting_models.Provenance) (definitions.Route, error)
}

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      *apiprometheus.PrometheusSrv
	DatasourceCache datasources.CacheService
}

func NewForkingProm

func NewForkingProm(datasourceCache datasources.CacheService, proxy *LotexProm, grafana *apiprometheus.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 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, nameOrUid 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, nameOrUid 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 ReceiverStatus

type ReceiverStatus apimodels.Receiver

func (ReceiverStatus) GetUID

func (rs ReceiverStatus) GetUID() string

type ReceiversDelta

type ReceiversDelta struct {
	Created []*apimodels.PostableApiReceiver
	Updated []*apimodels.GettableApiReceiver
	Deleted []*apimodels.GettableApiReceiver
}

ReceiversDelta represents the changes to receivers in the alertmanager configuration.

func (ReceiversDelta) IsEmpty

func (d ReceiversDelta) IsEmpty() bool

IsEmpty returns true if the delta contains no changes.

func (ReceiversDelta) ProvisionedSubset

func (d ReceiversDelta) ProvisionedSubset() ReceiversDelta

ProvisionedSubset returns a subset of the delta containing only integrations that were provisioned.

func (ReceiversDelta) String

func (d ReceiversDelta) String() string

String returns a human-readable representation of the delta for error messages.

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 models.Namespaced) error
}

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.FolderReference
	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)
	GetNamespaceByTitle(ctx context.Context, fullpath string, orgID int64, user identity.Requester, parentUID string) (*folder.FolderReference, error)
	GetOrCreateNamespaceByTitle(ctx context.Context, title string, orgID int64, user identity.Requester, parentUID string) (*folder.FolderReference, bool, error)
	// GetNamespaceChildren returns all children (first level) of the namespace with the given id.
	GetNamespaceChildren(ctx context.Context, uid string, orgID int64, user identity.Requester) ([]*folder.FolderReference, 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)
	ListAlertRulesByGroup(ctx context.Context, query *ngmodels.ListAlertRulesByGroupQuery) (ngmodels.RulesGroup, string, error)
	ListDeletedRules(ctx context.Context, orgID int64) ([]*ngmodels.AlertRule, error)

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

	// IncreaseVersionForAllRulesInNamespaces Increases version for all rules that have specified namespace uids
	IncreaseVersionForAllRulesInNamespaces(ctx context.Context, orgID int64, namespaceUIDs []string) ([]ngmodels.AlertRuleKeyWithVersion, error)
	GetAlertRuleVersions(ctx context.Context, orgID int64, guid string) ([]*ngmodels.AlertRule, 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
	RouteDeleteRuleFromTrashByGUID(*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
	RouteGetRuleVersionsByUID(*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
	RouteUpdateNamespaceRules(*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) RouteDeleteRuleFromTrashByGUID

func (f *RulerApiHandler) RouteDeleteRuleFromTrashByGUID(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) RouteGetRuleVersionsByUID

func (f *RulerApiHandler) RouteGetRuleVersionsByUID(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

func (*RulerApiHandler) RouteUpdateNamespaceRules

func (f *RulerApiHandler) RouteUpdateNamespaceRules(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) RouteDeleteAlertRuleFromTrashByGUID

func (srv RulerSrv) RouteDeleteAlertRuleFromTrashByGUID(ctx *contextmodel.ReqContext, guid string) response.Response

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) RouteGetRuleVersionsByUID

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

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

func (RulerSrv) RouteUpdateNamespaceRules

func (srv RulerSrv) RouteUpdateNamespaceRules(c *contextmodel.ReqContext, body apimodels.UpdateNamespaceRulesRequest, namespaceUID string) response.Response

RouteUpdateNamespaceRules updates all alert rules in a namespace.

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)
	GetTemplate(ctx context.Context, orgID int64, nameOrUid string) (definitions.NotificationTemplate, error)
	UpsertTemplate(ctx context.Context, orgID int64, tmpl definitions.NotificationTemplate) (definitions.NotificationTemplate, error)
	DeleteTemplate(ctx context.Context, orgID int64, nameOrUid string, provenance definitions.Provenance, version 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
⌂ 换网址