Documentation ¶
Index ¶
- Constants
- Variables
- func Load(rawConfig []byte) (*api.PostableUserConfig, error)
- func NewFakeConfigStore(t *testing.T, configs map[int64]*models.AlertConfiguration) *fakeConfigStore
- func PersistTemplates(logger log.Logger, cfg *api.PostableUserConfig, path string) ([]string, bool, error)
- func PostableApiAlertingConfigToApiReceivers(c apimodels.PostableApiAlertingConfig) []*alertingNotify.APIReceiver
- func PostableApiReceiverToApiReceiver(r *apimodels.PostableApiReceiver) *alertingNotify.APIReceiver
- func PostableGrafanaReceiverToGrafanaIntegrationConfig(p *apimodels.PostableGrafanaReceiver) *alertingNotify.GrafanaIntegrationConfig
- 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() []string
- type AlertingStore
- type Alertmanager
- func (am *Alertmanager) AppURL() string
- func (am *Alertmanager) ApplyConfig(ctx context.Context, dbCfg *ngmodels.AlertConfiguration) error
- func (am *Alertmanager) CreateSilence(ps *alertingNotify.PostableSilence) (string, error)
- func (am *Alertmanager) DeleteSilence(silenceID string) error
- func (am *Alertmanager) GetAlertGroups(active, silenced, inhibited bool, filter []string, receivers string) (alertingNotify.AlertGroups, error)
- func (am *Alertmanager) GetAlerts(active, silenced, inhibited bool, filter []string, receivers string) (alertingNotify.GettableAlerts, error)
- func (am *Alertmanager) GetReceivers(_ context.Context) []apimodels.Receiver
- func (am *Alertmanager) GetSilence(silenceID string) (alertingNotify.GettableSilence, error)
- func (am *Alertmanager) GetStatus() apimodels.GettableStatus
- func (am *Alertmanager) ListSilences(filter []string) (alertingNotify.GettableSilences, error)
- func (am *Alertmanager) PutAlerts(postableAlerts apimodels.PostableAlerts) error
- func (am *Alertmanager) Ready() bool
- func (am *Alertmanager) SaveAndApplyConfig(ctx context.Context, cfg *apimodels.PostableUserConfig) error
- func (am *Alertmanager) SaveAndApplyDefaultConfig(ctx context.Context) error
- func (am *Alertmanager) StopAndWait()
- func (am *Alertmanager) TestReceivers(ctx context.Context, c apimodels.TestReceiversConfigBodyParams) (*TestReceiversResult, error)
- func (am *Alertmanager) TestTemplate(ctx context.Context, c apimodels.TestTemplatesConfigBodyParams) (*TestTemplatesResults, error)
- type AlertmanagerConfigRejectedError
- type Crypto
- type FakeKVStore
- func (fkv *FakeKVStore) Del(_ context.Context, orgId int64, namespace string, key string) error
- func (fkv *FakeKVStore) Get(_ context.Context, orgId int64, namespace string, key string) (string, bool, error)
- func (fkv *FakeKVStore) GetAll(ctx context.Context, orgId int64, namespace string) (map[int64]map[string]string, error)
- func (fkv *FakeKVStore) Keys(ctx context.Context, orgID int64, namespace string, keyPrefix string) ([]kvstore.Key, error)
- func (fkv *FakeKVStore) Set(_ context.Context, orgId int64, namespace string, key string, value string) error
- type FakeOrgStore
- type FileStore
- func (fileStore *FileStore) CleanUp()
- func (fileStore *FileStore) FilepathFor(ctx context.Context, filename string) (string, error)
- func (fileStore *FileStore) Persist(ctx context.Context, filename string, st alertingNotify.State) (int64, error)
- func (fileStore *FileStore) WriteFileToDisk(fn string, content []byte) 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) ApplyAlertmanagerConfiguration(ctx context.Context, org int64, config definitions.PostableUserConfig) error
- func (moa *MultiOrgAlertmanager) GetAlertmanagerConfiguration(ctx context.Context, org int64) (definitions.GettableUserConfig, error)
- func (moa *MultiOrgAlertmanager) GetAppliedAlertmanagerConfigurations(ctx context.Context, org int64, limit int) ([]*definitions.GettableHistoricUserConfig, error)
- func (moa *MultiOrgAlertmanager) LoadAndSyncAlertmanagersForOrgs(ctx context.Context) error
- func (moa *MultiOrgAlertmanager) Run(ctx context.Context) error
- func (moa *MultiOrgAlertmanager) StopAndWait()
- func (moa *MultiOrgAlertmanager) SyncAlertmanagersForOrgs(ctx context.Context, orgIDs []int64)
- type NilChannel
- type NilPeer
- type RedisChannel
- type TestReceiverConfigResult
- type TestReceiverResult
- type TestReceiversResult
- type TestTemplatesResults
- type UnknownReceiverError
Constants ¶
const KVNamespace = "alertmanager"
Variables ¶
var ( ErrNoAlertmanagerForOrg = fmt.Errorf("Alertmanager does not exist for this organization") ErrAlertmanagerNotReady = fmt.Errorf("Alertmanager is not ready yet") )
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 ...interface{}) alertingLogging.Logger { return &logWrapper{log.New(append([]interface{}{logger}, ctx...)...)} }
Functions ¶
func NewFakeConfigStore ¶
func NewFakeConfigStore(t *testing.T, configs map[int64]*models.AlertConfiguration) *fakeConfigStore
func PersistTemplates ¶
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
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() []string
type AlertingStore ¶
type AlertingStore interface { store.AlertingStore store.ImageStore }
type Alertmanager ¶
type Alertmanager struct { Base *alertingNotify.GrafanaAlertmanager ConfigMetrics *metrics.AlertmanagerConfigMetrics Settings *setting.Cfg Store AlertingStore NotificationService notifications.Service // contains filtered or unexported fields }
func (*Alertmanager) AppURL ¶
func (am *Alertmanager) AppURL() string
func (*Alertmanager) ApplyConfig ¶
func (am *Alertmanager) ApplyConfig(ctx context.Context, dbCfg *ngmodels.AlertConfiguration) error
ApplyConfig applies the configuration to the Alertmanager.
func (*Alertmanager) CreateSilence ¶
func (am *Alertmanager) CreateSilence(ps *alertingNotify.PostableSilence) (string, error)
func (*Alertmanager) DeleteSilence ¶
func (am *Alertmanager) DeleteSilence(silenceID string) error
func (*Alertmanager) GetAlertGroups ¶
func (am *Alertmanager) GetAlertGroups(active, silenced, inhibited bool, filter []string, receivers string) (alertingNotify.AlertGroups, error)
func (*Alertmanager) GetAlerts ¶
func (am *Alertmanager) GetAlerts(active, silenced, inhibited bool, filter []string, receivers string) (alertingNotify.GettableAlerts, error)
func (*Alertmanager) GetReceivers ¶
func (am *Alertmanager) GetReceivers(_ context.Context) []apimodels.Receiver
func (*Alertmanager) GetSilence ¶
func (am *Alertmanager) GetSilence(silenceID string) (alertingNotify.GettableSilence, error)
func (*Alertmanager) GetStatus ¶
func (am *Alertmanager) GetStatus() apimodels.GettableStatus
TODO: We no longer do apimodels at this layer, move it to the API.
func (*Alertmanager) ListSilences ¶
func (am *Alertmanager) ListSilences(filter []string) (alertingNotify.GettableSilences, error)
func (*Alertmanager) PutAlerts ¶
func (am *Alertmanager) PutAlerts(postableAlerts apimodels.PostableAlerts) error
PutAlerts receives the alerts and then sends them through the corresponding route based on whenever the alert has a receiver embedded or not
func (*Alertmanager) Ready ¶
func (am *Alertmanager) Ready() bool
func (*Alertmanager) SaveAndApplyConfig ¶
func (am *Alertmanager) SaveAndApplyConfig(ctx context.Context, cfg *apimodels.PostableUserConfig) error
SaveAndApplyConfig saves the configuration the database and applies the configuration to the Alertmanager. It rollbacks the save if we fail to apply the configuration.
func (*Alertmanager) SaveAndApplyDefaultConfig ¶
func (am *Alertmanager) SaveAndApplyDefaultConfig(ctx context.Context) error
SaveAndApplyDefaultConfig saves the default configuration to the database and applies it to the Alertmanager. It rolls back the save if we fail to apply the configuration.
func (*Alertmanager) StopAndWait ¶
func (am *Alertmanager) StopAndWait()
func (*Alertmanager) TestReceivers ¶
func (am *Alertmanager) TestReceivers(ctx context.Context, c apimodels.TestReceiversConfigBodyParams) (*TestReceiversResult, error)
func (*Alertmanager) TestTemplate ¶
func (am *Alertmanager) TestTemplate(ctx context.Context, c apimodels.TestTemplatesConfigBodyParams) (*TestTemplatesResults, error)
TestTemplate tests the given template string against the given alerts. Existing templates are used to provide context for the test. If an existing template of the same filename as the one being tested is found, it will not be used as context.
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) // contains filtered or unexported methods }
Crypto allows decryption of Alertmanager Configuration and encryption of arbitrary payloads.
type FakeKVStore ¶
type FakeKVStore struct {
// contains filtered or unexported fields
}
func NewFakeKVStore ¶
func NewFakeKVStore(t *testing.T) *FakeKVStore
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 NewFileStore ¶
func (*FileStore) CleanUp ¶
func (fileStore *FileStore) CleanUp()
CleanUp will remove the working directory from disk.
func (*FileStore) FilepathFor ¶
FilepathFor returns the filepath to an Alertmanager file. If the file is already present on disk it no-ops. If not, it tries to read the database and if there's no file it no-ops. If there is a file in the database, it decodes it and writes to disk for Alertmanager consumption.
type MultiOrgAlertmanager ¶
type MultiOrgAlertmanager struct { Crypto Crypto ProvStore provisioning.ProvisioningStore // contains filtered or unexported fields }
func NewMultiOrgAlertmanager ¶
func NewMultiOrgAlertmanager(cfg *setting.Cfg, configStore AlertingStore, orgStore store.OrgStore, kvStore kvstore.KVStore, provStore provisioning.ProvisioningStore, decryptFn alertingNotify.GetDecryptedValueFn, m *metrics.MultiOrgAlertmanager, ns notifications.Service, l log.Logger, s secrets.Service, ) (*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) ApplyAlertmanagerConfiguration ¶
func (moa *MultiOrgAlertmanager) ApplyAlertmanagerConfiguration(ctx context.Context, org int64, config definitions.PostableUserConfig) error
func (*MultiOrgAlertmanager) GetAlertmanagerConfiguration ¶
func (moa *MultiOrgAlertmanager) GetAlertmanagerConfiguration(ctx context.Context, org int64) (definitions.GettableUserConfig, error)
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) LoadAndSyncAlertmanagersForOrgs ¶
func (moa *MultiOrgAlertmanager) LoadAndSyncAlertmanagersForOrgs(ctx context.Context) 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.
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, cluster.State, prometheus.Registerer) cluster.ClusterChannel
type RedisChannel ¶
type RedisChannel struct {
// contains filtered or unexported fields
}
func (*RedisChannel) Broadcast ¶
func (c *RedisChannel) Broadcast(b []byte)
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