Documentation ¶
Overview ¶
Alert provides a framework for tracking events in a publish subscribe system. Events are published to topics and handlers consume the events from the topics.
Index ¶
- func PatternMatch(pattern, id string) bool
- type Data
- type Event
- type EventData
- type EventState
- type Handler
- type Level
- type TemplateData
- type Topic
- type TopicState
- type Topics
- func (s *Topics) Close() error
- func (s *Topics) Collect(event Event) error
- func (s *Topics) DeleteTopic(topic string)
- func (s *Topics) DeregisterHandler(topic string, h Handler)
- func (s *Topics) EventState(topic, event string) (EventState, bool)
- func (s *Topics) Open() error
- func (s *Topics) RegisterHandler(topic string, h Handler)
- func (s *Topics) ReplaceHandler(topic string, oldH, newH Handler)
- func (s *Topics) RestoreTopic(id string, eventStates map[string]EventState)
- func (s *Topics) Topic(id string) (*Topic, bool)
- func (s *Topics) TopicState(pattern string, minLevel Level) map[string]TopicState
- func (s *Topics) UpdateEvent(id string, event EventState)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PatternMatch ¶ added in v1.3.0
Types ¶
type Data ¶ added in v1.3.0
type Data struct { ID string `json:"id"` Message string `json:"message"` Details string `json:"details"` Time time.Time `json:"time"` Duration time.Duration `json:"duration"` Level Level `json:"level"` Data models.Result `json:"data"` }
Data is a structure that contains relevant data about an alert event. The structure is intended to be JSON encoded, providing a consistent data format.
type Event ¶
type Event struct { Topic string State EventState Data EventData NoExternal bool // contains filtered or unexported fields }
func (Event) PreviousState ¶
func (e Event) PreviousState() EventState
func (Event) TemplateData ¶
func (e Event) TemplateData() TemplateData
type EventData ¶
type EventData struct { // Measurement name Name string // TaskName is the name of the task that generated this event. TaskName string // Concatenation of all group-by tags of the form [key=value,]+. // If not groupBy is performed equal to literal 'nil' Group string // Map of tags Tags map[string]string // Fields of alerting data point. Fields map[string]interface{} Result models.Result }
type EventState ¶
type Handler ¶
type Handler interface { // Handle is responsible for taking action on the event. Handle(event Event) }
type Level ¶
type Level int
func ParseLevel ¶
func (Level) MarshalText ¶
func (*Level) UnmarshalText ¶
type TemplateData ¶
type TemplateData struct { // The ID of the alert. ID string // The Message of the Alert Message string // Alert Level, one of: INFO, WARNING, CRITICAL. Level string // Time the event occurred. Time time.Time // Duration of the event Duration time.Duration // Measurement name Name string // Task name TaskName string // Concatenation of all group-by tags of the form [key=value,]+. // If not groupBy is performed equal to literal 'nil' Group string // Map of tags Tags map[string]string // Fields of alerting data point. Fields map[string]interface{} }
TemplateData is a structure containing all information available to use in templates for an Event.
type Topic ¶
type Topic struct {
// contains filtered or unexported fields
}
func (*Topic) EventState ¶
func (t *Topic) EventState(event string) (EventState, bool)
func (*Topic) EventStates ¶
func (t *Topic) EventStates(minLevel Level) map[string]EventState
func (*Topic) State ¶ added in v1.3.0
func (t *Topic) State() TopicState
type TopicState ¶ added in v1.3.0
type Topics ¶
type Topics struct {
// contains filtered or unexported fields
}
func (*Topics) DeleteTopic ¶
func (*Topics) DeregisterHandler ¶
func (*Topics) EventState ¶
func (s *Topics) EventState(topic, event string) (EventState, bool)
func (*Topics) RegisterHandler ¶
func (*Topics) ReplaceHandler ¶
func (*Topics) RestoreTopic ¶
func (s *Topics) RestoreTopic(id string, eventStates map[string]EventState)
func (*Topics) TopicState ¶ added in v1.3.0
func (s *Topics) TopicState(pattern string, minLevel Level) map[string]TopicState
TopicState returns the max alert level for each topic matching 'pattern', not returning any topics with max alert levels less severe than 'minLevel'
func (*Topics) UpdateEvent ¶
func (s *Topics) UpdateEvent(id string, event EventState)
Click to show internal directories.
Click to hide internal directories.