2025-02-18 13:06:31 +05:30
|
|
|
package alertmanager
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
2025-03-20 21:01:41 +05:30
|
|
|
"github.com/SigNoz/signoz/pkg/errors"
|
|
|
|
|
"github.com/SigNoz/signoz/pkg/factory"
|
2025-06-09 16:43:29 +05:30
|
|
|
"github.com/SigNoz/signoz/pkg/statsreporter"
|
2025-03-20 21:01:41 +05:30
|
|
|
"github.com/SigNoz/signoz/pkg/types/alertmanagertypes"
|
2025-04-03 23:26:49 +05:30
|
|
|
"github.com/SigNoz/signoz/pkg/valuer"
|
2025-02-18 13:06:31 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
ErrCodeAlertmanagerNotFound = errors.MustNewCode("alertmanager_not_found")
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Alertmanager interface {
|
|
|
|
|
factory.Service
|
|
|
|
|
// GetAlerts gets the alerts from the alertmanager per organization.
|
2025-03-05 10:01:02 +05:30
|
|
|
GetAlerts(context.Context, string, alertmanagertypes.GettableAlertsParams) (alertmanagertypes.DeprecatedGettableAlerts, error)
|
2025-02-18 13:06:31 +05:30
|
|
|
|
|
|
|
|
// PutAlerts puts the alerts into the alertmanager per organization.
|
|
|
|
|
PutAlerts(context.Context, string, alertmanagertypes.PostableAlerts) error
|
|
|
|
|
|
|
|
|
|
// TestReceiver sends a test alert to a receiver.
|
|
|
|
|
TestReceiver(context.Context, string, alertmanagertypes.Receiver) error
|
2025-02-20 14:14:09 +05:30
|
|
|
|
2025-03-05 10:01:02 +05:30
|
|
|
// TestAlert sends an alert to a list of receivers.
|
|
|
|
|
TestAlert(ctx context.Context, orgID string, alert *alertmanagertypes.PostableAlert, receivers []string) error
|
|
|
|
|
|
2025-02-20 14:14:09 +05:30
|
|
|
// ListChannels lists all channels for the organization.
|
|
|
|
|
ListChannels(context.Context, string) ([]*alertmanagertypes.Channel, error)
|
|
|
|
|
|
2025-03-05 10:01:02 +05:30
|
|
|
// ListAllChannels lists all channels for all organizations. It is used by the legacy alertmanager only.
|
|
|
|
|
ListAllChannels(context.Context) ([]*alertmanagertypes.Channel, error)
|
|
|
|
|
|
2025-02-20 14:14:09 +05:30
|
|
|
// GetChannelByID gets a channel for the organization.
|
2025-04-03 23:26:49 +05:30
|
|
|
GetChannelByID(context.Context, string, valuer.UUID) (*alertmanagertypes.Channel, error)
|
2025-02-20 14:14:09 +05:30
|
|
|
|
|
|
|
|
// UpdateChannel updates a channel for the organization.
|
2025-04-03 23:26:49 +05:30
|
|
|
UpdateChannelByReceiverAndID(context.Context, string, alertmanagertypes.Receiver, valuer.UUID) error
|
2025-02-20 14:14:09 +05:30
|
|
|
|
|
|
|
|
// CreateChannel creates a channel for the organization.
|
|
|
|
|
CreateChannel(context.Context, string, alertmanagertypes.Receiver) error
|
|
|
|
|
|
|
|
|
|
// DeleteChannelByID deletes a channel for the organization.
|
2025-04-03 23:26:49 +05:30
|
|
|
DeleteChannelByID(context.Context, string, valuer.UUID) error
|
2025-03-05 10:01:02 +05:30
|
|
|
|
|
|
|
|
// SetConfig sets the config for the organization.
|
|
|
|
|
SetConfig(context.Context, *alertmanagertypes.Config) error
|
|
|
|
|
|
|
|
|
|
// GetConfig gets the config for the organization.
|
|
|
|
|
GetConfig(context.Context, string) (*alertmanagertypes.Config, error)
|
2025-03-10 01:30:42 +05:30
|
|
|
|
|
|
|
|
// SetDefaultConfig sets the default config for the organization.
|
|
|
|
|
SetDefaultConfig(context.Context, string) error
|
2025-06-09 16:43:29 +05:30
|
|
|
|
2025-09-26 18:54:58 +05:30
|
|
|
SetNotificationConfig(ctx context.Context, orgID valuer.UUID, ruleId string, config *alertmanagertypes.NotificationConfig) error
|
|
|
|
|
|
|
|
|
|
DeleteNotificationConfig(ctx context.Context, orgID valuer.UUID, ruleId string) error
|
|
|
|
|
|
2025-06-09 16:43:29 +05:30
|
|
|
// Collects stats for the organization.
|
|
|
|
|
statsreporter.StatsCollector
|
2025-02-18 13:06:31 +05:30
|
|
|
}
|