mirror of https://github.com/grafana/grafana.git
				
				
				
			Alerting: Separate the forked Alertmanager into two implementations (#77582)
This commit is contained in:
		
							parent
							
								
									0abfc3b6be
								
							
						
					
					
						commit
						01af8f61f1
					
				|  | @ -1,94 +0,0 @@ | |||
| package remote | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 
 | ||||
| 	apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" | ||||
| 	"github.com/grafana/grafana/pkg/services/ngalert/models" | ||||
| 	"github.com/grafana/grafana/pkg/services/ngalert/notifier" | ||||
| ) | ||||
| 
 | ||||
| type Mode int | ||||
| 
 | ||||
| const ( | ||||
| 	ModeRemoteSecondary Mode = iota | ||||
| 	ModeRemotePrimary | ||||
| ) | ||||
| 
 | ||||
| type ForkedAlertmanager struct { | ||||
| 	internal notifier.Alertmanager | ||||
| 	remote   notifier.Alertmanager | ||||
| 	mode     Mode | ||||
| } | ||||
| 
 | ||||
| func NewForkedAlertmanager(internal, remote notifier.Alertmanager, m Mode) *ForkedAlertmanager { | ||||
| 	return &ForkedAlertmanager{ | ||||
| 		internal: internal, | ||||
| 		remote:   remote, | ||||
| 		mode:     m, | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func (fam *ForkedAlertmanager) ApplyConfig(ctx context.Context, config *models.AlertConfiguration) error { | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (fam *ForkedAlertmanager) SaveAndApplyConfig(ctx context.Context, config *apimodels.PostableUserConfig) error { | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (fam *ForkedAlertmanager) SaveAndApplyDefaultConfig(ctx context.Context) error { | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (fam *ForkedAlertmanager) GetStatus() apimodels.GettableStatus { | ||||
| 	return apimodels.GettableStatus{} | ||||
| } | ||||
| 
 | ||||
| func (fam *ForkedAlertmanager) CreateSilence(ctx context.Context, silence *apimodels.PostableSilence) (string, error) { | ||||
| 	return "", nil | ||||
| } | ||||
| 
 | ||||
| func (fam *ForkedAlertmanager) DeleteSilence(ctx context.Context, id string) error { | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (fam *ForkedAlertmanager) GetSilence(ctx context.Context, id string) (apimodels.GettableSilence, error) { | ||||
| 	return apimodels.GettableSilence{}, nil | ||||
| } | ||||
| 
 | ||||
| func (fam *ForkedAlertmanager) ListSilences(ctx context.Context, filter []string) (apimodels.GettableSilences, error) { | ||||
| 	return apimodels.GettableSilences{}, nil | ||||
| } | ||||
| 
 | ||||
| func (fam *ForkedAlertmanager) GetAlerts(ctx context.Context, active, silenced, inhibited bool, filter []string, receiver string) (apimodels.GettableAlerts, error) { | ||||
| 	return apimodels.GettableAlerts{}, nil | ||||
| } | ||||
| 
 | ||||
| func (fam *ForkedAlertmanager) GetAlertGroups(ctx context.Context, active, silenced, inhibited bool, filter []string, receiver string) (apimodels.AlertGroups, error) { | ||||
| 	return apimodels.AlertGroups{}, nil | ||||
| } | ||||
| 
 | ||||
| func (fam *ForkedAlertmanager) PutAlerts(ctx context.Context, alerts apimodels.PostableAlerts) error { | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (fam *ForkedAlertmanager) GetReceivers(ctx context.Context) ([]apimodels.Receiver, error) { | ||||
| 	return []apimodels.Receiver{}, nil | ||||
| } | ||||
| 
 | ||||
| func (fam *ForkedAlertmanager) TestReceivers(ctx context.Context, c apimodels.TestReceiversConfigBodyParams) (*notifier.TestReceiversResult, error) { | ||||
| 	return ¬ifier.TestReceiversResult{}, nil | ||||
| } | ||||
| 
 | ||||
| func (fam *ForkedAlertmanager) TestTemplate(ctx context.Context, c apimodels.TestTemplatesConfigBodyParams) (*notifier.TestTemplatesResults, error) { | ||||
| 	return ¬ifier.TestTemplatesResults{}, nil | ||||
| } | ||||
| 
 | ||||
| func (fam *ForkedAlertmanager) CleanUp() {} | ||||
| 
 | ||||
| func (fam *ForkedAlertmanager) StopAndWait() {} | ||||
| 
 | ||||
| func (fam *ForkedAlertmanager) Ready() bool { | ||||
| 	return false | ||||
| } | ||||
|  | @ -0,0 +1,85 @@ | |||
| package remote | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 
 | ||||
| 	apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" | ||||
| 	"github.com/grafana/grafana/pkg/services/ngalert/models" | ||||
| 	"github.com/grafana/grafana/pkg/services/ngalert/notifier" | ||||
| ) | ||||
| 
 | ||||
| type RemotePrimaryForkedAlertmanager struct { | ||||
| 	internal notifier.Alertmanager | ||||
| 	remote   notifier.Alertmanager | ||||
| } | ||||
| 
 | ||||
| func NewRemotePrimaryForkedAlertmanager(internal, remote notifier.Alertmanager) *RemotePrimaryForkedAlertmanager { | ||||
| 	return &RemotePrimaryForkedAlertmanager{ | ||||
| 		internal: internal, | ||||
| 		remote:   remote, | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func (fam *RemotePrimaryForkedAlertmanager) ApplyConfig(ctx context.Context, config *models.AlertConfiguration) error { | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemotePrimaryForkedAlertmanager) SaveAndApplyConfig(ctx context.Context, config *apimodels.PostableUserConfig) error { | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemotePrimaryForkedAlertmanager) SaveAndApplyDefaultConfig(ctx context.Context) error { | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemotePrimaryForkedAlertmanager) GetStatus() apimodels.GettableStatus { | ||||
| 	return apimodels.GettableStatus{} | ||||
| } | ||||
| 
 | ||||
| func (fam *RemotePrimaryForkedAlertmanager) CreateSilence(ctx context.Context, silence *apimodels.PostableSilence) (string, error) { | ||||
| 	return "", nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemotePrimaryForkedAlertmanager) DeleteSilence(ctx context.Context, id string) error { | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemotePrimaryForkedAlertmanager) GetSilence(ctx context.Context, id string) (apimodels.GettableSilence, error) { | ||||
| 	return apimodels.GettableSilence{}, nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemotePrimaryForkedAlertmanager) ListSilences(ctx context.Context, filter []string) (apimodels.GettableSilences, error) { | ||||
| 	return apimodels.GettableSilences{}, nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemotePrimaryForkedAlertmanager) GetAlerts(ctx context.Context, active, silenced, inhibited bool, filter []string, receiver string) (apimodels.GettableAlerts, error) { | ||||
| 	return apimodels.GettableAlerts{}, nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemotePrimaryForkedAlertmanager) GetAlertGroups(ctx context.Context, active, silenced, inhibited bool, filter []string, receiver string) (apimodels.AlertGroups, error) { | ||||
| 	return apimodels.AlertGroups{}, nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemotePrimaryForkedAlertmanager) PutAlerts(ctx context.Context, alerts apimodels.PostableAlerts) error { | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemotePrimaryForkedAlertmanager) GetReceivers(ctx context.Context) ([]apimodels.Receiver, error) { | ||||
| 	return []apimodels.Receiver{}, nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemotePrimaryForkedAlertmanager) TestReceivers(ctx context.Context, c apimodels.TestReceiversConfigBodyParams) (*notifier.TestReceiversResult, error) { | ||||
| 	return ¬ifier.TestReceiversResult{}, nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemotePrimaryForkedAlertmanager) TestTemplate(ctx context.Context, c apimodels.TestTemplatesConfigBodyParams) (*notifier.TestTemplatesResults, error) { | ||||
| 	return ¬ifier.TestTemplatesResults{}, nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemotePrimaryForkedAlertmanager) CleanUp() {} | ||||
| 
 | ||||
| func (fam *RemotePrimaryForkedAlertmanager) StopAndWait() {} | ||||
| 
 | ||||
| func (fam *RemotePrimaryForkedAlertmanager) Ready() bool { | ||||
| 	return false | ||||
| } | ||||
|  | @ -0,0 +1,85 @@ | |||
| package remote | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 
 | ||||
| 	apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" | ||||
| 	"github.com/grafana/grafana/pkg/services/ngalert/models" | ||||
| 	"github.com/grafana/grafana/pkg/services/ngalert/notifier" | ||||
| ) | ||||
| 
 | ||||
| type RemoteSecondaryForkedAlertmanager struct { | ||||
| 	internal notifier.Alertmanager | ||||
| 	remote   notifier.Alertmanager | ||||
| } | ||||
| 
 | ||||
| func NewRemoteSecondaryForkedAlertmanager(internal, remote notifier.Alertmanager) *RemoteSecondaryForkedAlertmanager { | ||||
| 	return &RemoteSecondaryForkedAlertmanager{ | ||||
| 		internal: internal, | ||||
| 		remote:   remote, | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func (fam *RemoteSecondaryForkedAlertmanager) ApplyConfig(ctx context.Context, config *models.AlertConfiguration) error { | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemoteSecondaryForkedAlertmanager) SaveAndApplyConfig(ctx context.Context, config *apimodels.PostableUserConfig) error { | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemoteSecondaryForkedAlertmanager) SaveAndApplyDefaultConfig(ctx context.Context) error { | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemoteSecondaryForkedAlertmanager) GetStatus() apimodels.GettableStatus { | ||||
| 	return apimodels.GettableStatus{} | ||||
| } | ||||
| 
 | ||||
| func (fam *RemoteSecondaryForkedAlertmanager) CreateSilence(ctx context.Context, silence *apimodels.PostableSilence) (string, error) { | ||||
| 	return "", nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemoteSecondaryForkedAlertmanager) DeleteSilence(ctx context.Context, id string) error { | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemoteSecondaryForkedAlertmanager) GetSilence(ctx context.Context, id string) (apimodels.GettableSilence, error) { | ||||
| 	return apimodels.GettableSilence{}, nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemoteSecondaryForkedAlertmanager) ListSilences(ctx context.Context, filter []string) (apimodels.GettableSilences, error) { | ||||
| 	return apimodels.GettableSilences{}, nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemoteSecondaryForkedAlertmanager) GetAlerts(ctx context.Context, active, silenced, inhibited bool, filter []string, receiver string) (apimodels.GettableAlerts, error) { | ||||
| 	return apimodels.GettableAlerts{}, nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemoteSecondaryForkedAlertmanager) GetAlertGroups(ctx context.Context, active, silenced, inhibited bool, filter []string, receiver string) (apimodels.AlertGroups, error) { | ||||
| 	return apimodels.AlertGroups{}, nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemoteSecondaryForkedAlertmanager) PutAlerts(ctx context.Context, alerts apimodels.PostableAlerts) error { | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemoteSecondaryForkedAlertmanager) GetReceivers(ctx context.Context) ([]apimodels.Receiver, error) { | ||||
| 	return []apimodels.Receiver{}, nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemoteSecondaryForkedAlertmanager) TestReceivers(ctx context.Context, c apimodels.TestReceiversConfigBodyParams) (*notifier.TestReceiversResult, error) { | ||||
| 	return ¬ifier.TestReceiversResult{}, nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemoteSecondaryForkedAlertmanager) TestTemplate(ctx context.Context, c apimodels.TestTemplatesConfigBodyParams) (*notifier.TestTemplatesResults, error) { | ||||
| 	return ¬ifier.TestTemplatesResults{}, nil | ||||
| } | ||||
| 
 | ||||
| func (fam *RemoteSecondaryForkedAlertmanager) CleanUp() {} | ||||
| 
 | ||||
| func (fam *RemoteSecondaryForkedAlertmanager) StopAndWait() {} | ||||
| 
 | ||||
| func (fam *RemoteSecondaryForkedAlertmanager) Ready() bool { | ||||
| 	return false | ||||
| } | ||||
		Loading…
	
		Reference in New Issue