Documentation ¶
Index ¶
- Constants
- Variables
- func AddAutogenConfig[R receiver](ctx context.Context, logger log.Logger, store autogenRuleStore, orgId int64, ...) error
- func EncryptReceiverConfigs(c []*definitions.PostableApiReceiver, encrypt definitions.EncryptFn) error
- func GettableSilenceToSilence(s alertingNotify.GettableSilence) *models.Silence
- func GettableSilencesToSilences(silences alertingNotify.GettableSilences) []*models.Silence
- func Load(rawConfig []byte) (*api.PostableUserConfig, error)
- func NewAlertmanager(ctx context.Context, orgID int64, cfg *setting.Cfg, store AlertingStore, ...) (*alertmanager, error)
- func NewFakeConfigStore(t *testing.T, configs map[int64]*models.AlertConfiguration) *fakeConfigStore
- func PostableApiAlertingConfigToApiReceivers(c apimodels.PostableApiAlertingConfig) []*alertingNotify.APIReceiver
- func PostableApiReceiverToApiReceiver(r *apimodels.PostableApiReceiver) *alertingNotify.APIReceiver
- func PostableGrafanaReceiverToGrafanaIntegrationConfig(p *apimodels.PostableGrafanaReceiver) *alertingNotify.GrafanaIntegrationConfig
- func PostableToGettableApiReceiver(r *apimodels.PostableApiReceiver, provenances map[string]models.Provenance, ...) (apimodels.GettableApiReceiver, error)
- func PostableToGettableGrafanaReceiver(r *apimodels.PostableGrafanaReceiver, provenance *models.Provenance, ...) (apimodels.GettableGrafanaReceiver, error)
- func RemoveAutogenConfigIfExists(route *definitions.Route)
- func SilenceToPostableSilence(s models.Silence) *alertingNotify.PostableSilence
- func ToTemplateDefinitions(cfg *apimodels.PostableUserConfig) []alertingTemplates.TemplateDefinition
- func WithPublicError(err errutil.Error) error
- type AggregateMatchersUsage
- type AlertValidationError
- type AlertingConfiguration
- func (a AlertingConfiguration) BuildReceiverIntegrationsFunc() ...
- func (a AlertingConfiguration) DispatcherLimits() alertingNotify.DispatcherLimits
- func (a AlertingConfiguration) Hash() [16]byte
- func (a AlertingConfiguration) InhibitRules() []alertingNotify.InhibitRule
- func (a AlertingConfiguration) MuteTimeIntervals() []alertingNotify.MuteTimeInterval
- func (a AlertingConfiguration) Raw() []byte
- func (a AlertingConfiguration) Receivers() []*alertingNotify.APIReceiver
- func (a AlertingConfiguration) RoutingTree() *alertingNotify.Route
- func (a AlertingConfiguration) Templates() []alertingTemplates.TemplateDefinition
- func (a AlertingConfiguration) TimeIntervals() []alertingNotify.TimeInterval
- type AlertingStore
- type Alertmanager
- type AlertmanagerConfigRejectedError
- type Crypto
- type DecryptFn
- type ErrorReceiverDoesNotExist
- type ErrorReferenceInvalid
- type ErrorTimeIntervalDoesNotExist
- type FakeOrgStore
- type FileStore
- func (fileStore *FileStore) GetNotificationLog(ctx context.Context) (string, error)
- func (fileStore *FileStore) GetSilences(ctx context.Context) (string, error)
- func (fileStore *FileStore) SaveNotificationLog(ctx context.Context, st alertingNotify.State) (int64, error)
- func (fileStore *FileStore) SaveSilences(ctx context.Context, st alertingNotify.State) (int64, error)
- type MultiOrgAlertmanager
- func (moa *MultiOrgAlertmanager) ActivateHistoricalConfiguration(ctx context.Context, orgId int64, id int64) error
- func (moa *MultiOrgAlertmanager) AlertmanagerFor(orgID int64) (Alertmanager, error)
- func (moa *MultiOrgAlertmanager) ApplyConfig(ctx context.Context, orgId int64, dbConfig *models.AlertConfiguration) error
- func (moa *MultiOrgAlertmanager) CreateSilence(ctx context.Context, orgID int64, ps models.Silence) (string, error)
- func (moa *MultiOrgAlertmanager) DeleteSilence(ctx context.Context, orgID int64, silenceID string) error
- func (moa *MultiOrgAlertmanager) GetAlertmanagerConfiguration(ctx context.Context, org int64, withAutogen bool) (definitions.GettableUserConfig, error)
- func (moa *MultiOrgAlertmanager) GetAppliedAlertmanagerConfigurations(ctx context.Context, org int64, limit int) ([]*definitions.GettableHistoricUserConfig, error)
- func (moa *MultiOrgAlertmanager) GetSilence(ctx context.Context, orgID int64, id string) (*models.Silence, error)
- func (moa *MultiOrgAlertmanager) ListSilences(ctx context.Context, orgID int64, filter []string) ([]*models.Silence, error)
- func (moa *MultiOrgAlertmanager) LoadAndSyncAlertmanagersForOrgs(ctx context.Context) error
- func (moa *MultiOrgAlertmanager) Run(ctx context.Context) error
- func (moa *MultiOrgAlertmanager) SaveAndApplyAlertmanagerConfiguration(ctx context.Context, org int64, config definitions.PostableUserConfig) error
- func (moa *MultiOrgAlertmanager) StopAndWait()
- func (moa *MultiOrgAlertmanager) SyncAlertmanagersForOrgs(ctx context.Context, orgIDs []int64)
- func (moa *MultiOrgAlertmanager) UpdateSilence(ctx context.Context, orgID int64, ps models.Silence) (string, error)
- type NilChannel
- type NilPeer
- type NoValidation
- type NotificationSettingsValidator
- type NotificationSettingsValidatorProvider
- type Option
- type OrgAlertmanagerFactory
- type ReceiverService
- func (rs *ReceiverService) GetReceiver(ctx context.Context, q models.GetReceiverQuery, user identity.Requester) (definitions.GettableApiReceiver, error)
- func (rs *ReceiverService) GetReceivers(ctx context.Context, q models.GetReceiversQuery, user identity.Requester) ([]definitions.GettableApiReceiver, error)
- type RedisChannel
- type RuleAccessControlService
- type RuleStore
- type SilenceAccessControlService
- type SilenceService
- func (s *SilenceService) CreateSilence(ctx context.Context, user identity.Requester, ps models.Silence) (string, error)
- func (s *SilenceService) DeleteSilence(ctx context.Context, user identity.Requester, silenceID string) error
- func (s *SilenceService) GetSilence(ctx context.Context, user identity.Requester, silenceID string) (*models.Silence, error)
- func (s *SilenceService) ListSilences(ctx context.Context, user identity.Requester, filter []string) ([]*models.Silence, error)
- func (s *SilenceService) UpdateSilence(ctx context.Context, user identity.Requester, ps models.Silence) (string, error)
- func (s *SilenceService) WithAccessControlMetadata(ctx context.Context, user identity.Requester, ...) error
- func (s *SilenceService) WithRuleMetadata(ctx context.Context, user identity.Requester, ...) error
- type SilenceStore
- type TestReceiverConfigResult
- type TestReceiverResult
- type TestReceiversResult
- type TestTemplatesResults
- type UnknownReceiverError
Constants ¶
const ( KVNamespace = "alertmanager" NotificationLogFilename = "notifications" SilencesFilename = "silences" )
Variables ¶
var ( // ErrAlertmanagerReceiverInUse is primarily meant for when a receiver is used by a rule and is being deleted. ErrAlertmanagerReceiverInUse = errutil.BadRequest("alerting.notifications.alertmanager.receiverInUse").MustTemplate("receiver [Name: {{ .Public.Receiver }}] is used by rule: {{ .Error }}", errutil.WithPublic( "receiver [Name: {{ .Public.Receiver }}] is used by rule", )) // ErrAlertmanagerTimeIntervalInUse is primarily meant for when a time interval is used by a rule and is being deleted. ErrAlertmanagerTimeIntervalInUse = errutil.BadRequest("alerting.notifications.alertmanager.intervalInUse").MustTemplate("time interval [Name: {{ .Public.Interval }}] is used by rule: {{ .Error }}", errutil.WithPublic( "time interval [Name: {{ .Public.Interval }}] is used by rule", )) )
var ( ErrNoAlertmanagerForOrg = fmt.Errorf("Alertmanager does not exist for this organization") ErrAlertmanagerNotReady = fmt.Errorf("Alertmanager is not ready yet") )
var ( ErrAlertmanagerNotFound = errutil.NotFound("alerting.notifications.alertmanager.notFound") ErrAlertmanagerConflict = errutil.Conflict("alerting.notifications.alertmanager.conflict") ErrSilenceNotFound = errutil.NotFound("alerting.notifications.silences.notFound") ErrSilencesBadRequest = errutil.BadRequest("alerting.notifications.silences.badRequest") ErrSilenceInternal = errutil.Internal("alerting.notifications.silences.internal") )
errutil-based errors. TODO: Should completely replace the fmt.Errorf-based errors.
var ( // ErrPermissionDenied is returned when the user does not have permission to perform the requested action. ErrPermissionDenied = errors.New("permission denied") // TODO: convert to errutil // ErrNotFound is returned when the requested resource does not exist. ErrNotFound = errors.New("not found") // TODO: convert to errutil )
var ( DefaultLabels = map[string]string{ prometheusModel.AlertNameLabel: `alert title`, alertingModels.FolderTitleLabel: `folder title`, } DefaultAnnotations = map[string]string{ alertingModels.ValuesAnnotation: `{"B":22,"C":1}`, alertingModels.ValueStringAnnotation: `[ var='B' labels={__name__=go_threads, instance=host.docker.internal:3000, job=grafana} value=22 ], [ var='C' labels={__name__=go_threads, instance=host.docker.internal:3000, job=grafana} value=1 ]`, alertingModels.OrgIDAnnotation: `1`, alertingModels.DashboardUIDAnnotation: `dashboard_uid`, alertingModels.PanelIDAnnotation: `1`, } )
var LoggerFactory alertingLogging.LoggerFactory = func(logger string, ctx ...any) alertingLogging.Logger { return &logWrapper{log.New(append([]any{logger}, ctx...)...)} }
Functions ¶
func AddAutogenConfig ¶
func AddAutogenConfig[R receiver](ctx context.Context, logger log.Logger, store autogenRuleStore, orgId int64, cfg apiAlertingConfig[R], skipInvalid bool) error
AddAutogenConfig creates the autogenerated configuration and adds it to the given apiAlertingConfig. If skipInvalid is true, then invalid notification settings are skipped, otherwise an error is returned.
func EncryptReceiverConfigs ¶
func EncryptReceiverConfigs(c []*definitions.PostableApiReceiver, encrypt definitions.EncryptFn) error
EncryptReceiverConfigs encrypts all SecureSettings in the given receivers.
func GettableSilenceToSilence ¶
func GettableSilenceToSilence(s alertingNotify.GettableSilence) *models.Silence
func GettableSilencesToSilences ¶
func GettableSilencesToSilences(silences alertingNotify.GettableSilences) []*models.Silence
func NewAlertmanager ¶
func NewAlertmanager(ctx context.Context, orgID int64, cfg *setting.Cfg, store AlertingStore, stateStore stateStore, peer alertingNotify.ClusterPeer, decryptFn alertingNotify.GetDecryptedValueFn, ns notifications.Service, m *metrics.Alertmanager, withAutogen bool) (*alertmanager, error)
func NewFakeConfigStore ¶
func NewFakeConfigStore(t *testing.T, configs map[int64]*models.AlertConfiguration) *fakeConfigStore
func PostableApiAlertingConfigToApiReceivers ¶
func PostableApiAlertingConfigToApiReceivers(c apimodels.PostableApiAlertingConfig) []*alertingNotify.APIReceiver
func PostableApiReceiverToApiReceiver ¶
func PostableApiReceiverToApiReceiver(r *apimodels.PostableApiReceiver) *alertingNotify.APIReceiver
func PostableGrafanaReceiverToGrafanaIntegrationConfig ¶
func PostableGrafanaReceiverToGrafanaIntegrationConfig(p *apimodels.PostableGrafanaReceiver) *alertingNotify.GrafanaIntegrationConfig
func PostableToGettableApiReceiver ¶
func PostableToGettableApiReceiver(r *apimodels.PostableApiReceiver, provenances map[string]models.Provenance, decryptFn DecryptFn, listOnly bool) (apimodels.GettableApiReceiver, error)
func PostableToGettableGrafanaReceiver ¶
func PostableToGettableGrafanaReceiver(r *apimodels.PostableGrafanaReceiver, provenance *models.Provenance, decryptFn DecryptFn, listOnly bool) (apimodels.GettableGrafanaReceiver, error)
func RemoveAutogenConfigIfExists ¶
func RemoveAutogenConfigIfExists(route *definitions.Route)
RemoveAutogenConfigIfExists removes all top-level autogenerated routes from the provided route. If no autogenerated routes exist, this function does nothing.
func SilenceToPostableSilence ¶
func SilenceToPostableSilence(s models.Silence) *alertingNotify.PostableSilence
func ToTemplateDefinitions ¶
func ToTemplateDefinitions(cfg *apimodels.PostableUserConfig) []alertingTemplates.TemplateDefinition
ToTemplateDefinitions converts the given PostableUserConfig's TemplateFiles to a slice of TemplateDefinitions.
func WithPublicError ¶
WithPublicError sets the public message of an errutil error to the error message.
Types ¶
type AggregateMatchersUsage ¶
type AlertValidationError ¶
type AlertValidationError struct { Alerts []amv2.PostableAlert Errors []error // Errors[i] refers to Alerts[i]. }
AlertValidationError is the error capturing the validation errors faced on the alerts.
func (AlertValidationError) Error ¶
func (e AlertValidationError) Error() string
type AlertingConfiguration ¶
type AlertingConfiguration struct {
// contains filtered or unexported fields
}
AlertingConfiguration provides configuration for an Alertmanager. It implements the notify.Configuration interface.
func (AlertingConfiguration) BuildReceiverIntegrationsFunc ¶
func (a AlertingConfiguration) BuildReceiverIntegrationsFunc() func(next *alertingNotify.APIReceiver, tmpl *alertingTemplates.Template) ([]*alertingNotify.Integration, error)
func (AlertingConfiguration) DispatcherLimits ¶
func (a AlertingConfiguration) DispatcherLimits() alertingNotify.DispatcherLimits
func (AlertingConfiguration) Hash ¶
func (a AlertingConfiguration) Hash() [16]byte
func (AlertingConfiguration) InhibitRules ¶
func (a AlertingConfiguration) InhibitRules() []alertingNotify.InhibitRule
func (AlertingConfiguration) MuteTimeIntervals ¶
func (a AlertingConfiguration) MuteTimeIntervals() []alertingNotify.MuteTimeInterval
func (AlertingConfiguration) Raw ¶
func (a AlertingConfiguration) Raw() []byte
func (AlertingConfiguration) Receivers ¶
func (a AlertingConfiguration) Receivers() []*alertingNotify.APIReceiver
func (AlertingConfiguration) RoutingTree ¶
func (a AlertingConfiguration) RoutingTree() *alertingNotify.Route
func (AlertingConfiguration) Templates ¶
func (a AlertingConfiguration) Templates() []alertingTemplates.TemplateDefinition
func (AlertingConfiguration) TimeIntervals ¶
func (a AlertingConfiguration) TimeIntervals() []alertingNotify.TimeInterval
type AlertingStore ¶
type AlertingStore interface { store.AlertingStore store.ImageStore // contains filtered or unexported methods }
type Alertmanager ¶
type Alertmanager interface { // Configuration ApplyConfig(context.Context, *models.AlertConfiguration) error SaveAndApplyConfig(ctx context.Context, config *apimodels.PostableUserConfig) error SaveAndApplyDefaultConfig(ctx context.Context) error GetStatus(context.Context) (apimodels.GettableStatus, error) // Silences CreateSilence(context.Context, *apimodels.PostableSilence) (string, error) DeleteSilence(context.Context, string) error GetSilence(context.Context, string) (apimodels.GettableSilence, error) ListSilences(context.Context, []string) (apimodels.GettableSilences, error) // SilenceState returns the current state of silences in the Alertmanager. This is used to persist the state // to the kvstore. SilenceState(context.Context) (alertingNotify.SilenceState, error) // Alerts GetAlerts(ctx context.Context, active, silenced, inhibited bool, filter []string, receiver string) (apimodels.GettableAlerts, error) GetAlertGroups(ctx context.Context, active, silenced, inhibited bool, filter []string, receiver string) (apimodels.AlertGroups, error) PutAlerts(context.Context, apimodels.PostableAlerts) error // Receivers GetReceivers(ctx context.Context) ([]apimodels.Receiver, error) TestReceivers(ctx context.Context, c apimodels.TestReceiversConfigBodyParams) (*TestReceiversResult, error) TestTemplate(ctx context.Context, c apimodels.TestTemplatesConfigBodyParams) (*TestTemplatesResults, error) // Lifecycle StopAndWait() Ready() bool }
type AlertmanagerConfigRejectedError ¶
type AlertmanagerConfigRejectedError struct {
Inner error
}
func (AlertmanagerConfigRejectedError) Error ¶
func (e AlertmanagerConfigRejectedError) Error() string
type Crypto ¶
type Crypto interface { LoadSecureSettings(ctx context.Context, orgId int64, receivers []*definitions.PostableApiReceiver) error Encrypt(ctx context.Context, payload []byte, opt secrets.EncryptionOptions) ([]byte, error) ProcessSecureSettings(ctx context.Context, orgId int64, recvs []*definitions.PostableApiReceiver) error // contains filtered or unexported methods }
Crypto allows decryption of Alertmanager Configuration and encryption of arbitrary payloads.
type ErrorReceiverDoesNotExist ¶
type ErrorReceiverDoesNotExist struct {
ErrorReferenceInvalid
}
func (ErrorReceiverDoesNotExist) Error ¶
func (e ErrorReceiverDoesNotExist) Error() string
type ErrorReferenceInvalid ¶
type ErrorReferenceInvalid struct {
Reference string
}
type ErrorTimeIntervalDoesNotExist ¶
type ErrorTimeIntervalDoesNotExist struct {
ErrorReferenceInvalid
}
func (ErrorTimeIntervalDoesNotExist) Error ¶
func (e ErrorTimeIntervalDoesNotExist) Error() string
type FakeOrgStore ¶
type FakeOrgStore struct {
// contains filtered or unexported fields
}
func NewFakeOrgStore ¶
func NewFakeOrgStore(t *testing.T, orgs []int64) *FakeOrgStore
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
FileStore is in charge of persisting the alertmanager files to the database. It uses the KVstore table and encodes the files as a base64 string.
func (*FileStore) GetNotificationLog ¶
func (*FileStore) GetSilences ¶
GetSilences returns the content of the silences file from kvstore.
func (*FileStore) SaveNotificationLog ¶
func (fileStore *FileStore) SaveNotificationLog(ctx context.Context, st alertingNotify.State) (int64, error)
SaveNotificationLog saves the notification log to the database and returns the size of the unencoded state.
func (*FileStore) SaveSilences ¶
func (fileStore *FileStore) SaveSilences(ctx context.Context, st alertingNotify.State) (int64, error)
SaveSilences saves the silences to the database and returns the size of the unencoded state.
type MultiOrgAlertmanager ¶
type MultiOrgAlertmanager struct { Crypto Crypto ProvStore provisioningStore // contains filtered or unexported fields }
func NewMultiOrgAlertmanager ¶
func NewMultiOrgAlertmanager( cfg *setting.Cfg, configStore AlertingStore, orgStore store.OrgStore, kvStore kvstore.KVStore, provStore provisioningStore, decryptFn alertingNotify.GetDecryptedValueFn, m *metrics.MultiOrgAlertmanager, ns notifications.Service, l log.Logger, s secrets.Service, featureManager featuremgmt.FeatureToggles, opts ...Option, ) (*MultiOrgAlertmanager, error)
func (*MultiOrgAlertmanager) ActivateHistoricalConfiguration ¶
func (moa *MultiOrgAlertmanager) ActivateHistoricalConfiguration(ctx context.Context, orgId int64, id int64) error
ActivateHistoricalConfiguration will set the current alertmanager configuration to a previous value based on the provided alert_configuration_history id.
func (*MultiOrgAlertmanager) AlertmanagerFor ¶
func (moa *MultiOrgAlertmanager) AlertmanagerFor(orgID int64) (Alertmanager, error)
AlertmanagerFor returns the Alertmanager instance for the organization provided. When the organization does not have an active Alertmanager, it returns a ErrNoAlertmanagerForOrg. When the Alertmanager of the organization is not ready, it returns a ErrAlertmanagerNotReady.
func (*MultiOrgAlertmanager) ApplyConfig ¶
func (moa *MultiOrgAlertmanager) ApplyConfig(ctx context.Context, orgId int64, dbConfig *models.AlertConfiguration) error
ApplyConfig will apply the given alertmanager configuration for a given org. Can be used to force regeneration of autogenerated routes.
func (*MultiOrgAlertmanager) CreateSilence ¶
func (moa *MultiOrgAlertmanager) CreateSilence(ctx context.Context, orgID int64, ps models.Silence) (string, error)
CreateSilence creates a silence in the Alertmanager for the organization provided, returning the silence ID. It will also persist the silence state to the kvstore immediately after creating the silence.
func (*MultiOrgAlertmanager) DeleteSilence ¶
func (moa *MultiOrgAlertmanager) DeleteSilence(ctx context.Context, orgID int64, silenceID string) error
DeleteSilence deletes a silence in the Alertmanager for the organization provided. It will also persist the silence state to the kvstore immediately after deleting the silence.
func (*MultiOrgAlertmanager) GetAlertmanagerConfiguration ¶
func (moa *MultiOrgAlertmanager) GetAlertmanagerConfiguration(ctx context.Context, org int64, withAutogen bool) (definitions.GettableUserConfig, error)
GetAlertmanagerConfiguration returns the latest alertmanager configuration for a given org. If withAutogen is true, the configuration will be augmented with autogenerated routes.
func (*MultiOrgAlertmanager) GetAppliedAlertmanagerConfigurations ¶
func (moa *MultiOrgAlertmanager) GetAppliedAlertmanagerConfigurations(ctx context.Context, org int64, limit int) ([]*definitions.GettableHistoricUserConfig, error)
GetAppliedAlertmanagerConfigurations returns the last n configurations marked as applied for a given org.
func (*MultiOrgAlertmanager) GetSilence ¶
func (moa *MultiOrgAlertmanager) GetSilence(ctx context.Context, orgID int64, id string) (*models.Silence, error)
GetSilence gets a silence for the organization and silence id provided. Currently, this is a pass-through to the Alertmanager implementation.
func (*MultiOrgAlertmanager) ListSilences ¶
func (moa *MultiOrgAlertmanager) ListSilences(ctx context.Context, orgID int64, filter []string) ([]*models.Silence, error)
ListSilences lists silences for the organization provided. Currently, this is a pass-through to the Alertmanager implementation.
func (*MultiOrgAlertmanager) LoadAndSyncAlertmanagersForOrgs ¶
func (moa *MultiOrgAlertmanager) LoadAndSyncAlertmanagersForOrgs(ctx context.Context) error
func (*MultiOrgAlertmanager) SaveAndApplyAlertmanagerConfiguration ¶
func (moa *MultiOrgAlertmanager) SaveAndApplyAlertmanagerConfiguration(ctx context.Context, org int64, config definitions.PostableUserConfig) error
func (*MultiOrgAlertmanager) StopAndWait ¶
func (moa *MultiOrgAlertmanager) StopAndWait()
func (*MultiOrgAlertmanager) SyncAlertmanagersForOrgs ¶
func (moa *MultiOrgAlertmanager) SyncAlertmanagersForOrgs(ctx context.Context, orgIDs []int64)
SyncAlertmanagersForOrgs syncs configuration of the Alertmanager required by each organization.
func (*MultiOrgAlertmanager) UpdateSilence ¶
func (moa *MultiOrgAlertmanager) UpdateSilence(ctx context.Context, orgID int64, ps models.Silence) (string, error)
UpdateSilence updates a silence in the Alertmanager for the organization provided, returning the silence ID. It will also persist the silence state to the kvstore immediately after creating the silence. Currently, this just calls CreateSilence as the underlying Alertmanager implementation upserts.
type NilChannel ¶
type NilChannel struct{}
func (*NilChannel) Broadcast ¶
func (c *NilChannel) Broadcast([]byte)
type NilPeer ¶
type NilPeer struct{}
NilPeer and NilChannel implements the Alertmanager clustering interface.
func (*NilPeer) AddState ¶
func (p *NilPeer) AddState(string, alertingCluster.State, prometheus.Registerer) alertingCluster.ClusterChannel
type NoValidation ¶
type NoValidation struct { }
func (NoValidation) Validate ¶
func (n NoValidation) Validate(_ models.NotificationSettings) error
type NotificationSettingsValidator ¶
type NotificationSettingsValidator interface {
Validate(s models.NotificationSettings) error
}
NotificationSettingsValidator validates NotificationSettings against the current Alertmanager configuration
func NewNotificationSettingsValidator ¶
func NewNotificationSettingsValidator[R receiver](am apiAlertingConfig[R]) NotificationSettingsValidator
NewNotificationSettingsValidator creates a new NotificationSettingsValidator from the given apiAlertingConfig.
type NotificationSettingsValidatorProvider ¶
type NotificationSettingsValidatorProvider interface {
Validator(ctx context.Context, orgID int64) (NotificationSettingsValidator, error)
}
NotificationSettingsValidatorProvider provides a NotificationSettingsValidator for a given orgID.
func NewCachedNotificationSettingsValidationService ¶
func NewCachedNotificationSettingsValidationService(store store.AlertingStore) NotificationSettingsValidatorProvider
func NewNotificationSettingsValidationService ¶
func NewNotificationSettingsValidationService(store store.AlertingStore) NotificationSettingsValidatorProvider
type Option ¶
type Option func(*MultiOrgAlertmanager)
func WithAlertmanagerOverride ¶
func WithAlertmanagerOverride(f func(OrgAlertmanagerFactory) OrgAlertmanagerFactory) Option
type OrgAlertmanagerFactory ¶
type OrgAlertmanagerFactory func(ctx context.Context, orgID int64) (Alertmanager, error)
type ReceiverService ¶
type ReceiverService struct {
// contains filtered or unexported fields
}
ReceiverService is the service for managing alertmanager receivers.
func NewReceiverService ¶
func NewReceiverService( ac accesscontrol.AccessControl, cfgStore configStore, provisioningStore provisoningStore, encryptionService secrets.Service, xact transactionManager, log log.Logger, ) *ReceiverService
func (*ReceiverService) GetReceiver ¶
func (rs *ReceiverService) GetReceiver(ctx context.Context, q models.GetReceiverQuery, user identity.Requester) (definitions.GettableApiReceiver, error)
GetReceiver returns a receiver by name. The receiver's secure settings are decrypted if requested and the user has access to do so.
func (*ReceiverService) GetReceivers ¶
func (rs *ReceiverService) GetReceivers(ctx context.Context, q models.GetReceiversQuery, user identity.Requester) ([]definitions.GettableApiReceiver, error)
GetReceivers returns a list of receivers a user has access to. Receivers can be filtered by name, and secure settings are decrypted if requested and the user has access to do so.
type RedisChannel ¶
type RedisChannel struct {
// contains filtered or unexported fields
}
func (*RedisChannel) Broadcast ¶
func (c *RedisChannel) Broadcast(b []byte)
type RuleAccessControlService ¶
type RuleAccessControlService interface {
HasAccessInFolder(ctx context.Context, user identity.Requester, rule accesscontrol.Namespaced) (bool, error)
}
type RuleStore ¶
type RuleStore interface {
ListAlertRules(ctx context.Context, query *models.ListAlertRulesQuery) (models.RulesGroup, error)
}
type SilenceAccessControlService ¶
type SilenceAccessControlService interface { FilterByAccess(ctx context.Context, user identity.Requester, silences ...*models.Silence) ([]*models.Silence, error) AuthorizeReadSilence(ctx context.Context, user identity.Requester, silence *models.Silence) error AuthorizeCreateSilence(ctx context.Context, user identity.Requester, silence *models.Silence) error AuthorizeUpdateSilence(ctx context.Context, user identity.Requester, silence *models.Silence) error SilenceAccess(ctx context.Context, user identity.Requester, silences []*models.Silence) (map[*models.Silence]models.SilencePermissionSet, error) }
SilenceAccessControlService provides access control for silences.
type SilenceService ¶
type SilenceService struct {
// contains filtered or unexported fields
}
SilenceService is the authenticated service for managing alertmanager silences.
func NewSilenceService ¶
func NewSilenceService( authz SilenceAccessControlService, xact transactionManager, log log.Logger, store SilenceStore, ruleStore RuleStore, ruleAuthz RuleAccessControlService, ) *SilenceService
func (*SilenceService) CreateSilence ¶
func (s *SilenceService) CreateSilence(ctx context.Context, user identity.Requester, ps models.Silence) (string, error)
CreateSilence creates a new silence. For rule-specific silences, the user needs permission to create silences in the folder that the associated rule is in. For general silences, the user needs broader permissions.
func (*SilenceService) DeleteSilence ¶
func (s *SilenceService) DeleteSilence(ctx context.Context, user identity.Requester, silenceID string) error
DeleteSilence deletes a silence by its ID. For rule-specific silences, the user needs permission to update silences in the folder that the associated rule is in. For general silences, the user needs broader permissions.
func (*SilenceService) GetSilence ¶
func (s *SilenceService) GetSilence(ctx context.Context, user identity.Requester, silenceID string) (*models.Silence, error)
GetSilence retrieves a silence by its ID.
func (*SilenceService) ListSilences ¶
func (s *SilenceService) ListSilences(ctx context.Context, user identity.Requester, filter []string) ([]*models.Silence, error)
ListSilences retrieves all silences that match the given filter. This will include all rule-specific silences that the user has access to as well as all general silences.
func (*SilenceService) UpdateSilence ¶
func (s *SilenceService) UpdateSilence(ctx context.Context, user identity.Requester, ps models.Silence) (string, error)
UpdateSilence updates an existing silence. For rule-specific silences, the user needs permission to update silences in the folder that the associated rule is in. For general silences, the user needs broader permissions.
func (*SilenceService) WithAccessControlMetadata ¶
func (s *SilenceService) WithAccessControlMetadata(ctx context.Context, user identity.Requester, silencesWithMetadata ...*models.SilenceWithMetadata) error
WithAccessControlMetadata adds access control metadata to the given SilenceWithMetadata.
func (*SilenceService) WithRuleMetadata ¶
func (s *SilenceService) WithRuleMetadata(ctx context.Context, user identity.Requester, silences ...*models.SilenceWithMetadata) error
WithRuleMetadata adds rule metadata to the given SilenceWithMetadata.
type SilenceStore ¶
type SilenceStore interface { ListSilences(ctx context.Context, orgID int64, filter []string) ([]*models.Silence, error) GetSilence(ctx context.Context, orgID int64, id string) (*models.Silence, error) CreateSilence(ctx context.Context, orgID int64, ps models.Silence) (string, error) UpdateSilence(ctx context.Context, orgID int64, ps models.Silence) (string, error) DeleteSilence(ctx context.Context, orgID int64, id string) error }
SilenceStore is the interface for storing and retrieving silences. Currently, this is implemented by MultiOrgAlertmanager but should eventually be replaced with an actual store.
type TestReceiverResult ¶
type TestReceiverResult struct { Name string Configs []TestReceiverConfigResult }
type TestReceiversResult ¶
type TestReceiversResult struct { Alert types.Alert Receivers []TestReceiverResult NotifedAt time.Time }
type TestTemplatesResults ¶
type TestTemplatesResults = alertingNotify.TestTemplatesResults
type UnknownReceiverError ¶
type UnknownReceiverError struct {
UID string
}
func (UnknownReceiverError) Error ¶
func (e UnknownReceiverError) Error() string
Source Files ¶
- alertmanager.go
- alertmanager_config.go
- alerts.go
- autogen_alertmanager.go
- compat.go
- config.go
- crypto.go
- errors.go
- file_store.go
- images.go
- log.go
- multiorg_alertmanager.go
- receiver_svc.go
- redis_channel.go
- redis_peer.go
- sender.go
- silence_svc.go
- silences.go
- status.go
- templates.go
- testing.go
- testreceivers.go
- validation.go