Documentation ¶
Index ¶
- Constants
- Variables
- func GetAvailableNotifiers() []*alerting.NotifierPlugin
- func Load(rawConfig []byte) (*api.PostableUserConfig, error)
- func PersistTemplates(cfg *api.PostableUserConfig, path string) ([]string, bool, error)
- type AlertValidationError
- type Alertmanager
- func (am *Alertmanager) ApplyConfig(dbCfg *ngmodels.AlertConfiguration) error
- func (am *Alertmanager) CreateSilence(ps *apimodels.PostableSilence) (string, error)
- func (am *Alertmanager) DeleteSilence(silenceID string) error
- func (am *Alertmanager) GetAlertGroups(active, silenced, inhibited bool, filter []string, receivers string) (apimodels.AlertGroups, error)
- func (am *Alertmanager) GetAlerts(active, silenced, inhibited bool, filter []string, receivers string) (apimodels.GettableAlerts, error)
- func (am *Alertmanager) GetSilence(silenceID string) (apimodels.GettableSilence, error)
- func (am *Alertmanager) GetStatus() apimodels.GettableStatus
- func (am *Alertmanager) ListSilences(filter []string) (apimodels.GettableSilences, error)
- func (am *Alertmanager) PutAlerts(postableAlerts apimodels.PostableAlerts) error
- func (am *Alertmanager) Ready() bool
- func (am *Alertmanager) SaveAndApplyConfig(cfg *apimodels.PostableUserConfig) error
- func (am *Alertmanager) SaveAndApplyDefaultConfig() error
- func (am *Alertmanager) StopAndWait()
- func (am *Alertmanager) TestReceivers(ctx context.Context, c apimodels.TestReceiversConfigParams) (*TestReceiversResult, error)
- func (am *Alertmanager) WorkingDirPath() string
- type ClusterPeer
- type FakeConfigStore
- func (f *FakeConfigStore) GetAllLatestAlertmanagerConfiguration(context.Context) ([]*models.AlertConfiguration, error)
- func (f *FakeConfigStore) GetLatestAlertmanagerConfiguration(query *models.GetLatestAlertmanagerConfigurationQuery) error
- func (f *FakeConfigStore) SaveAlertmanagerConfiguration(cmd *models.SaveAlertmanagerConfigurationCmd) error
- func (f *FakeConfigStore) SaveAlertmanagerConfigurationWithCallback(cmd *models.SaveAlertmanagerConfigurationCmd, callback store.SaveCallback) error
- 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) 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 State) (int64, error)
- func (fileStore *FileStore) WriteFileToDisk(fn string, content []byte) error
- type InvalidReceiverError
- type MultiOrgAlertmanager
- func (moa *MultiOrgAlertmanager) AlertmanagerFor(orgID int64) (*Alertmanager, 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 NotificationChannel
- type ReceiverTimeoutError
- type State
- type TestReceiverConfigResult
- type TestReceiverResult
- type TestReceiversResult
Constants ¶
const KVNamespace = "alertmanager"
Variables ¶
var ( ErrGetAlertsInternal = fmt.Errorf("unable to retrieve alerts(s) due to an internal error") ErrGetAlertsBadPayload = fmt.Errorf("unable to retrieve alerts") ErrGetAlertGroupsBadPayload = fmt.Errorf("unable to retrieve alerts groups") )
var ( ErrNoAlertmanagerForOrg = fmt.Errorf("Alertmanager does not exist for this organization") ErrAlertmanagerNotReady = fmt.Errorf("Alertmanager is not ready yet") )
var ( ErrGetSilencesInternal = fmt.Errorf("unable to retrieve silence(s) due to an internal error") ErrDeleteSilenceInternal = fmt.Errorf("unable to delete silence due to an internal error") ErrCreateSilenceBadPayload = fmt.Errorf("unable to create silence") ErrListSilencesBadPayload = fmt.Errorf("unable to list silences") ErrSilenceNotFound = silence.ErrNotFound )
var (
ErrNoReceivers = errors.New("no receivers")
)
Functions ¶
func GetAvailableNotifiers ¶
func GetAvailableNotifiers() []*alerting.NotifierPlugin
GetAvailableNotifiers returns the metadata of all the notification channels that can be configured.
func PersistTemplates ¶
Types ¶
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 Alertmanager ¶
type Alertmanager struct { Settings *setting.Cfg Store store.AlertingStore Metrics *metrics.Alertmanager // contains filtered or unexported fields }
func (*Alertmanager) ApplyConfig ¶
func (am *Alertmanager) ApplyConfig(dbCfg *ngmodels.AlertConfiguration) error
ApplyConfig applies the configuration to the Alertmanager.
func (*Alertmanager) CreateSilence ¶
func (am *Alertmanager) CreateSilence(ps *apimodels.PostableSilence) (string, error)
CreateSilence persists the provided silence and returns the silence ID if successful.
func (*Alertmanager) DeleteSilence ¶
func (am *Alertmanager) DeleteSilence(silenceID string) error
DeleteSilence looks for and expires the silence by the provided silenceID. It returns ErrSilenceNotFound if the silence is not present.
func (*Alertmanager) GetAlertGroups ¶
func (am *Alertmanager) GetAlertGroups(active, silenced, inhibited bool, filter []string, receivers string) (apimodels.AlertGroups, error)
func (*Alertmanager) GetAlerts ¶
func (am *Alertmanager) GetAlerts(active, silenced, inhibited bool, filter []string, receivers string) (apimodels.GettableAlerts, error)
func (*Alertmanager) GetSilence ¶
func (am *Alertmanager) GetSilence(silenceID string) (apimodels.GettableSilence, error)
GetSilence retrieves a silence by the provided silenceID. It returns ErrSilenceNotFound if the silence is not present.
func (*Alertmanager) GetStatus ¶
func (am *Alertmanager) GetStatus() apimodels.GettableStatus
func (*Alertmanager) ListSilences ¶
func (am *Alertmanager) ListSilences(filter []string) (apimodels.GettableSilences, error)
ListSilences retrieves a list of stored silences. It supports a set of labels as filters.
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(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() error
SaveAndApplyDefaultConfig saves the default configuration the database and applies the configuration to the Alertmanager. It rollbacks 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.TestReceiversConfigParams) (*TestReceiversResult, error)
func (*Alertmanager) WorkingDirPath ¶
func (am *Alertmanager) WorkingDirPath() string
type ClusterPeer ¶
type ClusterPeer interface { AddState(string, cluster.State, prometheus.Registerer) cluster.ClusterChannel Position() int WaitReady(context.Context) error }
type FakeConfigStore ¶
type FakeConfigStore struct {
// contains filtered or unexported fields
}
func (*FakeConfigStore) GetAllLatestAlertmanagerConfiguration ¶
func (f *FakeConfigStore) GetAllLatestAlertmanagerConfiguration(context.Context) ([]*models.AlertConfiguration, error)
func (*FakeConfigStore) GetLatestAlertmanagerConfiguration ¶
func (f *FakeConfigStore) GetLatestAlertmanagerConfiguration(query *models.GetLatestAlertmanagerConfigurationQuery) error
func (*FakeConfigStore) SaveAlertmanagerConfiguration ¶
func (f *FakeConfigStore) SaveAlertmanagerConfiguration(cmd *models.SaveAlertmanagerConfigurationCmd) error
func (*FakeConfigStore) SaveAlertmanagerConfigurationWithCallback ¶
func (f *FakeConfigStore) SaveAlertmanagerConfigurationWithCallback(cmd *models.SaveAlertmanagerConfigurationCmd, callback store.SaveCallback) error
type FakeKVStore ¶
type FakeKVStore struct {
// contains filtered or unexported fields
}
type FakeOrgStore ¶
type FakeOrgStore struct {
// contains filtered or unexported fields
}
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 InvalidReceiverError ¶
type InvalidReceiverError struct { Receiver *apimodels.PostableGrafanaReceiver Err error }
func (InvalidReceiverError) Error ¶
func (e InvalidReceiverError) Error() string
type MultiOrgAlertmanager ¶
type MultiOrgAlertmanager struct {
// contains filtered or unexported fields
}
func NewMultiOrgAlertmanager ¶
func NewMultiOrgAlertmanager(cfg *setting.Cfg, configStore store.AlertingStore, orgStore store.OrgStore, kvStore kvstore.KVStore, decryptFn channels.GetDecryptedValueFn, m *metrics.MultiOrgAlertmanager, l log.Logger, ) (*MultiOrgAlertmanager, error)
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) 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 NotificationChannel ¶
type NotificationChannel interface { notify.Notifier notify.ResolvedSender }
type ReceiverTimeoutError ¶
type ReceiverTimeoutError struct { Receiver *apimodels.PostableGrafanaReceiver Err error }
func (ReceiverTimeoutError) Error ¶
func (e ReceiverTimeoutError) Error() string
type State ¶
State represents any of the two 'states' of the alertmanager. Notification log or Silences. MarshalBinary returns the binary representation of this internal state based on the protobuf.
type TestReceiverResult ¶
type TestReceiverResult struct { Name string Configs []TestReceiverConfigResult }
type TestReceiversResult ¶
type TestReceiversResult struct { Alert types.Alert Receivers []TestReceiverResult NotifedAt time.Time }