Documentation ¶
Index ¶
- Constants
- func ChunkSlice(original []string, chunkSize int) (divided [][]string)
- func GetStringListsDiff(stringLists ...[]string) []string
- func Int64ToTime(timeStamp int64) time.Time
- func Subset(first, second []string) bool
- func UseFloat64(f *float64) float64
- func UseString(str *string) string
- type CheckData
- type ContactData
- type Database
- type Logger
- type MatchedMetric
- type MetricEvent
- type MetricState
- type MetricValue
- type NotificationEvent
- type NotificationEvents
- type PlotTheme
- type PlottingData
- type ScheduleData
- type ScheduleDataDay
- type ScheduledNotification
- type Searcher
- type Sender
- type SubscriptionData
- type Trigger
- type TriggerCheck
- type TriggerData
Constants ¶
const ( // FallingTrigger represents falling trigger type, in which OK > WARN > ERROR FallingTrigger = "falling" // RisingTrigger represents rising trigger type, in which OK < WARN < ERROR RisingTrigger = "rising" // ExpressionTrigger represents trigger type with custom user expression ExpressionTrigger = "expression" )
Variables ¶
This section is empty.
Functions ¶
func ChunkSlice ¶
ChunkSlice gets slice of strings and chunks it to a given size. It returns a batch of chunked lists
func GetStringListsDiff ¶
GetStringListsDiff returns the members of the set resulting from the difference between the first set and all the successive lists.
func Int64ToTime ¶
Int64ToTime returns time.Time from int64
func UseFloat64 ¶
UseFloat64 gets pointer value of float64 or default float64 if pointer is nil
Types ¶
type CheckData ¶
type CheckData struct { Metrics map[string]MetricState `json:"metrics"` Score int64 `json:"score"` State string `json:"state"` Maintenance int64 `json:"maintenance,omitempty"` Timestamp int64 `json:"timestamp,omitempty"` EventTimestamp int64 `json:"event_timestamp,omitempty"` LastSuccessfulCheckTimestamp int64 `json:"last_successful_check_timestamp"` Suppressed bool `json:"suppressed,omitempty"` SuppressedState string `json:"suppressed_state,omitempty"` Message string `json:"msg,omitempty"` }
CheckData represents last trigger check data
func (CheckData) GetEventTimestamp ¶
GetEventTimestamp gets event timestamp for given check
func (*CheckData) GetOrCreateMetricState ¶
func (checkData *CheckData) GetOrCreateMetricState(metric string, emptyTimestampValue int64, muteNewMetric bool) MetricState
GetOrCreateMetricState gets metric state from check data or create new if CheckData has no state for given metric
func (*CheckData) UpdateScore ¶
UpdateScore update and return checkData score, based on metric states and checkData state
type ContactData ¶
type ContactData struct { Type string `json:"type"` Value string `json:"value"` ID string `json:"id"` User string `json:"user"` }
ContactData represents contact object
type Database ¶
type Database interface { // SelfState UpdateMetricsHeartbeat() error GetMetricsUpdatesCount() (int64, error) GetChecksUpdatesCount() (int64, error) GetRemoteChecksUpdatesCount() (int64, error) GetNotifierState() (string, error) SetNotifierState(string) error // Tag storing GetTagNames() ([]string, error) RemoveTag(tagName string) error GetTagTriggerIDs(tagName string) ([]string, error) // LastCheck storing GetTriggerLastCheck(triggerID string) (CheckData, error) SetTriggerLastCheck(triggerID string, checkData *CheckData, isRemote bool) error RemoveTriggerLastCheck(triggerID string) error GetTriggerCheckIDs(tags []string, onlyErrors bool) ([]string, error) SetTriggerCheckMaintenance(triggerID string, metrics map[string]int64, triggerMaintenance *int64) error // Trigger storing GetLocalTriggerIDs() ([]string, error) GetAllTriggerIDs() ([]string, error) GetRemoteTriggerIDs() ([]string, error) GetTrigger(triggerID string) (Trigger, error) GetTriggers(triggerIDs []string) ([]*Trigger, error) GetTriggerChecks(triggerIDs []string) ([]*TriggerCheck, error) SaveTrigger(triggerID string, trigger *Trigger) error RemoveTrigger(triggerID string) error GetPatternTriggerIDs(pattern string) ([]string, error) RemovePatternTriggerIDs(pattern string) error // Throttling GetTriggerThrottling(triggerID string) (time.Time, time.Time) SetTriggerThrottling(triggerID string, next time.Time) error DeleteTriggerThrottling(triggerID string) error // NotificationEvent storing GetNotificationEvents(triggerID string, start, size int64) ([]*NotificationEvent, error) PushNotificationEvent(event *NotificationEvent, ui bool) error GetNotificationEventCount(triggerID string, from int64) int64 FetchNotificationEvent() (NotificationEvent, error) RemoveAllNotificationEvents() error // ContactData storing GetContact(contactID string) (ContactData, error) GetContacts(contactIDs []string) ([]*ContactData, error) GetAllContacts() ([]*ContactData, error) RemoveContact(contactID string) error SaveContact(contact *ContactData) error GetUserContactIDs(userLogin string) ([]string, error) // SubscriptionData storing GetSubscription(id string) (SubscriptionData, error) GetSubscriptions(subscriptionIDs []string) ([]*SubscriptionData, error) SaveSubscription(subscription *SubscriptionData) error SaveSubscriptions(subscriptions []*SubscriptionData) error RemoveSubscription(subscriptionID string) error GetUserSubscriptionIDs(userLogin string) ([]string, error) GetTagsSubscriptions(tags []string) ([]*SubscriptionData, error) // ScheduledNotification storing GetNotifications(start, end int64) ([]*ScheduledNotification, int64, error) RemoveNotification(notificationKey string) (int64, error) RemoveAllNotifications() error FetchNotifications(to int64) ([]*ScheduledNotification, error) AddNotification(notification *ScheduledNotification) error AddNotifications(notification []*ScheduledNotification, timestamp int64) error // Patterns and metrics storing GetPatterns() ([]string, error) AddPatternMetric(pattern, metric string) error GetPatternMetrics(pattern string) ([]string, error) RemovePattern(pattern string) error RemovePatternsMetrics(pattern []string) error RemovePatternWithMetrics(pattern string) error SubscribeMetricEvents(tomb *tomb.Tomb) (<-chan *MetricEvent, error) SaveMetrics(buffer map[string]*MatchedMetric) error GetMetricRetention(metric string) (int64, error) GetMetricsValues(metrics []string, from int64, until int64) (map[string][]*MetricValue, error) RemoveMetricValues(metric string, toTime int64) error RemoveMetricsValues(metrics []string, toTime int64) error AddTriggersToCheck(triggerIDs []string) error GetTriggerToCheck() (string, error) GetTriggersToCheckCount() (int64, error) AddRemoteTriggersToCheck(triggerIDs []string) error GetRemoteTriggerToCheck() (string, error) GetRemoteTriggersToCheckCount() (int64, error) // TriggerCheckLock storing AcquireTriggerCheckLock(triggerID string, timeout int) error DeleteTriggerCheckLock(triggerID string) error SetTriggerCheckLock(triggerID string) (bool, error) // Bot data storing GetIDByUsername(messenger, username string) (string, error) SetUsernameID(messenger, username, id string) error RemoveUser(messenger, username string) error RegisterBotIfAlreadyNot(messenger string, ttl time.Duration) bool RenewBotRegistration(messenger string) bool DeregisterBots() DeregisterBot(messenger string) bool // Service registration RegisterNodataCheckerIfAlreadyNot(ttl time.Duration) bool RenewNodataCheckerRegistration() bool DeregisterNodataChecker() bool // Triggers without subscription manipulation MarkTriggersAsUnused(triggerIDs ...string) error GetUnusedTriggerIDs() ([]string, error) MarkTriggersAsUsed(triggerIDs ...string) error // Triggers to reindex in full-text search index FetchTriggersToReindex(from int64) ([]string, error) RemoveTriggersToReindex(to int64) error }
Database implements DB functionality
type Logger ¶
type Logger interface { Debug(args ...interface{}) Debugf(format string, args ...interface{}) Info(args ...interface{}) Infof(format string, args ...interface{}) Error(args ...interface{}) Errorf(format string, args ...interface{}) Fatal(args ...interface{}) Fatalf(format string, args ...interface{}) Warning(args ...interface{}) Warningf(format string, args ...interface{}) }
Logger implements logger abstraction
type MatchedMetric ¶
type MatchedMetric struct { Metric string Patterns []string Value float64 Timestamp int64 RetentionTimestamp int64 Retention int }
MatchedMetric represents parsed and matched metric data
type MetricEvent ¶
MetricEvent represents filter metric event
type MetricState ¶
type MetricState struct { EventTimestamp int64 `json:"event_timestamp"` State string `json:"state"` Suppressed bool `json:"suppressed"` SuppressedState string `json:"suppressed_state,omitempty"` Timestamp int64 `json:"timestamp"` Value *float64 `json:"value,omitempty"` Maintenance int64 `json:"maintenance,omitempty"` }
MetricState represents metric state data for given timestamp
func (*MetricState) GetCheckPoint ¶
func (metricState *MetricState) GetCheckPoint(checkPointGap int64) int64
GetCheckPoint gets check point for given MetricState CheckPoint is the timestamp from which to start checking the current state of the metric
func (MetricState) GetEventTimestamp ¶
func (metricState MetricState) GetEventTimestamp() int64
GetEventTimestamp gets event timestamp for given metric
type MetricValue ¶
type MetricValue struct { RetentionTimestamp int64 `json:"step,omitempty"` Timestamp int64 `json:"ts"` Value float64 `json:"value"` }
MetricValue represents metric data
type NotificationEvent ¶
type NotificationEvent struct { IsTriggerEvent bool `json:"trigger_event,omitempty"` Timestamp int64 `json:"timestamp"` Metric string `json:"metric"` Value *float64 `json:"value,omitempty"` State string `json:"state"` TriggerID string `json:"trigger_id"` SubscriptionID *string `json:"sub_id,omitempty"` ContactID string `json:"contactId,omitempty"` OldState string `json:"old_state"` Message *string `json:"msg,omitempty"` }
NotificationEvent represents trigger state changes event
func (NotificationEvent) String ¶
func (eventData NotificationEvent) String() string
type NotificationEvents ¶
type NotificationEvents []NotificationEvent
NotificationEvents represents slice of NotificationEvent
func (NotificationEvents) GetSubjectState ¶
func (events NotificationEvents) GetSubjectState() string
GetSubjectState returns the most critical state of events
type PlotTheme ¶
type PlotTheme interface { GetTitleStyle() chart.Style GetGridStyle() chart.Style GetCanvasStyle() chart.Style GetBackgroundStyle(maxMarkLen int) chart.Style GetThresholdStyle(thresholdType string) chart.Style GetAnnotationStyle(thresholdType string) chart.Style GetSerieStyles(curveInd int) (curveStyle, pointStyle chart.Style) GetLegendStyle() chart.Style GetXAxisStyle() chart.Style GetYAxisStyle() chart.Style }
PlotTheme is an interface to access plot theme styles
type PlottingData ¶
PlottingData represents plotting settings
type ScheduleData ¶
type ScheduleData struct { Days []ScheduleDataDay `json:"days"` TimezoneOffset int64 `json:"tzOffset"` StartOffset int64 `json:"startOffset"` EndOffset int64 `json:"endOffset"` }
ScheduleData represents subscription schedule
func (*ScheduleData) IsScheduleAllows ¶
func (schedule *ScheduleData) IsScheduleAllows(ts int64) bool
IsScheduleAllows check if the time is in the allowed schedule interval
type ScheduleDataDay ¶
ScheduleDataDay represents week day of schedule
type ScheduledNotification ¶
type ScheduledNotification struct { Event NotificationEvent `json:"event"` Trigger TriggerData `json:"trigger"` Contact ContactData `json:"contact"` Plotting PlottingData `json:"plotting"` Throttled bool `json:"throttled"` SendFail int `json:"send_fail"` Timestamp int64 `json:"timestamp"` }
ScheduledNotification represent notification object
func (*ScheduledNotification) GetKey ¶
func (notification *ScheduledNotification) GetKey() string
GetKey return notification key to prevent duplication to the same contact
type Searcher ¶
type Searcher interface { Start() error Stop() error IsReady() bool SearchTriggers(filterTags []string, searchString string, onlyErrors bool, page int64, size int64) (triggerIDs []string, total int64, err error) }
Searcher interface implements full-text search index functionality
type Sender ¶
type Sender interface { SendEvents(events NotificationEvents, contact ContactData, trigger TriggerData, plot []byte, throttled bool) error Init(senderSettings map[string]string, logger Logger, location *time.Location, dateTimeFormat string) error }
Sender interface for implementing specified contact type sender
type SubscriptionData ¶
type SubscriptionData struct { Contacts []string `json:"contacts"` Tags []string `json:"tags"` Schedule ScheduleData `json:"sched"` Plotting PlottingData `json:"plotting"` ID string `json:"id"` Enabled bool `json:"enabled"` IgnoreWarnings bool `json:"ignore_warnings,omitempty"` IgnoreRecoverings bool `json:"ignore_recoverings,omitempty"` ThrottlingEnabled bool `json:"throttling"` User string `json:"user"` }
SubscriptionData represents user subscription
func (*SubscriptionData) MustIgnore ¶
func (subscription *SubscriptionData) MustIgnore(eventData *NotificationEvent) bool
MustIgnore returns true if given state transition must be ignored
type Trigger ¶
type Trigger struct { ID string `json:"id"` Name string `json:"name"` Desc *string `json:"desc,omitempty"` Targets []string `json:"targets"` WarnValue *float64 `json:"warn_value"` ErrorValue *float64 `json:"error_value"` TriggerType string `json:"trigger_type"` Tags []string `json:"tags"` TTLState *string `json:"ttl_state,omitempty"` TTL int64 `json:"ttl,omitempty"` Schedule *ScheduleData `json:"sched,omitempty"` Expression *string `json:"expression,omitempty"` PythonExpression *string `json:"python_expression,omitempty"` Patterns []string `json:"patterns"` IsRemote bool `json:"is_remote"` MuteNewMetrics bool `json:"mute_new_metrics"` }
Trigger represents trigger data object
func GetTriggerListsDiff ¶
GetTriggerListsDiff returns the members of the set resulting from the difference between the first set and all the successive lists.
type TriggerCheck ¶
type TriggerCheck struct { Trigger Throttling int64 `json:"throttling"` LastCheck CheckData `json:"last_check"` }
TriggerCheck represents trigger data with last check data and check timestamp
type TriggerData ¶
type TriggerData struct { ID string `json:"id"` Name string `json:"name"` Desc string `json:"desc"` Targets []string `json:"targets"` WarnValue float64 `json:"warn_value"` ErrorValue float64 `json:"error_value"` IsRemote bool `json:"is_remote"` Tags []string `json:"__notifier_trigger_tags"` }
TriggerData represents trigger object
func (*TriggerData) GetTags ¶
func (trigger *TriggerData) GetTags() string
GetTags returns "[tag1][tag2]...[tagN]" string
Directories ¶
Path | Synopsis |
---|---|
dto
nolint nolint nolint nolint nolint nolint nolint nolint nolint
|
nolint nolint nolint nolint nolint nolint nolint nolint nolint |
logging
|
|
metrics
|
|
graphite/go-metrics
nolint nolint nolint nolint nolint nolint
|
nolint nolint nolint nolint nolint nolint |
mock
|
|
moira-alert
Package mock_moira_alert is a generated GoMock package.
|
Package mock_moira_alert is a generated GoMock package. |
notifier
Package mock_notifier is a generated GoMock package.
|
Package mock_notifier is a generated GoMock package. |
scheduler
Package mock_scheduler is a generated GoMock package.
|
Package mock_scheduler is a generated GoMock package. |
senders
|
|