alertlog

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreatedMetaData added in v0.25.0

type CreatedMetaData struct {
	EPNoSteps bool
}

type DB

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

func NewDB

func NewDB(ctx context.Context, db *sql.DB) (*DB, error)

func (*DB) FindAll

func (db *DB) FindAll(ctx context.Context, alertID int) ([]Entry, error)

func (*DB) FindLatestByType

func (db *DB) FindLatestByType(ctx context.Context, alertID int, status Type) (*Entry, error)

FindLatestByType returns the latest Log Entry given alertID and status type

func (*DB) FindOne

func (db *DB) FindOne(ctx context.Context, logID int) (*Entry, error)

func (*DB) LegacySearch added in v0.23.0

func (db *DB) LegacySearch(ctx context.Context, opts *LegacySearchOptions) ([]Entry, int, error)

LegacySearch will return a list of matching log entries.

func (*DB) Log

func (db *DB) Log(ctx context.Context, alertID int, _type Type, meta interface{}) error

func (*DB) LogEPTx

func (db *DB) LogEPTx(ctx context.Context, tx *sql.Tx, epID string, _type Type, meta *EscalationMetaData) error

func (*DB) LogManyTx

func (db *DB) LogManyTx(ctx context.Context, tx *sql.Tx, alertIDs []int, _type Type, meta interface{}) error

func (*DB) LogServiceTx

func (db *DB) LogServiceTx(ctx context.Context, tx *sql.Tx, serviceID string, _type Type, meta interface{}) error

func (*DB) LogTx

func (db *DB) LogTx(ctx context.Context, tx *sql.Tx, alertID int, _type Type, meta interface{}) error

func (*DB) MustLog

func (db *DB) MustLog(ctx context.Context, alertID int, _type Type, meta interface{})

func (*DB) MustLogTx

func (db *DB) MustLogTx(ctx context.Context, tx *sql.Tx, alertID int, _type Type, meta interface{})

func (*DB) Search

func (db *DB) Search(ctx context.Context, opts *SearchOptions) ([]Entry, error)

Search will return a list of matching log entries

type Entry

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

func (Entry) AlertID

func (e Entry) AlertID() int

func (Entry) ID

func (e Entry) ID() int

func (Entry) Meta

func (e Entry) Meta() interface{}

func (Entry) String

func (e Entry) String() string

func (Entry) Subject

func (e Entry) Subject() *Subject

func (Entry) Timestamp

func (e Entry) Timestamp() time.Time

func (Entry) Type

func (e Entry) Type() Type

type EscalationMetaData

type EscalationMetaData struct {
	NewStepIndex    int
	Repeat          bool
	Forced          bool
	Deleted         bool
	OldDelayMinutes int
	NoOneOnCall     bool
}

type LegacySearchOptions added in v0.23.0

type LegacySearchOptions struct {
	// AlertID, if specified, will restrict alert logs to those with a matching AlertID.
	AlertID int

	// ServiceID, if specified, will restrict alert logs to those alerts which map to this particular ServiceID.
	ServiceID string

	// UserID, if specified, will restrict alert logs to those with events performed by the specified user.
	UserID string

	// IntegrationKeyID, if specified, will restrict alert logs to those with events authorized via the specified integration key.
	IntegrationKeyID string

	// Start will restrict alert logs to those which were created on or after this time.
	Start time.Time

	// End will restrict alert logs to those which were created before this time.
	End time.Time

	// Event, if specified, will restrict alert logs to those of the specified event type.
	Event Type

	// SortBy can be used to alter the primary sorting criteria. By default, results are ordered by timestamp as newest first.
	// Results will always have a secondary sort criteria of newest-events-first, unless SortByTimestamp is set and SortDesc is false.
	SortBy SortBy

	// SortDesc controls ascending or descending results of the primary sort (SortBy field).
	SortDesc bool

	// Offset indicates the starting row of the returned results.
	Offset int

	// Limit restricts the maximum number of rows returned. Default is 25. Maximum is 50.
	// Note: Limit is applied AFTER Offset is taken into account.
	Limit int
}

LegacySearchOptions contains criteria for filtering alert logs. At a minimum, at least one of AlertID or ServiceID must be specified.

type NotificationMetaData

type NotificationMetaData struct {
	MessageID string
}

type SearchCursor added in v0.23.0

type SearchCursor struct {
	ID int `json:"i,omitempty"`
}

type SearchOptions

type SearchOptions struct {
	// FilterAlertIDs restricts the log entries belonging to specific alertIDs only.
	FilterAlertIDs []int `json:"f"`

	// Limit restricts the maximum number of rows returned. Default is 15.
	Limit int `json:"-"`

	After SearchCursor `json:"a,omitempty"`
}

SearchOptions contains criteria for filtering alert logs.

type SortBy

type SortBy int

SortBy describes the possible primary sort options for alert logs.

const (
	SortByTimestamp SortBy = iota
	SortByAlertID
	SortByEventType
	SortByUserName
)

Configurable sort columns.

type Store

type Store interface {
	FindOne(ctx context.Context, logID int) (*Entry, error)
	FindAll(ctx context.Context, alertID int) ([]Entry, error)
	Log(ctx context.Context, alertID int, _type Type, meta interface{}) error
	LogTx(ctx context.Context, tx *sql.Tx, alertID int, _type Type, meta interface{}) error
	LogEPTx(ctx context.Context, tx *sql.Tx, epID string, _type Type, meta *EscalationMetaData) error
	LogServiceTx(ctx context.Context, tx *sql.Tx, serviceID string, _type Type, meta interface{}) error
	LogManyTx(ctx context.Context, tx *sql.Tx, alertIDs []int, _type Type, meta interface{}) error
	FindLatestByType(ctx context.Context, alertID int, status Type) (*Entry, error)
	LegacySearch(ctx context.Context, opt *LegacySearchOptions) ([]Entry, int, error)
	Search(ctx context.Context, opt *SearchOptions) ([]Entry, error)

	MustLog(ctx context.Context, alertID int, _type Type, meta interface{})
	MustLogTx(ctx context.Context, tx *sql.Tx, alertID int, _type Type, meta interface{})
}

type Subject

type Subject struct {
	ID         string      `json:"id"`
	Name       string      `json:"name"`
	Type       SubjectType `json:"type"`
	Classifier string      `json:"classifier"`
}

A Subject is generally the causer of an event. If a user closes an alert, the entry would have a Subject set to the user.

type SubjectType

type SubjectType string

SubjectType represents the type of subject or causer of an alert event.

const (
	SubjectTypeUser             SubjectType = "user"
	SubjectTypeIntegrationKey   SubjectType = "integration_key"
	SubjectTypeHeartbeatMonitor SubjectType = "heartbeat_monitor"
	SubjectTypeChannel          SubjectType = "channel"
	SubjectTypeNone             SubjectType = ""
)

Possible subject types

func (*SubjectType) Scan

func (s *SubjectType) Scan(value interface{}) error

Scan handles reading a Type from the DB enum

func (SubjectType) Value

func (s SubjectType) Value() (driver.Value, error)

type Type

type Type string

A Type represents a log entry type for an alert.

const (
	TypeCreated            Type = "created"
	TypeClosed             Type = "closed"
	TypeNotificationSent   Type = "notification_sent"
	TypeNoNotificationSent Type = "no_notification_sent"
	TypeEscalated          Type = "escalated"
	TypeAcknowledged       Type = "acknowledged"
	TypePolicyUpdated      Type = "policy_updated"
	TypeDuplicateSupressed Type = "duplicate_suppressed"
	TypeEscalationRequest  Type = "escalation_request"
)

Types of Log Entries

func (*Type) Scan

func (ty *Type) Scan(value interface{}) error

Scan handles reading a Type from the DB enum

Jump to

Keyboard shortcuts

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