alert

package
v0.7.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidAlertSeverity      = errors.New("invalid alert severity")
	ErrInvalidChannelCriticality = errors.New("invalid channel criticality")
	ErrSubscriptionNotFound      = errors.New("could not find subscription")
	ErrNoSirenReceiver           = errors.New("could not find siren's receiver")
	ErrMultipleSirenReceiver     = errors.New("multiple siren's receivers found")
	ErrInvalidSirenReceiver      = errors.New("invalid siren's receiver type")

	ErrNoShieldOrg                      = errors.New("could not find shield's organization")
	ErrNoShieldProject                  = errors.New("could not find shield's project")
	ErrNoShieldGroup                    = errors.New("could not find shield's group")
	ErrNoShieldParentSlackReceiver      = errors.New("could not find siren's parent slack receiver from shield metadata")
	ErrNoShieldSirenNamespace           = errors.New("could not find siren's namespace id from shield org metadata")
	ErrInvalidShieldSirenNamespace      = errors.New("invalid siren's namespace id from shield org metadata")
	ErrInvalidShieldParentSlackReceiver = errors.New("invalid siren's parent slack receiver from shield org metadata")
)
View Source
var SuppliedVariables = []string{"name", "team", "entity"}

Functions

func AlertRoutes added in v0.7.16

func AlertRoutes(
	siren sirenv1beta1rpc.SirenServiceClient,
	shield shieldv1beta1rpc.ShieldServiceClient,
) func(chi.Router)

func MapToSubscription added in v0.7.9

func MapToSubscription(sirenSub *sirenv1beta1.Subscription) models.Subscription

func MapToSubscriptionList added in v0.7.9

func MapToSubscriptionList(sirenSubs []*sirenv1beta1.Subscription) []models.Subscription

func SubscriptionRoutes added in v0.7.9

func SubscriptionRoutes(
	siren sirenv1beta1rpc.SirenServiceClient,
	shield shieldv1beta1rpc.ShieldServiceClient,
) func(chi.Router)

Types

type Alert

type Alert struct {
	ID          string    `json:"id"`
	Resource    string    `json:"resource"`
	Metric      string    `json:"metric"`
	Value       string    `json:"value"`
	Severity    string    `json:"severity"`
	Rule        string    `json:"Rule"`
	TriggeredAt time.Time `json:"triggered_at"`
}

type AlertChannelForm added in v0.7.11

type AlertChannelForm struct {
	ChannelCriticality  ChannelCriticality
	ChannelName         string
	ChannelType         string
	PagerdutyServiceKey string
}

type AlertSeverity added in v0.7.9

type AlertSeverity string
const (
	AlertSeverityInfo     AlertSeverity = "INFO"
	AlertSeverityWarning  AlertSeverity = "WARNING"
	AlertSeverityCritical AlertSeverity = "CRITICAL"
)

type ChannelCriticality added in v0.7.9

type ChannelCriticality string
const (
	ChannelCriticalityInfo     ChannelCriticality = "INFO"
	ChannelCriticalityWarning  ChannelCriticality = "WARNING"
	ChannelCriticalityCritical ChannelCriticality = "CRITICAL"
)

type ChannelType added in v0.7.11

type ChannelType string
const (
	ChannelTypeSlack     ChannelType = "slack_channel"
	ChannelTypePagerduty ChannelType = "pagerduty"
)

type Handler added in v0.7.9

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler added in v0.7.9

func NewHandler(subscriptionService *SubscriptionService, alertService *Service) *Handler

type Policy

type Policy struct {
	Resource string `json:"resource"`
	Rules    []Rule `json:"rules"`
}

type Rule

type Rule struct {
	ID        string     `json:"id,omitempty"`
	Template  string     `json:"template"`
	Enabled   bool       `json:"enabled"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	Variables []Variable `json:"variables"`
}

func AddSuppliedVariablesFromRules

func AddSuppliedVariablesFromRules(rules []Rule, vars map[string]string) []Rule

func RemoveSuppliedVariablesFromRules

func RemoveSuppliedVariablesFromRules(rules []Rule, varKeys []string) []Rule

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService added in v0.7.16

func NewService(siren sirenv1beta1grpc.SirenServiceClient) *Service

func (*Service) GetAlertPolicy

func (svc *Service) GetAlertPolicy(ctx context.Context, projectSlug, resource, resourceTag string) (*Policy, error)

func (*Service) GetAlertTemplate

func (svc *Service) GetAlertTemplate(ctx context.Context, urn string) (*Template, error)

func (*Service) GetProjectDataSource

func (svc *Service) GetProjectDataSource(ctx context.Context, projectSlug string) (string, error)

func (*Service) HandleListTemplates

func (svc *Service) HandleListTemplates() http.HandlerFunc

func (*Service) ListAlertTemplates

func (svc *Service) ListAlertTemplates(ctx context.Context, tag string) ([]Template, error)

func (*Service) ListAlerts

func (svc *Service) ListAlerts(ctx context.Context, projectSlug, resource string) ([]Alert, error)

func (*Service) UpsertAlertPolicy

func (svc *Service) UpsertAlertPolicy(ctx context.Context, projectSlug string, update Policy) (*Policy, error)

type SirenReceivers added in v0.7.11

type SirenReceivers []*sirenv1beta1.Receiver

func (SirenReceivers) Find added in v0.7.11

func (receivers SirenReceivers) Find(receiverType, severity string) *sirenv1beta1.Receiver

type SubscriptionForm added in v0.7.9

type SubscriptionForm struct {
	UserID             string
	AlertSeverity      AlertSeverity
	ProjectID          string
	ChannelCriticality ChannelCriticality
	GroupID            string
	ResourceID         string
	ResourceType       string
}

type SubscriptionService added in v0.7.9

type SubscriptionService struct {
	// contains filtered or unexported fields
}

func NewSubscriptionService added in v0.7.9

func NewSubscriptionService(
	sirenClient sirenv1beta1grpc.SirenServiceClient,
	shieldClient shieldv1beta1rpc.ShieldServiceClient,
) *SubscriptionService

func (*SubscriptionService) CreateSubscription added in v0.7.9

func (svc *SubscriptionService) CreateSubscription(ctx context.Context, form SubscriptionForm) (int, error)

func (*SubscriptionService) DeleteSubscription added in v0.7.9

func (svc *SubscriptionService) DeleteSubscription(ctx context.Context, subscriptionID int) error

func (*SubscriptionService) FindSubscription added in v0.7.9

func (svc *SubscriptionService) FindSubscription(ctx context.Context, subscriptionID int) (*sirenv1beta1.Subscription, error)

func (*SubscriptionService) GetAlertChannels added in v0.7.9

func (svc *SubscriptionService) GetAlertChannels(ctx context.Context, groupID string) ([]models.AlertChannel, error)

func (*SubscriptionService) GetSubscriptions added in v0.7.9

func (svc *SubscriptionService) GetSubscriptions(ctx context.Context, groupID, resourceID, resourceType string) ([]*sirenv1beta1.Subscription, error)

func (*SubscriptionService) SetAlertChannels added in v0.7.11

func (svc *SubscriptionService) SetAlertChannels(ctx context.Context, userID string, groupID string, forms []AlertChannelForm) ([]models.AlertChannel, error)

func (*SubscriptionService) UpdateSubscription added in v0.7.9

func (svc *SubscriptionService) UpdateSubscription(ctx context.Context, subscriptionID int, form SubscriptionForm) error

type Template

type Template struct {
	ID        string     `json:"id"`
	Name      string     `json:"name"`
	Body      string     `json:"body"`
	Tags      []string   `json:"tags"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	Variables []Variable `json:"variables"`
}

func RemoveSuppliedVariablesFromTemplates

func RemoveSuppliedVariablesFromTemplates(templates []Template, varKeys []string) []Template

type Variable

type Variable struct {
	Name        string `json:"name"`
	Value       string `json:"value,omitempty"`
	Default     string `json:"default,omitempty"`
	Type        string `json:"type"`
	Description string `json:"description"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL