Documentation ¶
Index ¶
- Constants
- func AlertID(err error) int
- func IsAlreadyAcknowledged(err error) bool
- func IsAlreadyClosed(err error) bool
- type Alert
- type DB
- func (db *DB) Create(ctx context.Context, a *Alert) (*Alert, error)
- func (db *DB) CreateOrUpdate(ctx context.Context, a *Alert) (*Alert, error)
- func (db *DB) CreateOrUpdateTx(ctx context.Context, tx *sql.Tx, a *Alert) (*Alert, bool, error)
- func (db *DB) EPID(ctx context.Context, alertID int) (string, error)
- func (db *DB) Escalate(ctx context.Context, alertID int, currentLevel int) error
- func (db *DB) EscalateMany(ctx context.Context, alertIDs []int) ([]int, error)
- func (db *DB) FindAllSummary(ctx context.Context) ([]Summary, error)
- func (db *DB) FindMany(ctx context.Context, alertIDs []int) ([]Alert, error)
- func (db *DB) FindOne(ctx context.Context, id int) (*Alert, error)
- func (db *DB) GetCreationTime(ctx context.Context, id int) (t time.Time, err error)
- func (db *DB) LegacySearch(ctx context.Context, opts *LegacySearchOptions) ([]Alert, int, error)
- func (db *DB) Search(ctx context.Context, opts *SearchOptions) ([]Alert, error)
- func (db *DB) ServiceInfo(ctx context.Context, serviceID string) (string, int, error)
- func (db *DB) State(ctx context.Context, alertIDs []int) ([]State, error)
- func (db *DB) UpdateManyAlertStatus(ctx context.Context, status Status, alertIDs []int) ([]int, error)
- func (db *DB) UpdateStatus(ctx context.Context, id int, s Status) error
- func (db *DB) UpdateStatusByService(ctx context.Context, serviceID string, status Status) error
- func (db *DB) UpdateStatusTx(ctx context.Context, tx *sql.Tx, id int, s Status) error
- type DedupID
- type DedupType
- type LegacySearchOptions
- type Log
- type LogEntryFetcher
- type LogEvent
- type Manager
- type SearchCursor
- type SearchOptions
- type SortBy
- type Source
- type State
- type Status
- type Store
- type Summary
- type Trigger
Constants ¶
const ( MaxSummaryLength = 118 MaxDetailsLength = 6 * 1024 // 6KiB )
maximum lengths
const ( DedupTypeUser = DedupType("user") DedupTypeAuto = DedupType("auto") DedupTypeHeartbeat = DedupType("heartbeat") )
DedupType can be auto or user-generated.
Variables ¶
This section is empty.
Functions ¶
func IsAlreadyAcknowledged ¶
func IsAlreadyClosed ¶
Types ¶
type Alert ¶
type Alert struct { ID int `json:"_id"` Status Status `json:"status"` Summary string `json:"summary"` Details string `json:"details"` Source Source `json:"source"` ServiceID string `json:"service_id"` CreatedAt time.Time `json:"created_at"` Dedup *DedupID `json:"dedup"` }
An Alert represents an ongoing situation.
func (*Alert) DedupKey ¶
DedupKey will return the de-duplication key for the alert. The Dedup prop is used if non-nil, otherwise one is generated using the Description of the Alert.
func (Alert) Description ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) CreateOrUpdate ¶
func (*DB) CreateOrUpdateTx ¶
func (*DB) EscalateMany ¶
func (*DB) GetCreationTime ¶
func (*DB) LegacySearch ¶
LegacySearch will return a list of matching alerts, up to Limit, and the total number of matches available.
func (*DB) ServiceInfo ¶ added in v0.24.0
func (*DB) UpdateManyAlertStatus ¶
func (*DB) UpdateStatusByService ¶
type DedupID ¶
DedupID represents a de-duplication ID for alerts.
func NewUserDedup ¶
NewUserDedup will create a new DedupID from a user-provided string.
func ParseDedupString ¶
ParseDedupString will parse a string into a DedupID struct.
type LegacySearchOptions ¶
type LegacySearchOptions struct { // Search is matched case-insensitive against the alert summary, id and service name. Search string // ServiceID, if specified, will restrict alerts to those with a matching ServiceID. ServiceID string OmitTriggered bool OmitActive bool OmitClosed bool // Limit restricts the maximum number of rows returned. Default is 50. // Note: Limit is applied AFTER offset is taken into account. Limit int // Offset indicates the starting row of the returned results. Offset int // SortBy specifies the column to sort by. If anything other than ID, // ID is used as a secondary sort in descending (newest first) order. SortBy SortBy // SortDesc controls ascending or descending results of the primary sort (SortBy field). SortDesc bool //FavoriteServicesOnlyUserID, if populated, filters all those alerts which belong to this user's favorite services, if empty, it is ignored. FavoriteServicesOnlyUserID string }
LegacySearchOptions contains criteria for filtering and sorting alerts.
type Log ¶
type Log struct { Timestamp time.Time `json:"timestamp"` Event LogEvent `json:"event"` Message string `json:"message"` }
A Log is a recording of an Alert event.
type LogEntryFetcher ¶
type LogEvent ¶
type LogEvent string
A LogEvent represents a state change of an alert.
type Manager ¶
type Manager interface { FindOne(context.Context, int) (*Alert, error) FindMany(context.Context, []int) ([]Alert, error) UpdateStatus(context.Context, int, Status) error UpdateStatusByService(ctx context.Context, serviceID string, status Status) error UpdateManyAlertStatus(ctx context.Context, status Status, alertIDs []int) (updatedAlertIDs []int, err error) UpdateStatusTx(context.Context, *sql.Tx, int, Status) error EPID(ctx context.Context, alertID int) (string, error) // ServiceInfo will return the name of the given service ID as well as the current number // of unacknowledged alerts. ServiceInfo(ctx context.Context, serviceID string) (string, int, error) }
type SearchCursor ¶
type SearchOptions ¶
type SearchOptions struct { // Search is matched case-insensitive against the alert summary, id and service name. Search string `json:"s,omitempty"` // Status, if specified, will restrict alerts to those with a matching status. Status []Status `json:"t,omitempty"` // Services, if specified, will restrict alerts to those with a matching ServiceID. Services []string `json:"v,omitempty"` After SearchCursor `json:"a,omitempty"` // Omit specifies a list of alert IDs to exclude from the results. Omit []int // Limit restricts the maximum number of rows returned. Default is 50. // Note: Limit is applied AFTER AfterID is taken into account. Limit int `json:"-"` }
SearchOptions contains criteria for filtering and sorting alerts.
type Source ¶
type Source string
Source is the entity that triggered an alert.
type Status ¶
type Status string
Status is the current state of an Alert.
type Store ¶
type Store interface { Manager Create(context.Context, *Alert) (*Alert, error) // CreateOrUpdate will create an alert or log a "duplicate suppressed message" if // Status is Triggered. If Status is Closed, it will close and return the result. // // In the case that Status is closed but a matching alert is not present, nil is returned. // Otherwise the current alert is returned. CreateOrUpdate(context.Context, *Alert) (*Alert, error) // CreateOrUpdateTx returns `isNew` to indicate if the returned alert was a new one. // It is the caller's responsibility to log alert creation if the transaction is committed (and isNew is true). CreateOrUpdateTx(context.Context, *sql.Tx, *Alert) (a *Alert, isNew bool, err error) FindAllSummary(ctx context.Context) ([]Summary, error) Escalate(ctx context.Context, alertID int, currentLevel int) error EscalateMany(ctx context.Context, alertIDs []int) ([]int, error) GetCreationTime(ctx context.Context, alertID int) (time.Time, error) LegacySearch(ctx context.Context, opt *LegacySearchOptions) ([]Alert, int, error) Search(ctx context.Context, opts *SearchOptions) ([]Alert, error) State(ctx context.Context, alertIDs []int) ([]State, error) }