Documentation ¶
Index ¶
- Variables
- func DecodeAlertFilter(req bunrouter.Request, f *AlertFilter) error
- func Init(ctx context.Context, app *bunapp.App)
- func InsertNotifChannel(ctx context.Context, app *bunapp.App, channel NotifChannel) error
- func NewAlertmanagerMessage(app *bunapp.App, project *org.Project, alert org.Alert) (models.PostableAlerts, error)
- func SelectAlert(ctx context.Context, app *bunapp.App, id uint64) (org.Alert, error)
- func SelectBaseAlert(ctx context.Context, app *bunapp.App, alertID uint64) (*org.BaseAlert, error)
- func UpdateNotifChannel(ctx context.Context, app *bunapp.App, channel NotifChannel) error
- func UpdateNotifChannelState(ctx context.Context, app *bunapp.App, channel *BaseNotifChannel, ...) error
- type AlertFilter
- type AlertFormatter
- type AlertFormatterOption
- func WithClosedByTemplate(tpl ...string) AlertFormatterOption
- func WithClosedTemplate(tpl ...string) AlertFormatterOption
- func WithCreatedTemplate(tpl ...string) AlertFormatterOption
- func WithRecurringTemplate(tpl ...string) AlertFormatterOption
- func WithReopenedByTemplate(tpl ...string) AlertFormatterOption
- func WithReopenedTemplate(tpl ...string) AlertFormatterOption
- type AlertHandler
- func (h *AlertHandler) Close(w http.ResponseWriter, req bunrouter.Request) error
- func (h *AlertHandler) Delete(w http.ResponseWriter, req bunrouter.Request) error
- func (h *AlertHandler) List(w http.ResponseWriter, req bunrouter.Request) error
- func (h *AlertHandler) Open(w http.ResponseWriter, req bunrouter.Request) error
- func (h *AlertHandler) Show(w http.ResponseWriter, req bunrouter.Request) error
- type BaseNotifChannel
- type EmailNotifier
- type ErrorAlert
- type ErrorAlertEvent
- type ErrorMonitorIn
- type Manager
- type ManagerConfig
- type MetricAlert
- type MetricAlertEvent
- type MetricAlertParams
- type MetricMonitorIn
- type Middleware
- type MonitorFilter
- type MonitorHandler
- func (h *MonitorHandler) Activate(w http.ResponseWriter, req bunrouter.Request) error
- func (h *MonitorHandler) CreateErrorMonitor(w http.ResponseWriter, req bunrouter.Request) error
- func (h *MonitorHandler) CreateMetricMonitor(w http.ResponseWriter, req bunrouter.Request) error
- func (h *MonitorHandler) CreateMonitorFromYAML(w http.ResponseWriter, req bunrouter.Request) error
- func (h *MonitorHandler) Delete(w http.ResponseWriter, req bunrouter.Request) error
- func (h *MonitorHandler) List(w http.ResponseWriter, req bunrouter.Request) error
- func (h *MonitorHandler) Pause(w http.ResponseWriter, req bunrouter.Request) error
- func (h *MonitorHandler) Show(w http.ResponseWriter, req bunrouter.Request) error
- func (h *MonitorHandler) ShowYAML(w http.ResponseWriter, req bunrouter.Request) error
- func (h *MonitorHandler) UpdateErrorMonitor(w http.ResponseWriter, req bunrouter.Request) error
- func (h *MonitorHandler) UpdateMetricMonitor(w http.ResponseWriter, req bunrouter.Request) error
- type MonitorOut
- type NotifChannel
- type NotifChannelHandler
- func (h *NotifChannelHandler) Delete(w http.ResponseWriter, req bunrouter.Request) error
- func (h *NotifChannelHandler) EmailShow(w http.ResponseWriter, req bunrouter.Request) error
- func (h *NotifChannelHandler) EmailUpdate(w http.ResponseWriter, req bunrouter.Request) error
- func (h *NotifChannelHandler) List(w http.ResponseWriter, req bunrouter.Request) error
- func (h *NotifChannelHandler) Pause(w http.ResponseWriter, req bunrouter.Request) error
- func (h *NotifChannelHandler) SlackCreate(w http.ResponseWriter, req bunrouter.Request) error
- func (h *NotifChannelHandler) SlackShow(w http.ResponseWriter, req bunrouter.Request) error
- func (h *NotifChannelHandler) SlackUpdate(w http.ResponseWriter, req bunrouter.Request) error
- func (h *NotifChannelHandler) TelegramCreate(w http.ResponseWriter, req bunrouter.Request) error
- func (h *NotifChannelHandler) TelegramShow(w http.ResponseWriter, req bunrouter.Request) error
- func (h *NotifChannelHandler) TelegramUpdate(w http.ResponseWriter, req bunrouter.Request) error
- func (h *NotifChannelHandler) Unpause(w http.ResponseWriter, req bunrouter.Request) error
- func (h *NotifChannelHandler) UpdateNotifChannelState(w http.ResponseWriter, req bunrouter.Request, state NotifChannelState) error
- func (h *NotifChannelHandler) WebhookCreate(w http.ResponseWriter, req bunrouter.Request) error
- func (h *NotifChannelHandler) WebhookShow(w http.ResponseWriter, req bunrouter.Request) error
- func (h *NotifChannelHandler) WebhookUpdate(w http.ResponseWriter, req bunrouter.Request) error
- type NotifChannelState
- type NotifChannelType
- type SlackNotifChannel
- type SlackNotifChannelIn
- type SlackParams
- type StateCount
- type TelegramNotifChannel
- type TelegramNotifChannelIn
- type TelegramParams
- type WebhookMessage
- type WebhookNotifChannel
- type WebhookNotifChannelIn
- type WebhookParams
Constants ¶
This section is empty.
Variables ¶
View Source
var ( NotifyByEmailTask = taskq.NewTask("notify-by-email") NotifyBySlackTask = taskq.NewTask("notify-by-slack") NotifyByWebhookTask = taskq.NewTask("notify-by-webhook") NotifyByTelegramTask = taskq.NewTask("notify-by-telegram") )
Functions ¶
func DecodeAlertFilter ¶
func DecodeAlertFilter(req bunrouter.Request, f *AlertFilter) error
func InsertNotifChannel ¶
func NewAlertmanagerMessage ¶
func SelectAlert ¶
func SelectBaseAlert ¶
func UpdateNotifChannel ¶
func UpdateNotifChannelState ¶
func UpdateNotifChannelState( ctx context.Context, app *bunapp.App, channel *BaseNotifChannel, state NotifChannelState, ) error
Types ¶
type AlertFilter ¶
type AlertFilter struct { ProjectID uint32 `urlstruct:"-"` org.FacetFilter org.OrderByMixin Status []string Type []string MonitorID uint64 }
func (*AlertFilter) Clone ¶
func (f *AlertFilter) Clone() *AlertFilter
func (*AlertFilter) PGOrder ¶
func (f *AlertFilter) PGOrder(q *bun.SelectQuery) *bun.SelectQuery
func (*AlertFilter) UnmarshalValues ¶
func (*AlertFilter) WhereClause ¶
func (f *AlertFilter) WhereClause(q *bun.SelectQuery) *bun.SelectQuery
type AlertFormatter ¶
type AlertFormatter struct {
// contains filtered or unexported fields
}
func NewAlertFormatter ¶
func NewAlertFormatter(breakLine string, opts ...AlertFormatterOption) *AlertFormatter
type AlertFormatterOption ¶
type AlertFormatterOption func(*AlertFormatter)
func WithClosedByTemplate ¶
func WithClosedByTemplate(tpl ...string) AlertFormatterOption
func WithClosedTemplate ¶
func WithClosedTemplate(tpl ...string) AlertFormatterOption
func WithCreatedTemplate ¶
func WithCreatedTemplate(tpl ...string) AlertFormatterOption
func WithRecurringTemplate ¶
func WithRecurringTemplate(tpl ...string) AlertFormatterOption
func WithReopenedByTemplate ¶
func WithReopenedByTemplate(tpl ...string) AlertFormatterOption
func WithReopenedTemplate ¶
func WithReopenedTemplate(tpl ...string) AlertFormatterOption
type AlertHandler ¶
func NewAlertHandler ¶
func NewAlertHandler(app *bunapp.App) *AlertHandler
func (*AlertHandler) Close ¶
func (h *AlertHandler) Close(w http.ResponseWriter, req bunrouter.Request) error
func (*AlertHandler) Delete ¶
func (h *AlertHandler) Delete(w http.ResponseWriter, req bunrouter.Request) error
func (*AlertHandler) List ¶
func (h *AlertHandler) List(w http.ResponseWriter, req bunrouter.Request) error
func (*AlertHandler) Open ¶
func (h *AlertHandler) Open(w http.ResponseWriter, req bunrouter.Request) error
func (*AlertHandler) Show ¶
func (h *AlertHandler) Show(w http.ResponseWriter, req bunrouter.Request) error
type BaseNotifChannel ¶
type BaseNotifChannel struct { bun.BaseModel `bun:"notif_channels,alias:c"` ID uint64 `json:"id" bun:",pk,autoincrement"` ProjectID uint32 `json:"projectId"` Name string `json:"name" bun:",nullzero"` Type NotifChannelType `json:"type"` State NotifChannelState `json:"state" bun:",nullzero"` ParamsData []byte `json:"-" bun:"params,nullzero,type:jsonb"` ParamsMap map[string]any `json:"params" bun:"-"` }
func (*BaseNotifChannel) AfterScanRow ¶
func (c *BaseNotifChannel) AfterScanRow(ctx context.Context) error
func (*BaseNotifChannel) Base ¶
func (c *BaseNotifChannel) Base() *BaseNotifChannel
type EmailNotifier ¶
type EmailNotifier struct {
// contains filtered or unexported fields
}
func NewEmailNotifier ¶
func NewEmailNotifier(app *bunapp.App) *EmailNotifier
func (*EmailNotifier) NotifyHandler ¶
type ErrorAlert ¶
type ErrorAlert struct { org.BaseAlert `bun:",inherit"` Event *ErrorAlertEvent `json:"-" bun:"rel:belongs-to,join:event_id=id"` }
func NewErrorAlert ¶
func NewErrorAlert() *ErrorAlert
func (*ErrorAlert) Base ¶
func (a *ErrorAlert) Base() *org.BaseAlert
func (*ErrorAlert) GetEvent ¶ added in v1.7.0
func (a *ErrorAlert) GetEvent() org.AlertEvent
func (*ErrorAlert) SetEvent ¶ added in v1.7.0
func (a *ErrorAlert) SetEvent(event org.AlertEvent)
type ErrorAlertEvent ¶ added in v1.7.0
type ErrorAlertEvent struct { org.BaseAlertEvent `bun:",inherit"` Params org.ErrorAlertParams `json:"params" bun:"type:jsonb,nullzero"` }
func (*ErrorAlertEvent) Base ¶ added in v1.7.0
func (e *ErrorAlertEvent) Base() *org.BaseAlertEvent
func (*ErrorAlertEvent) Clone ¶ added in v1.7.0
func (e *ErrorAlertEvent) Clone() org.AlertEvent
type ErrorMonitorIn ¶
type ErrorMonitorIn struct { Name string `json:"name"` NotifyEveryoneByEmail bool `json:"notifyEveryoneByEmail"` Params org.ErrorMonitorParams `json:"params"` ChannelIDs []uint64 `json:"channelIds"` }
func (*ErrorMonitorIn) Validate ¶
func (in *ErrorMonitorIn) Validate( ctx context.Context, app *bunapp.App, monitor *org.ErrorMonitor, ) error
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager(app *bunapp.App, conf *ManagerConfig) *Manager
type ManagerConfig ¶
type ManagerConfig struct { Monitors []*org.MetricMonitor Logger *zap.Logger }
type MetricAlert ¶
type MetricAlert struct { org.BaseAlert `bun:",inherit"` Event *MetricAlertEvent `json:"-" bun:"rel:belongs-to,join:event_id=id"` }
func NewMetricAlert ¶
func NewMetricAlert() *MetricAlert
func (*MetricAlert) Base ¶
func (a *MetricAlert) Base() *org.BaseAlert
func (*MetricAlert) GetEvent ¶ added in v1.7.0
func (a *MetricAlert) GetEvent() org.AlertEvent
func (*MetricAlert) LongSummary ¶
func (a *MetricAlert) LongSummary(sep string) string
func (*MetricAlert) SetEvent ¶ added in v1.7.0
func (a *MetricAlert) SetEvent(event org.AlertEvent)
func (*MetricAlert) ShortSummary ¶
func (a *MetricAlert) ShortSummary() string
type MetricAlertEvent ¶ added in v1.7.0
type MetricAlertEvent struct { org.BaseAlertEvent `bun:",inherit"` Params MetricAlertParams `json:"params" bun:"type:jsonb,nullzero"` }
func (*MetricAlertEvent) Base ¶ added in v1.7.0
func (e *MetricAlertEvent) Base() *org.BaseAlertEvent
func (*MetricAlertEvent) Clone ¶ added in v1.7.0
func (e *MetricAlertEvent) Clone() org.AlertEvent
type MetricAlertParams ¶
type MetricAlertParams struct { Firing int `json:"firing"` InitialValue float64 `json:"initialValue"` CurrentValue float64 `json:"currentValue"` NormalValue float64 `json:"normalValue"` NumPointFiring int `json:"numPointFiring"` WhereQuery string `json:"whereQuery"` Bounds madalarm.Bounds `json:"bounds"` Monitor struct { Metrics []mql.MetricAlias `json:"metrics"` Query string `json:"query"` Column string `json:"column"` ColumnUnit string `json:"columnUnit"` GroupingInterval unixtime.Millis `json:"groupingInterval"` } `json:"monitor"` }
func (*MetricAlertParams) Update ¶
func (params *MetricAlertParams) Update( monitor *org.MetricMonitor, checkRes *madalarm.CheckResult, )
func (*MetricAlertParams) UpdateCheckResult ¶ added in v1.7.0
func (params *MetricAlertParams) UpdateCheckResult(checkRes *madalarm.CheckResult)
func (*MetricAlertParams) UpdateMonitor ¶ added in v1.7.0
func (params *MetricAlertParams) UpdateMonitor(monitor *org.MetricMonitor)
type MetricMonitorIn ¶
type MetricMonitorIn struct { Name string `json:"name"` NotifyEveryoneByEmail bool `json:"notifyEveryoneByEmail"` Params org.MetricMonitorParams `json:"params"` ChannelIDs []uint64 `json:"channelIds"` }
func (*MetricMonitorIn) Validate ¶
func (in *MetricMonitorIn) Validate( ctx context.Context, app *bunapp.App, monitor *org.MetricMonitor, ) error
type Middleware ¶
type Middleware struct { App *bunapp.App *org.Middleware }
func NewMiddleware ¶
func NewMiddleware(app *bunapp.App) Middleware
func (*Middleware) Monitor ¶
func (m *Middleware) Monitor(next bunrouter.HandlerFunc) bunrouter.HandlerFunc
func (*Middleware) NotifChannel ¶
func (m *Middleware) NotifChannel(next bunrouter.HandlerFunc) bunrouter.HandlerFunc
type MonitorFilter ¶
type MonitorFilter struct { *bunapp.App urlstruct.Pager org.OrderByMixin Q string ProjectID uint32 MonitorID uint64 State string }
func (*MonitorFilter) PGOrder ¶ added in v1.7.0
func (f *MonitorFilter) PGOrder(q *bun.SelectQuery) *bun.SelectQuery
func (*MonitorFilter) UnmarshalValues ¶
type MonitorHandler ¶
func NewMonitorHandler ¶
func NewMonitorHandler(app *bunapp.App) *MonitorHandler
func (*MonitorHandler) Activate ¶
func (h *MonitorHandler) Activate(w http.ResponseWriter, req bunrouter.Request) error
func (*MonitorHandler) CreateErrorMonitor ¶
func (h *MonitorHandler) CreateErrorMonitor(w http.ResponseWriter, req bunrouter.Request) error
func (*MonitorHandler) CreateMetricMonitor ¶
func (h *MonitorHandler) CreateMetricMonitor(w http.ResponseWriter, req bunrouter.Request) error
func (*MonitorHandler) CreateMonitorFromYAML ¶ added in v1.6.2
func (h *MonitorHandler) CreateMonitorFromYAML( w http.ResponseWriter, req bunrouter.Request, ) error
func (*MonitorHandler) Delete ¶
func (h *MonitorHandler) Delete(w http.ResponseWriter, req bunrouter.Request) error
func (*MonitorHandler) List ¶
func (h *MonitorHandler) List(w http.ResponseWriter, req bunrouter.Request) error
func (*MonitorHandler) Pause ¶
func (h *MonitorHandler) Pause(w http.ResponseWriter, req bunrouter.Request) error
func (*MonitorHandler) Show ¶
func (h *MonitorHandler) Show(w http.ResponseWriter, req bunrouter.Request) error
func (*MonitorHandler) ShowYAML ¶ added in v1.6.2
func (h *MonitorHandler) ShowYAML(w http.ResponseWriter, req bunrouter.Request) error
func (*MonitorHandler) UpdateErrorMonitor ¶
func (h *MonitorHandler) UpdateErrorMonitor(w http.ResponseWriter, req bunrouter.Request) error
func (*MonitorHandler) UpdateMetricMonitor ¶
func (h *MonitorHandler) UpdateMetricMonitor(w http.ResponseWriter, req bunrouter.Request) error
type MonitorOut ¶
type MonitorOut struct { org.BaseMonitor `bun:",extend"` AlertOpenCount int `json:"alertOpenCount" bun:",scanonly"` AlertClosedCount int `json:"alertClosedCount" bun:",scanonly"` }
type NotifChannel ¶
type NotifChannel interface {
Base() *BaseNotifChannel
}
func NotifChannelFromContext ¶
func NotifChannelFromContext(ctx context.Context) NotifChannel
func SelectNotifChannel ¶
type NotifChannelHandler ¶
func NewNotifChannelHandler ¶
func NewNotifChannelHandler(app *bunapp.App) *NotifChannelHandler
func (*NotifChannelHandler) Delete ¶
func (h *NotifChannelHandler) Delete(w http.ResponseWriter, req bunrouter.Request) error
func (*NotifChannelHandler) EmailShow ¶
func (h *NotifChannelHandler) EmailShow(w http.ResponseWriter, req bunrouter.Request) error
func (*NotifChannelHandler) EmailUpdate ¶
func (h *NotifChannelHandler) EmailUpdate(w http.ResponseWriter, req bunrouter.Request) error
func (*NotifChannelHandler) List ¶
func (h *NotifChannelHandler) List(w http.ResponseWriter, req bunrouter.Request) error
func (*NotifChannelHandler) Pause ¶
func (h *NotifChannelHandler) Pause(w http.ResponseWriter, req bunrouter.Request) error
func (*NotifChannelHandler) SlackCreate ¶
func (h *NotifChannelHandler) SlackCreate(w http.ResponseWriter, req bunrouter.Request) error
func (*NotifChannelHandler) SlackShow ¶
func (h *NotifChannelHandler) SlackShow(w http.ResponseWriter, req bunrouter.Request) error
func (*NotifChannelHandler) SlackUpdate ¶
func (h *NotifChannelHandler) SlackUpdate(w http.ResponseWriter, req bunrouter.Request) error
func (*NotifChannelHandler) TelegramCreate ¶
func (h *NotifChannelHandler) TelegramCreate(w http.ResponseWriter, req bunrouter.Request) error
func (*NotifChannelHandler) TelegramShow ¶
func (h *NotifChannelHandler) TelegramShow(w http.ResponseWriter, req bunrouter.Request) error
func (*NotifChannelHandler) TelegramUpdate ¶
func (h *NotifChannelHandler) TelegramUpdate(w http.ResponseWriter, req bunrouter.Request) error
func (*NotifChannelHandler) Unpause ¶
func (h *NotifChannelHandler) Unpause(w http.ResponseWriter, req bunrouter.Request) error
func (*NotifChannelHandler) UpdateNotifChannelState ¶
func (h *NotifChannelHandler) UpdateNotifChannelState( w http.ResponseWriter, req bunrouter.Request, state NotifChannelState, ) error
func (*NotifChannelHandler) WebhookCreate ¶
func (h *NotifChannelHandler) WebhookCreate(w http.ResponseWriter, req bunrouter.Request) error
func (*NotifChannelHandler) WebhookShow ¶
func (h *NotifChannelHandler) WebhookShow(w http.ResponseWriter, req bunrouter.Request) error
func (*NotifChannelHandler) WebhookUpdate ¶
func (h *NotifChannelHandler) WebhookUpdate(w http.ResponseWriter, req bunrouter.Request) error
type NotifChannelState ¶
type NotifChannelState string
const ( NotifChannelDraft NotifChannelState = "draft" NotifChannelDelivering NotifChannelState = "delivering" NotifChannelPaused NotifChannelState = "paused" NotifChannelDisabled NotifChannelState = "disabled" )
type NotifChannelType ¶
type NotifChannelType string
const ( NotifChannelSlack NotifChannelType = "slack" NotifChannelWebhook NotifChannelType = "webhook" NotifChannelAlertmanager NotifChannelType = "alertmanager" NotifChannelTelegram NotifChannelType = "telegram" )
type SlackNotifChannel ¶
type SlackNotifChannel struct { *BaseNotifChannel `bun:",inherit"` Params SlackParams `json:"params"` }
func SelectSlackNotifChannel ¶
func SlackNotifChannelFromContext ¶
func SlackNotifChannelFromContext(ctx context.Context) (*SlackNotifChannel, error)
func (*SlackNotifChannel) Base ¶
func (c *SlackNotifChannel) Base() *BaseNotifChannel
type SlackNotifChannelIn ¶
type SlackNotifChannelIn struct { Name string `json:"name"` Params SlackParams `json:"params"` }
func (*SlackNotifChannelIn) Validate ¶
func (in *SlackNotifChannelIn) Validate(channel *SlackNotifChannel) error
type SlackParams ¶
type SlackParams struct {
WebhookURL string `json:"webhookUrl"`
}
type StateCount ¶
func SelectMonitorStatesCount ¶
func SelectMonitorStatesCount(ctx context.Context, f *MonitorFilter) ([]StateCount, error)
type TelegramNotifChannel ¶
type TelegramNotifChannel struct { *BaseNotifChannel `bun:",inherit"` Params TelegramParams `json:"params"` }
func TelegramNotifChannelFromContext ¶
func TelegramNotifChannelFromContext(ctx context.Context) (*TelegramNotifChannel, error)
func (*TelegramNotifChannel) Base ¶
func (c *TelegramNotifChannel) Base() *BaseNotifChannel
func (*TelegramNotifChannel) TelegramBot ¶
type TelegramNotifChannelIn ¶
type TelegramNotifChannelIn struct { Name string `json:"name"` Params struct { ChatID int64 `json:"chatId"` } `json:"params"` }
func (*TelegramNotifChannelIn) Validate ¶
func (in *TelegramNotifChannelIn) Validate(channel *TelegramNotifChannel) error
type TelegramParams ¶
type TelegramParams struct {
ChatID int64 `json:"chatId"`
}
type WebhookMessage ¶
type WebhookMessage struct { ID uint64 `json:"id,string"` EventName org.AlertEventName `json:"eventName"` Payload any `json:"payload"` CreatedAt time.Time `json:"createdAt"` Alert struct { ID uint64 `json:"id,string"` URL string `json:"url"` Name string `json:"name"` Type org.AlertType `json:"type"` Status org.AlertStatus `json:"status"` CreatedAt time.Time `json:"createdAt"` } `json:"alert"` }
func NewWebhookMessage ¶
type WebhookNotifChannel ¶
type WebhookNotifChannel struct { *BaseNotifChannel `bun:",inherit"` Params WebhookParams `json:"params"` }
func WebhookNotifChannelFromContext ¶
func WebhookNotifChannelFromContext(ctx context.Context) (*WebhookNotifChannel, error)
func (*WebhookNotifChannel) Base ¶
func (c *WebhookNotifChannel) Base() *BaseNotifChannel
type WebhookNotifChannelIn ¶
type WebhookNotifChannelIn struct { Type NotifChannelType `json:"type"` Name string `json:"name"` Params struct { WebhookParams Payload string `json:"payload"` } `json:"params"` }
func (*WebhookNotifChannelIn) Validate ¶
func (in *WebhookNotifChannelIn) Validate(channel *WebhookNotifChannel) error
type WebhookParams ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.