Documentation ¶
Index ¶
- Constants
- Variables
- type AdminConfigurationStore
- type AdminConfigurationStoreMock
- func (_m *AdminConfigurationStoreMock) DeleteAdminConfiguration(orgID int64) error
- func (_m *AdminConfigurationStoreMock) EXPECT() *AdminConfigurationStoreMock_Expecter
- func (_m *AdminConfigurationStoreMock) GetAdminConfiguration(orgID int64) (*models.AdminConfiguration, error)
- func (_m *AdminConfigurationStoreMock) GetAdminConfigurations() ([]*models.AdminConfiguration, error)
- func (_m *AdminConfigurationStoreMock) UpdateAdminConfiguration(_a0 UpdateAdminConfigurationCmd) error
- type AdminConfigurationStoreMock_DeleteAdminConfiguration_Call
- func (_c *AdminConfigurationStoreMock_DeleteAdminConfiguration_Call) Return(_a0 error) *AdminConfigurationStoreMock_DeleteAdminConfiguration_Call
- func (_c *AdminConfigurationStoreMock_DeleteAdminConfiguration_Call) Run(run func(orgID int64)) *AdminConfigurationStoreMock_DeleteAdminConfiguration_Call
- type AdminConfigurationStoreMock_Expecter
- func (_e *AdminConfigurationStoreMock_Expecter) DeleteAdminConfiguration(orgID interface{}) *AdminConfigurationStoreMock_DeleteAdminConfiguration_Call
- func (_e *AdminConfigurationStoreMock_Expecter) GetAdminConfiguration(orgID interface{}) *AdminConfigurationStoreMock_GetAdminConfiguration_Call
- func (_e *AdminConfigurationStoreMock_Expecter) GetAdminConfigurations() *AdminConfigurationStoreMock_GetAdminConfigurations_Call
- func (_e *AdminConfigurationStoreMock_Expecter) UpdateAdminConfiguration(_a0 interface{}) *AdminConfigurationStoreMock_UpdateAdminConfiguration_Call
- type AdminConfigurationStoreMock_GetAdminConfiguration_Call
- func (_c *AdminConfigurationStoreMock_GetAdminConfiguration_Call) Return(_a0 *models.AdminConfiguration, _a1 error) *AdminConfigurationStoreMock_GetAdminConfiguration_Call
- func (_c *AdminConfigurationStoreMock_GetAdminConfiguration_Call) Run(run func(orgID int64)) *AdminConfigurationStoreMock_GetAdminConfiguration_Call
- type AdminConfigurationStoreMock_GetAdminConfigurations_Call
- func (_c *AdminConfigurationStoreMock_GetAdminConfigurations_Call) Return(_a0 []*models.AdminConfiguration, _a1 error) *AdminConfigurationStoreMock_GetAdminConfigurations_Call
- func (_c *AdminConfigurationStoreMock_GetAdminConfigurations_Call) Run(run func()) *AdminConfigurationStoreMock_GetAdminConfigurations_Call
- type AdminConfigurationStoreMock_UpdateAdminConfiguration_Call
- func (_c *AdminConfigurationStoreMock_UpdateAdminConfiguration_Call) Return(_a0 error) *AdminConfigurationStoreMock_UpdateAdminConfiguration_Call
- func (_c *AdminConfigurationStoreMock_UpdateAdminConfiguration_Call) Run(run func(_a0 UpdateAdminConfigurationCmd)) *AdminConfigurationStoreMock_UpdateAdminConfiguration_Call
- type AlertingStore
- type DBstore
- func (st DBstore) Count(ctx context.Context, orgID int64) (int64, error)
- func (st DBstore) CountInFolder(ctx context.Context, orgID int64, folderUID string, u *user.SignedInUser) (int64, error)
- func (st DBstore) DeleteAdminConfiguration(orgID int64) error
- func (st DBstore) DeleteAlertInstances(ctx context.Context, keys ...models.AlertInstanceKey) error
- func (st DBstore) DeleteAlertInstancesByRule(ctx context.Context, key models.AlertRuleKey) error
- func (st DBstore) DeleteAlertRulesByUID(ctx context.Context, orgID int64, ruleUID ...string) error
- func (st DBstore) DeleteExpiredImages(ctx context.Context) (int64, error)
- func (st DBstore) DeleteInFolder(ctx context.Context, orgID int64, folderUID string, user *user.SignedInUser) error
- func (st DBstore) DeleteProvenance(ctx context.Context, o models.Provisionable, org int64) error
- func (st DBstore) FetchOrgIds(ctx context.Context) ([]int64, error)
- func (st *DBstore) GetAdminConfiguration(orgID int64) (*ngmodels.AdminConfiguration, error)
- func (st DBstore) GetAdminConfigurations() ([]*ngmodels.AdminConfiguration, error)
- func (st DBstore) GetAlertRuleByUID(ctx context.Context, query *ngmodels.GetAlertRuleByUIDQuery) (result *ngmodels.AlertRule, err error)
- func (st DBstore) GetAlertRulesForScheduling(ctx context.Context, query *ngmodels.GetAlertRulesForSchedulingQuery) error
- func (st DBstore) GetAlertRulesGroupByRuleUID(ctx context.Context, query *ngmodels.GetAlertRulesGroupByRuleUIDQuery) (result []*ngmodels.AlertRule, err error)
- func (st DBstore) GetAlertRulesKeysForScheduling(ctx context.Context) ([]ngmodels.AlertRuleKeyWithVersion, error)
- func (st *DBstore) GetAllLatestAlertmanagerConfiguration(ctx context.Context) ([]*models.AlertConfiguration, error)
- func (st *DBstore) GetAppliedConfigurations(ctx context.Context, orgID int64, limit int) ([]*models.HistoricAlertConfiguration, error)
- func (st *DBstore) GetHistoricalConfiguration(ctx context.Context, orgID int64, id int64) (*models.HistoricAlertConfiguration, error)
- func (st DBstore) GetImage(ctx context.Context, token string) (*models.Image, error)
- func (st DBstore) GetImageByURL(ctx context.Context, url string) (*models.Image, error)
- func (st DBstore) GetImages(ctx context.Context, tokens []string) ([]models.Image, []string, error)
- func (st *DBstore) GetLatestAlertmanagerConfiguration(ctx context.Context, query *models.GetLatestAlertmanagerConfigurationQuery) (result *models.AlertConfiguration, err error)
- func (st DBstore) GetNamespaceByTitle(ctx context.Context, namespace string, orgID int64, user *user.SignedInUser) (*folder.Folder, error)
- func (st DBstore) GetNamespaceByUID(ctx context.Context, uid string, orgID int64, user *user.SignedInUser) (*folder.Folder, error)
- func (st DBstore) GetOrgs(ctx context.Context) ([]int64, error)
- func (st DBstore) GetProvenance(ctx context.Context, o models.Provisionable, org int64) (models.Provenance, error)
- func (st DBstore) GetProvenances(ctx context.Context, org int64, resourceType string) (map[string]models.Provenance, error)
- func (st DBstore) GetRuleGroupInterval(ctx context.Context, orgID int64, namespaceUID string, ruleGroup string) (int64, error)
- func (st DBstore) GetUserVisibleNamespaces(ctx context.Context, orgID int64, user *user.SignedInUser) (map[string]*folder.Folder, error)
- func (st *DBstore) InTransaction(ctx context.Context, f func(ctx context.Context) error) error
- func (st DBstore) IncreaseVersionForAllRulesInNamespace(ctx context.Context, orgID int64, namespaceUID string) ([]ngmodels.AlertRuleKeyWithVersionAndPauseStatus, error)
- func (st DBstore) InsertAlertRules(ctx context.Context, rules []ngmodels.AlertRule) (map[string]int64, error)
- func (st DBstore) Kind() string
- func (st DBstore) ListAlertInstances(ctx context.Context, cmd *models.ListAlertInstancesQuery) (result []*models.AlertInstance, err error)
- func (st DBstore) ListAlertRules(ctx context.Context, query *ngmodels.ListAlertRulesQuery) (result ngmodels.RulesGroup, err error)
- func (st *DBstore) MarkConfigurationAsApplied(ctx context.Context, cmd *models.MarkConfigurationAsAppliedCmd) error
- func (st DBstore) SaveAlertInstance(ctx context.Context, alertInstance models.AlertInstance) error
- func (st DBstore) SaveAlertmanagerConfiguration(ctx context.Context, cmd *models.SaveAlertmanagerConfigurationCmd) error
- func (st DBstore) SaveAlertmanagerConfigurationWithCallback(ctx context.Context, cmd *models.SaveAlertmanagerConfigurationCmd, ...) error
- func (st DBstore) SaveImage(ctx context.Context, img *models.Image) error
- func (st DBstore) SetProvenance(ctx context.Context, o models.Provisionable, org int64, p models.Provenance) error
- func (st DBstore) URLExists(ctx context.Context, url string) (bool, error)
- func (st DBstore) UpdateAdminConfiguration(cmd UpdateAdminConfigurationCmd) error
- func (st DBstore) UpdateAlertRules(ctx context.Context, rules []ngmodels.UpdateRule) error
- func (st *DBstore) UpdateAlertmanagerConfiguration(ctx context.Context, cmd *models.SaveAlertmanagerConfigurationCmd) error
- type FakeAdminConfigStore
- func (f *FakeAdminConfigStore) DeleteAdminConfiguration(orgID int64) error
- func (f *FakeAdminConfigStore) GetAdminConfiguration(orgID int64) (*models.AdminConfiguration, error)
- func (f *FakeAdminConfigStore) GetAdminConfigurations() ([]*models.AdminConfiguration, error)
- func (f *FakeAdminConfigStore) UpdateAdminConfiguration(cmd UpdateAdminConfigurationCmd) error
- type FakeImageStore
- func (s *FakeImageStore) GetImage(_ context.Context, token string) (*models.Image, error)
- func (s *FakeImageStore) GetImageByURL(_ context.Context, url string) (*models.Image, error)
- func (s *FakeImageStore) GetImages(_ context.Context, tokens []string) ([]models.Image, []string, error)
- func (s *FakeImageStore) SaveImage(_ context.Context, image *models.Image) error
- func (s *FakeImageStore) URLExists(_ context.Context, url string) (bool, error)
- type GroupDelta
- type ImageAdminStore
- type ImageStore
- type OrgStore
- type RuleDelta
- type RuleReader
- type SaveCallback
- type UpdateAdminConfigurationCmd
Constants ¶
const AlertDefinitionMaxTitleLength = 190
AlertDefinitionMaxTitleLength is the maximum length of the alert definition title
const AlertRuleMaxRuleGroupNameLength = 190
AlertRuleMaxRuleGroupNameLength is the maximum length of the alert rule group name
const AlertRuleMaxTitleLength = 190
AlertRuleMaxTitleLength is the maximum length of the alert rule title
Variables ¶
var ( ErrAlertRuleGroupNotFound = errors.New("rulegroup not found") ErrOptimisticLock = errors.New("version conflict while updating a record in the database with optimistic locking") )
var ( // ErrNoAlertmanagerConfiguration is an error for when no alertmanager configuration is found. ErrNoAlertmanagerConfiguration = fmt.Errorf("could not find an Alertmanager configuration") // ErrVersionLockedObjectNotFound is returned when an object is not // found using the current hash. ErrVersionLockedObjectNotFound = fmt.Errorf("could not find object using provided id and hash") // ConfigRecordsLimit defines the limit of how many alertmanager configuration versions // should be stored in the database for each organization including the current one. // Has to be > 0 ConfigRecordsLimit int = 100 )
var AlertRuleFieldsToIgnoreInDiff = [...]string{"ID", "Version", "Updated"}
AlertRuleFieldsToIgnoreInDiff contains fields that are ignored when calculating the RuleDelta.Diff.
var ( // ErrNoAdminConfiguration is an error for when no admin configuration is found. ErrNoAdminConfiguration = fmt.Errorf("no admin configuration available") )
var GenerateNewAlertRuleUID = func(sess *db.Session, orgID int64, ruleTitle string) (string, error) { for i := 0; i < 3; i++ { uid := util.GenerateShortUID() exists, err := sess.Where("org_id=? AND uid=?", orgID, uid).Get(&ngmodels.AlertRule{}) if err != nil { return "", err } if !exists { return uid, nil } } return "", ngmodels.ErrAlertRuleFailedGenerateUniqueUID }
GenerateNewAlertRuleUID generates a unique UID for a rule. This is set as a variable so that the tests can override it. The ruleTitle is only used by the mocked functions.
var TimeNow = time.Now
TimeNow makes it possible to test usage of time
Functions ¶
This section is empty.
Types ¶
type AdminConfigurationStore ¶
type AdminConfigurationStore interface { GetAdminConfiguration(orgID int64) (*ngmodels.AdminConfiguration, error) GetAdminConfigurations() ([]*ngmodels.AdminConfiguration, error) DeleteAdminConfiguration(orgID int64) error UpdateAdminConfiguration(UpdateAdminConfigurationCmd) error }
type AdminConfigurationStoreMock ¶
AdminConfigurationStoreMock is an autogenerated mock type for the AdminConfigurationStore type
func (*AdminConfigurationStoreMock) DeleteAdminConfiguration ¶
func (_m *AdminConfigurationStoreMock) DeleteAdminConfiguration(orgID int64) error
DeleteAdminConfiguration provides a mock function with given fields: orgID
func (*AdminConfigurationStoreMock) EXPECT ¶
func (_m *AdminConfigurationStoreMock) EXPECT() *AdminConfigurationStoreMock_Expecter
func (*AdminConfigurationStoreMock) GetAdminConfiguration ¶
func (_m *AdminConfigurationStoreMock) GetAdminConfiguration(orgID int64) (*models.AdminConfiguration, error)
GetAdminConfiguration provides a mock function with given fields: orgID
func (*AdminConfigurationStoreMock) GetAdminConfigurations ¶
func (_m *AdminConfigurationStoreMock) GetAdminConfigurations() ([]*models.AdminConfiguration, error)
GetAdminConfigurations provides a mock function with given fields:
func (*AdminConfigurationStoreMock) UpdateAdminConfiguration ¶
func (_m *AdminConfigurationStoreMock) UpdateAdminConfiguration(_a0 UpdateAdminConfigurationCmd) error
UpdateAdminConfiguration provides a mock function with given fields: _a0
type AdminConfigurationStoreMock_DeleteAdminConfiguration_Call ¶
AdminConfigurationStoreMock_DeleteAdminConfiguration_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteAdminConfiguration'
func (*AdminConfigurationStoreMock_DeleteAdminConfiguration_Call) Run ¶
func (_c *AdminConfigurationStoreMock_DeleteAdminConfiguration_Call) Run(run func(orgID int64)) *AdminConfigurationStoreMock_DeleteAdminConfiguration_Call
type AdminConfigurationStoreMock_Expecter ¶
type AdminConfigurationStoreMock_Expecter struct {
// contains filtered or unexported fields
}
func (*AdminConfigurationStoreMock_Expecter) DeleteAdminConfiguration ¶
func (_e *AdminConfigurationStoreMock_Expecter) DeleteAdminConfiguration(orgID interface{}) *AdminConfigurationStoreMock_DeleteAdminConfiguration_Call
DeleteAdminConfiguration is a helper method to define mock.On call
- orgID int64
func (*AdminConfigurationStoreMock_Expecter) GetAdminConfiguration ¶
func (_e *AdminConfigurationStoreMock_Expecter) GetAdminConfiguration(orgID interface{}) *AdminConfigurationStoreMock_GetAdminConfiguration_Call
GetAdminConfiguration is a helper method to define mock.On call
- orgID int64
func (*AdminConfigurationStoreMock_Expecter) GetAdminConfigurations ¶
func (_e *AdminConfigurationStoreMock_Expecter) GetAdminConfigurations() *AdminConfigurationStoreMock_GetAdminConfigurations_Call
GetAdminConfigurations is a helper method to define mock.On call
func (*AdminConfigurationStoreMock_Expecter) UpdateAdminConfiguration ¶
func (_e *AdminConfigurationStoreMock_Expecter) UpdateAdminConfiguration(_a0 interface{}) *AdminConfigurationStoreMock_UpdateAdminConfiguration_Call
UpdateAdminConfiguration is a helper method to define mock.On call
- _a0 UpdateAdminConfigurationCmd
type AdminConfigurationStoreMock_GetAdminConfiguration_Call ¶
AdminConfigurationStoreMock_GetAdminConfiguration_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetAdminConfiguration'
func (*AdminConfigurationStoreMock_GetAdminConfiguration_Call) Run ¶
func (_c *AdminConfigurationStoreMock_GetAdminConfiguration_Call) Run(run func(orgID int64)) *AdminConfigurationStoreMock_GetAdminConfiguration_Call
type AdminConfigurationStoreMock_GetAdminConfigurations_Call ¶
AdminConfigurationStoreMock_GetAdminConfigurations_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetAdminConfigurations'
func (*AdminConfigurationStoreMock_GetAdminConfigurations_Call) Return ¶
func (_c *AdminConfigurationStoreMock_GetAdminConfigurations_Call) Return(_a0 []*models.AdminConfiguration, _a1 error) *AdminConfigurationStoreMock_GetAdminConfigurations_Call
func (*AdminConfigurationStoreMock_GetAdminConfigurations_Call) Run ¶
func (_c *AdminConfigurationStoreMock_GetAdminConfigurations_Call) Run(run func()) *AdminConfigurationStoreMock_GetAdminConfigurations_Call
type AdminConfigurationStoreMock_UpdateAdminConfiguration_Call ¶
AdminConfigurationStoreMock_UpdateAdminConfiguration_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateAdminConfiguration'
type AlertingStore ¶
type AlertingStore interface { GetLatestAlertmanagerConfiguration(ctx context.Context, query *models.GetLatestAlertmanagerConfigurationQuery) (*models.AlertConfiguration, error) GetAllLatestAlertmanagerConfiguration(ctx context.Context) ([]*models.AlertConfiguration, error) SaveAlertmanagerConfiguration(ctx context.Context, cmd *models.SaveAlertmanagerConfigurationCmd) error SaveAlertmanagerConfigurationWithCallback(ctx context.Context, cmd *models.SaveAlertmanagerConfigurationCmd, callback SaveCallback) error UpdateAlertmanagerConfiguration(ctx context.Context, cmd *models.SaveAlertmanagerConfigurationCmd) error MarkConfigurationAsApplied(ctx context.Context, cmd *models.MarkConfigurationAsAppliedCmd) error GetAppliedConfigurations(ctx context.Context, orgID int64, limit int) ([]*models.HistoricAlertConfiguration, error) GetHistoricalConfiguration(ctx context.Context, orgID int64, id int64) (*models.HistoricAlertConfiguration, error) }
AlertingStore is the database interface used by the Alertmanager service.
type DBstore ¶
type DBstore struct { Cfg setting.UnifiedAlertingSettings FeatureToggles featuremgmt.FeatureToggles SQLStore db.DB Logger log.Logger FolderService folder.Service AccessControl accesscontrol.AccessControl DashboardService dashboards.DashboardService }
DBstore stores the alert definitions and instances in the database.
func ProvideDBStore ¶
func ProvideDBStore( cfg *setting.Cfg, featureToggles featuremgmt.FeatureToggles, sqlstore db.DB, folderService folder.Service, access accesscontrol.AccessControl, dashboards dashboards.DashboardService) (*DBstore, error)
func (DBstore) Count ¶
Count returns either the number of the alert rules under a specific org (if orgID is not zero) or the number of all the alert rules
func (DBstore) CountInFolder ¶
func (st DBstore) CountInFolder(ctx context.Context, orgID int64, folderUID string, u *user.SignedInUser) (int64, error)
CountInFolder is a handler for retrieving the number of alert rules of specific organisation associated with a given namespace (parent folder).
func (DBstore) DeleteAdminConfiguration ¶
func (DBstore) DeleteAlertInstances ¶
DeleteAlertInstances deletes instances with the provided keys in a single transaction.
func (DBstore) DeleteAlertInstancesByRule ¶
func (DBstore) DeleteAlertRulesByUID ¶
DeleteAlertRulesByUID is a handler for deleting an alert rule.
func (DBstore) DeleteExpiredImages ¶
func (DBstore) DeleteInFolder ¶
func (st DBstore) DeleteInFolder(ctx context.Context, orgID int64, folderUID string, user *user.SignedInUser) error
DeleteInFolder deletes the rules contained in a given folder along with their associated data.
func (DBstore) DeleteProvenance ¶
DeleteProvenance deletes the provenance record from the table
func (*DBstore) GetAdminConfiguration ¶
func (st *DBstore) GetAdminConfiguration(orgID int64) (*ngmodels.AdminConfiguration, error)
func (DBstore) GetAdminConfigurations ¶
func (st DBstore) GetAdminConfigurations() ([]*ngmodels.AdminConfiguration, error)
func (DBstore) GetAlertRuleByUID ¶
func (st DBstore) GetAlertRuleByUID(ctx context.Context, query *ngmodels.GetAlertRuleByUIDQuery) (result *ngmodels.AlertRule, err error)
GetAlertRuleByUID is a handler for retrieving an alert rule from that database by its UID and organisation ID. It returns ngmodels.ErrAlertRuleNotFound if no alert rule is found for the provided ID.
func (DBstore) GetAlertRulesForScheduling ¶
func (st DBstore) GetAlertRulesForScheduling(ctx context.Context, query *ngmodels.GetAlertRulesForSchedulingQuery) error
GetAlertRulesForScheduling returns a short version of all alert rules except those that belong to an excluded list of organizations
func (DBstore) GetAlertRulesGroupByRuleUID ¶
func (st DBstore) GetAlertRulesGroupByRuleUID(ctx context.Context, query *ngmodels.GetAlertRulesGroupByRuleUIDQuery) (result []*ngmodels.AlertRule, err error)
GetAlertRulesGroupByRuleUID is a handler for retrieving a group of alert rules from that database by UID and organisation ID of one of rules that belong to that group.
func (DBstore) GetAlertRulesKeysForScheduling ¶
func (*DBstore) GetAllLatestAlertmanagerConfiguration ¶
func (st *DBstore) GetAllLatestAlertmanagerConfiguration(ctx context.Context) ([]*models.AlertConfiguration, error)
GetAllLatestAlertmanagerConfiguration returns the latest configuration of every organization
func (*DBstore) GetAppliedConfigurations ¶
func (st *DBstore) GetAppliedConfigurations(ctx context.Context, orgID int64, limit int) ([]*models.HistoricAlertConfiguration, error)
GetAppliedConfigurations returns all configurations that have been marked as applied, ordered newest -> oldest by id.
func (*DBstore) GetHistoricalConfiguration ¶
func (st *DBstore) GetHistoricalConfiguration(ctx context.Context, orgID int64, id int64) (*models.HistoricAlertConfiguration, error)
GetHistoricalConfiguration returns a single historical configuration based on provided org and id.
func (DBstore) GetImageByURL ¶
func (*DBstore) GetLatestAlertmanagerConfiguration ¶
func (st *DBstore) GetLatestAlertmanagerConfiguration(ctx context.Context, query *models.GetLatestAlertmanagerConfigurationQuery) (result *models.AlertConfiguration, err error)
GetLatestAlertmanagerConfiguration returns the lastest version of the alertmanager configuration. It returns ErrNoAlertmanagerConfiguration if no configuration is found.
func (DBstore) GetNamespaceByTitle ¶
func (st DBstore) GetNamespaceByTitle(ctx context.Context, namespace string, orgID int64, user *user.SignedInUser) (*folder.Folder, error)
GetNamespaceByTitle is a handler for retrieving a namespace by its title. Alerting rules follow a Grafana folder-like structure which we call namespaces.
func (DBstore) GetNamespaceByUID ¶
func (st DBstore) GetNamespaceByUID(ctx context.Context, uid string, orgID int64, user *user.SignedInUser) (*folder.Folder, error)
GetNamespaceByUID is a handler for retrieving a namespace by its UID. Alerting rules follow a Grafana folder-like structure which we call namespaces.
func (DBstore) GetProvenance ¶
func (st DBstore) GetProvenance(ctx context.Context, o models.Provisionable, org int64) (models.Provenance, error)
GetProvenance gets the provenance status for a provisionable object.
func (DBstore) GetProvenances ¶
func (st DBstore) GetProvenances(ctx context.Context, org int64, resourceType string) (map[string]models.Provenance, error)
GetProvenance gets the provenance status for a provisionable object.
func (DBstore) GetRuleGroupInterval ¶
func (DBstore) GetUserVisibleNamespaces ¶
func (st DBstore) GetUserVisibleNamespaces(ctx context.Context, orgID int64, user *user.SignedInUser) (map[string]*folder.Folder, error)
GetUserVisibleNamespaces returns the folders that are visible to the user and have at least one alert in it
func (*DBstore) InTransaction ¶
func (DBstore) IncreaseVersionForAllRulesInNamespace ¶
func (st DBstore) IncreaseVersionForAllRulesInNamespace(ctx context.Context, orgID int64, namespaceUID string) ([]ngmodels.AlertRuleKeyWithVersionAndPauseStatus, error)
IncreaseVersionForAllRulesInNamespace Increases version for all rules that have specified namespace. Returns all rules that belong to the namespace
func (DBstore) InsertAlertRules ¶
func (st DBstore) InsertAlertRules(ctx context.Context, rules []ngmodels.AlertRule) (map[string]int64, error)
InsertAlertRules is a handler for creating/updating alert rules.
func (DBstore) ListAlertInstances ¶
func (st DBstore) ListAlertInstances(ctx context.Context, cmd *models.ListAlertInstancesQuery) (result []*models.AlertInstance, err error)
ListAlertInstances is a handler for retrieving alert instances within specific organisation based on various filters.
func (DBstore) ListAlertRules ¶
func (st DBstore) ListAlertRules(ctx context.Context, query *ngmodels.ListAlertRulesQuery) (result ngmodels.RulesGroup, err error)
ListAlertRules is a handler for retrieving alert rules of specific organisation.
func (*DBstore) MarkConfigurationAsApplied ¶
func (st *DBstore) MarkConfigurationAsApplied(ctx context.Context, cmd *models.MarkConfigurationAsAppliedCmd) error
MarkConfigurationAsApplied sets the `last_applied` field of the last config with the given hash to the current UNIX timestamp.
func (DBstore) SaveAlertInstance ¶
SaveAlertInstance is a handler for saving a new alert instance.
func (DBstore) SaveAlertmanagerConfiguration ¶
func (st DBstore) SaveAlertmanagerConfiguration(ctx context.Context, cmd *models.SaveAlertmanagerConfigurationCmd) error
SaveAlertmanagerConfiguration creates an alertmanager configuration.
func (DBstore) SaveAlertmanagerConfigurationWithCallback ¶
func (st DBstore) SaveAlertmanagerConfigurationWithCallback(ctx context.Context, cmd *models.SaveAlertmanagerConfigurationCmd, callback SaveCallback) error
SaveAlertmanagerConfigurationWithCallback creates an alertmanager configuration version and then executes a callback. If the callback results in error it rolls back the transaction.
func (DBstore) SetProvenance ¶
func (st DBstore) SetProvenance(ctx context.Context, o models.Provisionable, org int64, p models.Provenance) error
SetProvenance changes the provenance status for a provisionable object.
func (DBstore) UpdateAdminConfiguration ¶
func (st DBstore) UpdateAdminConfiguration(cmd UpdateAdminConfigurationCmd) error
func (DBstore) UpdateAlertRules ¶
UpdateAlertRules is a handler for updating alert rules.
func (*DBstore) UpdateAlertmanagerConfiguration ¶
func (st *DBstore) UpdateAlertmanagerConfiguration(ctx context.Context, cmd *models.SaveAlertmanagerConfigurationCmd) error
UpdateAlertmanagerConfiguration replaces an alertmanager configuration with optimistic locking. It assumes that an existing revision of the configuration exists in the store, and will return an error otherwise.
type FakeAdminConfigStore ¶
type FakeAdminConfigStore struct { Configs map[int64]*models.AdminConfiguration // contains filtered or unexported fields }
func NewFakeAdminConfigStore ¶
func NewFakeAdminConfigStore(t *testing.T) *FakeAdminConfigStore
func (*FakeAdminConfigStore) DeleteAdminConfiguration ¶
func (f *FakeAdminConfigStore) DeleteAdminConfiguration(orgID int64) error
func (*FakeAdminConfigStore) GetAdminConfiguration ¶
func (f *FakeAdminConfigStore) GetAdminConfiguration(orgID int64) (*models.AdminConfiguration, error)
func (*FakeAdminConfigStore) GetAdminConfigurations ¶
func (f *FakeAdminConfigStore) GetAdminConfigurations() ([]*models.AdminConfiguration, error)
func (*FakeAdminConfigStore) UpdateAdminConfiguration ¶
func (f *FakeAdminConfigStore) UpdateAdminConfiguration(cmd UpdateAdminConfigurationCmd) error
type FakeImageStore ¶
type FakeImageStore struct {
// contains filtered or unexported fields
}
func NewFakeImageStore ¶
func NewFakeImageStore(t *testing.T, images ...*models.Image) *FakeImageStore
func (*FakeImageStore) GetImageByURL ¶
type GroupDelta ¶
type GroupDelta struct { GroupKey models.AlertRuleGroupKey // AffectedGroups contains all rules of all groups that are affected by these changes. // For example, during moving a rule from one group to another this map will contain all rules from two groups AffectedGroups map[models.AlertRuleGroupKey]models.RulesGroup New []*models.AlertRule Update []RuleDelta Delete []*models.AlertRule }
func CalculateChanges ¶
func CalculateChanges(ctx context.Context, ruleReader RuleReader, groupKey models.AlertRuleGroupKey, submittedRules []*models.AlertRuleWithOptionals) (*GroupDelta, error)
CalculateChanges calculates the difference between rules in the group in the database and the submitted rules. If a submitted rule has UID it tries to find it in the database (in other groups). returns a list of rules that need to be added, updated and deleted. Deleted considered rules in the database that belong to the group but do not exist in the list of submitted rules.
func UpdateCalculatedRuleFields ¶
func UpdateCalculatedRuleFields(ch *GroupDelta) *GroupDelta
UpdateCalculatedRuleFields refreshes the calculated fields in a set of alert rule changes. This may generate new changes to keep a group consistent, such as versions or rule indexes.
func (*GroupDelta) IsEmpty ¶
func (c *GroupDelta) IsEmpty() bool
type ImageAdminStore ¶
type ImageAdminStore interface { ImageStore // DeleteExpiredImages deletes expired images. It returns the number of deleted images // or an error. DeleteExpiredImages(context.Context) (int64, error) }
type ImageStore ¶
type ImageStore interface { // GetImage returns the image with the token. It returns ErrImageNotFound // if the image has expired or if an image with the token does not exist. GetImage(ctx context.Context, token string) (*models.Image, error) // GetImageByURL looks for a image by its URL. It returns ErrImageNotFound // if the image has expired or if there is no image associated with the URL. GetImageByURL(ctx context.Context, url string) (*models.Image, error) // GetImages returns all images that match the tokens. If one or more images // have expired or do not exist then it also returns the unmatched tokens // and an ErrImageNotFound error. GetImages(ctx context.Context, tokens []string) ([]models.Image, []string, error) // SaveImage saves the image or returns an error. SaveImage(ctx context.Context, img *models.Image) error // URLExists takes a URL and returns a boolean indicating whether or not // we have an image for that URL. URLExists(ctx context.Context, url string) (bool, error) }
type RuleReader ¶
type RuleReader interface { ListAlertRules(ctx context.Context, query *models.ListAlertRulesQuery) (models.RulesGroup, error) GetAlertRulesGroupByRuleUID(ctx context.Context, query *models.GetAlertRulesGroupByRuleUIDQuery) ([]*models.AlertRule, error) }
type SaveCallback ¶
type SaveCallback func() error
type UpdateAdminConfigurationCmd ¶
type UpdateAdminConfigurationCmd struct {
AdminConfiguration *ngmodels.AdminConfiguration
}