Documentation ¶
Index ¶
- Constants
- type Action
- type ActionType
- type Error
- type Event
- type Filter
- func NewAlertTypeFilter(alertType int64, resourceType api.ResourceType, options ...Option) Filter
- func NewCountSpanFilter(minCount, maxCount int64) Filter
- func NewCustomFilter(f func(alert *api.Alert) (bool, error)) Filter
- func NewFlagCheckFilter(flag bool) Filter
- func NewMatchAlertTypeFilter(alertType int64) Filter
- func NewMatchResourceIDFilter(resourceID string) Filter
- func NewMinSeverityFilter(minSev api.SeverityType) Filter
- func NewResourceIDFilter(resourceID string, alertType int64, resourceType api.ResourceType, ...) Filter
- func NewResourceTypeFilter(resourceType api.ResourceType, options ...Option) Filter
- func NewTimeSpanFilter(start, stop time.Time) Filter
- type FilterDeleter
- type FilterType
- type Filters
- type Manager
- type Option
- type OptionType
- type Rule
Constants ¶
const ( HalfDay = Day / 2 Day = 60 * 60 * 24 FiveDays = Day * 5 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
Action is something that runs for an alerts manager.
func NewClearAction ¶
NewClearAction marks alert entries as cleared that get deleted after half a day of life in kvdb.
func NewCustomAction ¶
NewCustomAction takes custom action using user defined function.
func NewDeleteAction ¶
NewDeleteAction deletes alert entries based on filters.
type ActionType ¶
type ActionType int
ActionType defines categories of actions.
const (
// Custom user action.
CustomAction ActionType
)
ActionType constants
type Filter ¶
type Filter interface { GetFilterType() FilterType GetValue() interface{} Match(alert *api.Alert) (bool, error) }
Filter is something that matches an alert.
func NewAlertTypeFilter ¶
func NewAlertTypeFilter(alertType int64, resourceType api.ResourceType, options ...Option) Filter
NewAlertTypeFilter creates a filter that matches on <resourceType>/<alertType>
func NewCountSpanFilter ¶
NewCountSpanFilter provides a filter that matches on alert count.
func NewCustomFilter ¶
NewCustomFilter creates a filter that matches on UDF (user defined function)
func NewFlagCheckFilter ¶
NewFlagCheckFilter provides a filter that matches on alert clear flag.
func NewMatchAlertTypeFilter ¶
NewMatchAlertTypeFilter provides a filter that matches on alert type. Please use NewAlertTypeFilter if other inputs are known.
func NewMatchResourceIDFilter ¶
NewMatchResourceIDFilter provides a filter that matches on resource id. Please use NewResourceIDFilter if other inputs are known.
func NewMinSeverityFilter ¶
func NewMinSeverityFilter(minSev api.SeverityType) Filter
NewMinSeverityFilter provides a filter that matches on alert when severity is greater than or equal to the minSev value.
func NewResourceIDFilter ¶
func NewResourceIDFilter(resourceID string, alertType int64, resourceType api.ResourceType, options ...Option) Filter
NewResourceIDFilter creates a filter that matches on <resourceType>/<alertType>/<resourceID>
func NewResourceTypeFilter ¶
func NewResourceTypeFilter(resourceType api.ResourceType, options ...Option) Filter
NewResourceTypeFilter creates a filter that matches on <resourceType>
func NewTimeSpanFilter ¶
NewTimeSpanFilter creates a filter that matches on alert raised in a given time window.
type FilterDeleter ¶
type FilterDeleter interface { // Enumerate lists all alerts filtered by a variadic list of filters. // It will fetch a superset such that every alert is matched by at least one filter. Enumerate(filters ...Filter) ([]*api.Alert, error) // Filter filters given list of alerts successively through each filter. Filter(alerts []*api.Alert, filters ...Filter) ([]*api.Alert, error) // Delete deletes alerts filtered by a chain of filters. Delete(filters ...Filter) error }
FilterDeleter defines a list and delete interface on alerts. This interface is used in SDK.
func NewFilterDeleter ¶
func NewFilterDeleter(options ...Option) (FilterDeleter, error)
NewFilterDeleter obtains instance of FilterDeleter for alerts enumeration and deletion.
type FilterType ¶
type FilterType int
FilterType contains a filter type.
const ( // CustomFilter is based on a user defined function (UDF). All alert entries are fetched from kvdb // and then passed through UDF. Entries that match are returned. Therefore, this filter does not query // kvdb efficiently. CustomFilter FilterType = iota )
FilterType constants. Please note that the ordering of these filter type constants is very important since filters are sorted based on this ordering and such sorting is done to properly query kvdb tree structure.
kvdb tree struct is defined as alerts/<resourceType>/<alertType>/<resourceID>/data
Input filters are sorted based
type Manager ¶
type Manager interface { // FilterDeleter allows read only operation on alerts FilterDeleter // Raise raises an alert. Raise(alert *api.Alert) error // SetRules sets a set of rules to be performed on alert events. SetRules(rules ...Rule) // DeleteRules deletes rules DeleteRules(rules ...Rule) }
Manager manages alerts.
func NewManager ¶
NewManager obtains instance of Manager for alerts management.
type Option ¶
type Option interface { GetType() OptionType GetValue() interface{} }
Option defines what is an option.
func NewCountSpanOption ¶
NewCountSpanOption provides an option to be used in filter definition that accept options. Only filters that are efficient in querying kvdb accept options and apply these options during matching alerts.
func NewFlagCheckOption ¶
NewFlagCheckOptions provides an option to be used during filter creation that accept such options. Only filters that are efficient in querying kvdb accept options and apply these options during matching alerts.
func NewMinSeverityOption ¶
func NewMinSeverityOption(minSev api.SeverityType) Option
NewMinSeverityOption provides an option to be used during filter creation that accept such options. Only filters that are efficient in querying kvdb accept options and apply these options during matching alerts.
func NewResourceIdOption ¶
NewResourceIdOption provides an option to be used during filter creation that accept such options. Only filters that are efficient in querying kvdb accept options and apply these options during matching alerts.
func NewTTLOption ¶
NewTTLOption provides an option to be used in manager creation.
func NewTimeSpanOption ¶
NewTimeSpanOption provides an option to be used in filter definition. Filters that take options, apply options only during matching alerts.
type Rule ¶
Rule defines a rule on an Event, for a filter, executing a func.
func NewDeleteRule ¶
NewDeleteRule creates a rule that runs action when deleted alerts matche filter. Action happens after matching alerts are deleted.