Documentation
¶
Index ¶
Constants ¶
const NA = "N/A"
const True = "true"
Variables ¶
var ErrRateLimit = errors.New("rate limit exceeded")
Functions ¶
This section is empty.
Types ¶
type ChannelInfo ¶
type ChannelInfo struct {
ChannelExists bool
ChannelIsArchived bool
ManagerIsInChannel bool
UserCount int
}
ChannelInfo contains information about a Slack channel.
type ChannelInfoProvider ¶
type ChannelInfoProvider interface {
GetChannelInfo(ctx context.Context, channel string) (*ChannelInfo, error)
MapChannelNameToIDIfNeeded(channelName string) string
ManagedChannels() []*internal.ChannelSummary
}
ChannelInfoProvider defines the interface for channel information operations.
type FifoQueueConsumer ¶
type FifoQueueConsumer interface {
Receive(ctx context.Context, sinkCh chan<- *types.FifoQueueItem) error
}
type FifoQueueProducer ¶
type PrometheusAlert ¶
type PrometheusAlert struct {
Status string `json:"status,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
StartsAt time.Time `json:"startsAt"`
EndsAt time.Time `json:"endsAt"`
GeneratorURL string `json:"generatorURL,omitempty"` //nolint:tagliatelle
Fingerprint string `json:"fingerprint,omitempty"`
}
type PrometheusWebhook ¶
type PrometheusWebhook struct {
Version string `json:"version,omitempty"`
GroupKey string `json:"groupKey,omitempty"`
TruncatedAlerts int `json:"truncatedAlerts,omitempty"`
Status string `json:"status,omitempty"`
Receiver string `json:"receiver,omitempty"`
GroupLabels map[string]string `json:"groupLabels,omitempty"`
CommonLabels map[string]string `json:"commonLabels,omitempty"`
CommonAnnotations map[string]string `json:"commonAnnotations,omitempty"`
ExternalURL string `json:"externalURL,omitempty"` //nolint:tagliatelle
Alerts []*PrometheusAlert `json:"alerts,omitempty"`
}
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func New ¶
func New(alertQueue FifoQueueProducer, cacheStore cachestore.StoreInterface, logger types.Logger, metrics types.Metrics, cfg *config.APIConfig, settings *config.APISettings) *Server
func (*Server) Run ¶
Run starts the HTTP server and handles incoming requests. It also initializes the Slack API client and the channel info syncer. If raw alert consumers are set, it will start dedicated consumers for those queues.
This method blocks until the context is cancelled, or a server error occurs.
func (*Server) UpdateSettings ¶
func (s *Server) UpdateSettings(settings *config.APISettings) error
func (*Server) WithRawAlertConsumer ¶
func (s *Server) WithRawAlertConsumer(consumer FifoQueueConsumer) *Server
WithRawAlertConsumer defines an alternative alert consumer, which reads from a FIFO queue and processes the items similarly to the main rest API. The consumer is started by Run(ctx), and the queue is consumed in a separate goroutine.
Multiple raw alert consumers can be added.
The server can receive alerts from both the main rest API and the raw alert consumers simultaneously.
The queue item body must be a single JSON-serialized types.Alert. Prometheus webhooks are not supported here.
type SlackClient ¶
type SlackClient interface {
GetChannelInfo(ctx context.Context, channelID string) (*slack.Channel, error)
GetUserIDsInChannel(ctx context.Context, channelID string) (map[string]struct{}, error)
BotIsInChannel(ctx context.Context, channelID string) (bool, error)
ListBotChannels(ctx context.Context) ([]*internal.ChannelSummary, error)
}