types

package
v0.0.0-...-9b5cd94 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionTypeAck         = EventTypeAck
	ActionTypeAckRemove   = EventTypeAckremove
	ActionTypeAssocTicket = EventTypeAssocTicket
	ActionTypeCancel      = EventTypeCancel
	ActionTypeChangeState = EventTypeChangestate
	ActionTypeSnooze      = EventTypeSnooze
	ActionTypePbehavior   = "pbehavior"
	ActionTypeWebhook     = "webhook"
)
View Source
const (
	AlarmStepCropMinStates      = 20
	AlarmStepsHardLimit         = 2000
	AlarmLongOutputHistoryLimit = 100
)

Alarm consts

View Source
const (
	TicketRuleNameScenarioPrefix          = "Scenario: "
	TicketRuleNameIdleRulePrefix          = "Idle rule: "
	TicketRuleNameDeclareTicketRulePrefix = "Ticket declaration rule: "
)
View Source
const (
	InitiatorUser     = "user"
	InitiatorSystem   = "system"
	InitiatorExternal = "external"
)

event initiators

View Source
const (
	SourceTypeResource  = "resource"
	SourceTypeComponent = "component"
	SourceTypeConnector = "connector"
	SourceTypeService   = "service"
	SourceTypeMetaAlarm = "metaalarm"
)

Source types

View Source
const (
	EventTypeAck         = "ack"
	EventTypeAckremove   = "ackremove"
	EventTypeAssocTicket = "assocticket"
	EventTypeCancel      = "cancel"
	EventTypeCheck       = "check"
	EventTypeComment     = "comment"
	EventTypeChangestate = "changestate"
	EventTypeSnooze      = "snooze"
	EventTypeUnsnooze    = "unsnooze"
	EventTypeUncancel    = "uncancel"

	EventTypeDeclareTicketWebhook = "declareticketwebhook"
	EventTypeWebhookStarted       = "webhookstarted"
	EventTypeWebhookCompleted     = "webhookcompleted"
	EventTypeWebhookFailed        = "webhookfailed"
	EventTypeAutoWebhookStarted   = "autowebhookstarted"
	EventTypeAutoWebhookCompleted = "autowebhookcompleted"
	EventTypeAutoWebhookFailed    = "autowebhookfailed"

	EventTypePbhEnter           = "pbhenter"
	EventTypePbhLeaveAndEnter   = "pbhleaveandenter"
	EventTypePbhLeave           = "pbhleave"
	EventTypeResolveCancel      = "resolve_cancel"
	EventTypeResolveClose       = "resolve_close"
	EventTypeResolveDeleted     = "resolve_deleted"
	EventTypeUpdateStatus       = "updatestatus"
	EventTypeActivate           = "activate"
	EventTypeRunDelayedScenario = "run_delayed_scenario"

	EventTypeMetaAlarm               = "metaalarm"
	EventTypeMetaAlarmAttachChildren = "metaalarmattachchildren"
	EventTypeMetaAlarmDetachChildren = "metaalarmdetachchildren"
	EventTypeMetaAlarmUngroup        = "metaalarm_ungroup"
	EventTypeManualMetaAlarmGroup    = "manual_metaalarm_group"
	EventTypeManualMetaAlarmUngroup  = "manual_metaalarm_ungroup"
	EventTypeManualMetaAlarmUpdate   = "manual_metaalarm_update"

	// Following event types are used to add manual instruction execution to alarm steps.
	EventTypeInstructionStarted   = "instructionstarted"
	EventTypeInstructionPaused    = "instructionpaused"
	EventTypeInstructionResumed   = "instructionresumed"
	EventTypeInstructionCompleted = "instructioncompleted"
	EventTypeInstructionFailed    = "instructionfailed"
	// EventTypeInstructionAborted is the same for manual and auto instructions.
	EventTypeInstructionAborted = "instructionaborted"
	// Following event types are used to add auto instruction execution to alarm steps.
	EventTypeAutoInstructionStarted   = "autoinstructionstarted"
	EventTypeAutoInstructionCompleted = "autoinstructioncompleted"
	EventTypeAutoInstructionFailed    = "autoinstructionfailed"
	// Following event types are used to add job execution to alarm steps. Events are
	// the same for manual and auto instructions.
	EventTypeInstructionJobStarted   = "instructionjobstarted"
	EventTypeInstructionJobCompleted = "instructionjobcompleted"
	EventTypeInstructionJobFailed    = "instructionjobfailed"

	// EventTypeRecomputeEntityService is used to recompute service context graph and state.
	EventTypeRecomputeEntityService = "recomputeentityservice"
	// EventTypeEntityUpdated is used to notify engines that entity is updated out of
	// event flow.
	EventTypeEntityUpdated = "entityupdated"
	// EventTypeEntityToggled is used to notify engines that entity is enabled/disabled.
	EventTypeEntityToggled = "entitytoggled"

	EventTypeUpdateCounters = "updatecounters"
	// EventTypeJunitTestSuiteUpdated is used to notify that test suite is updated but state is not changed.
	EventTypeJunitTestSuiteUpdated = "junittestsuiteupdated"
	// EventTypeJunitTestCaseUpdated is used to notify that test case is updated but state is not changed.
	EventTypeJunitTestCaseUpdated = "junittestcaseeupdated"
	// EventTypeNoEvents is used to create alarm for entity by idle rule.
	EventTypeNoEvents = "noevents"
	// EventTypeTrigger is used in axe rpc to send auto and manual instruction triggers
	EventTypeTrigger = "trigger"
	// EventTypeAutoInstructionActivate is used to activate alarm when an autoremediation triggered by create trigger is completed
	EventTypeAutoInstructionActivate = "autoinstructionactivate"

	EventTypeMetaAlarmChildActivate   = "metaalarmchildactivate"
	EventTypeMetaAlarmChildDeactivate = "metaalarmchilddeactivate"
)

Event types. Add each new event type to isValidEventType func.

View Source
const (
	ConnectorEngineService = "service"
	ConnectorJunit         = "junit"
	ConnectorApi           = "api"
)
View Source
const (
	AlarmStateOK = iota
	AlarmStateMinor
	AlarmStateMajor
	AlarmStateCritical
)

Alarm states

View Source
const (
	AlarmStateTitleOK       = "ok"
	AlarmStateTitleMinor    = "minor"
	AlarmStateTitleMajor    = "major"
	AlarmStateTitleCritical = "critical"
)
View Source
const (
	AlarmStatusOff = iota
	AlarmStatusOngoing
	AlarmStatusStealthy
	AlarmStatusFlapping
	AlarmStatusCancelled
	AlarmStatusNoEvents
)

Alarm statuses

View Source
const (
	AlarmStatusTitleOff       = "off"
	AlarmStatusTitleOngoing   = "ongoing"
	AlarmStatusTitleStealthy  = "stealthy"
	AlarmStatusTitleFlapping  = "flapping"
	AlarmStatusTitleCancelled = "cancelled"
)
View Source
const (
	AlarmStepStateIncrease   = "stateinc"
	AlarmStepStateDecrease   = "statedec"
	AlarmStepStatusIncrease  = "statusinc"
	AlarmStepStatusDecrease  = "statusdec"
	AlarmStepAck             = "ack"
	AlarmStepAckRemove       = "ackremove"
	AlarmStepCancel          = "cancel"
	AlarmStepUncancel        = "uncancel"
	AlarmStepComment         = "comment"
	AlarmStepSnooze          = "snooze"
	AlarmStepStateCounter    = "statecounter"
	AlarmStepChangeState     = "changestate"
	AlarmStepPbhEnter        = "pbhenter"
	AlarmStepPbhLeave        = "pbhleave"
	AlarmStepMetaAlarmAttach = "metaalarmattach"

	AlarmStepAssocTicket       = "assocticket"
	AlarmStepDeclareTicket     = "declareticket"
	AlarmStepDeclareTicketFail = "declareticketfail"
	AlarmStepWebhookStart      = "webhookstart"
	AlarmStepWebhookComplete   = "webhookcomplete"
	AlarmStepWebhookFail       = "webhookfail"

	// Following alarm steps are used for manual instruction execution.
	AlarmStepInstructionStart    = "instructionstart"
	AlarmStepInstructionPause    = "instructionpause"
	AlarmStepInstructionResume   = "instructionresume"
	AlarmStepInstructionComplete = "instructioncomplete"
	AlarmStepInstructionFail     = "instructionfail"
	// AlarmStepInstructionAbort are used for manual and auto instruction execution.
	AlarmStepInstructionAbort = "instructionabort"
	// Following alarm steps are used for manual instruction execution.
	AlarmStepAutoInstructionStart    = "autoinstructionstart"
	AlarmStepAutoInstructionComplete = "autoinstructioncomplete"
	AlarmStepAutoInstructionFail     = "autoinstructionfail"
	// Following alarm steps are used for job execution.
	AlarmStepInstructionJobStart    = "instructionjobstart"
	AlarmStepInstructionJobComplete = "instructionjobcomplete"
	AlarmStepInstructionJobFail     = "instructionjobfail"

	// Following alarm steps are used for junit.
	AlarmStepJunitTestSuiteUpdate = "junittestsuiteupdate"
	AlarmStepJunitTestCaseUpdate  = "junittestcaseupdate"
)

Alarm steps

View Source
const (
	EntityTypeConnector = "connector"
	EntityTypeComponent = "component"
	EntityTypeResource  = "resource"
	EntityTypeService   = "service"
)

Entity types

View Source
const ActionPbehaviorColor = "#808080"
View Source
const EntityDefaultImpactLevel = 1
View Source
const MaxEventTimestampVariation = 24 * time.Hour
View Source
const MinimalEventsCountThreshold = 2
View Source
const PbhCanonicalTypeActive = "active"

PbhCanonicalTypeActive is duplicate of pbehavior.TypeActive because of package cycle. todo: move type constants from pbehavior package to types package

View Source
const (
	StepEngineCorrelationAuthor = "engine.correlation"
)

Variables

View Source
var ErrInvalidInfoType = fmt.Errorf("info value should be int, string, bool or array of strings")

Functions

func AsInteger

func AsInteger(value interface{}) (int64, bool)

AsInteger tries to convert an interface{} into an int64, and returns its value and an integer indicating whether it succeeded or not.

It works with int, uint, int64, uint64, CpsNumber and CpsTime (in this case, a unix timestamp is returned).

func GenDisplayName

func GenDisplayName(tpl *template.Template) string

func InterfaceToString

func InterfaceToString(v interface{}) (string, error)

InterfaceToString tries to convert v to it's string value. Supported types: * float64 * string * bool * int|int64|uint|uint64 * []interface{} : join elements with "," * nil: will return empty string

Any other type will return empty string and an error, like lists or maps...

func InterfaceToStringSlice

func InterfaceToStringSlice(v interface{}) ([]string, error)

func IsInfoValueValid

func IsInfoValueValid(value interface{}) bool

func TransformEventTag

func TransformEventTag(k, v string) string

func TransformEventTags

func TransformEventTags(eventTags map[string]string) []string

Types

type Alarm

type Alarm struct {
	ID       string           `bson:"_id" json:"_id"`
	Time     datetime.CpsTime `bson:"t" json:"t"`
	EntityID string           `bson:"d" json:"d"`

	Tags                []string           `bson:"tags" json:"tags"`
	ExternalTags        []string           `bson:"etags" json:"etags"`
	InternalTags        []string           `bson:"itags" json:"itags"`
	InternalTagsUpdated datetime.MicroTime `bson:"itags_upd" json:"itags_upd"`
	// todo move all field from Value to Alarm
	Value AlarmValue `bson:"v" json:"v"`

	// is used only for manual instructions KPI metrics
	KpiAssignedInstructions []string `bson:"kpi_assigned_instructions,omitempty" json:"kpi_assigned_instructions,omitempty"`
	KpiExecutedInstructions []string `bson:"kpi_executed_instructions,omitempty" json:"kpi_executed_instructions,omitempty"`
	// is used only for auto instructions KPI metrics
	KpiAssignedAutoInstructions []string `bson:"kpi_assigned_auto_instructions,omitempty" json:"kpi_assigned_auto_instructions,omitempty"`
	KpiExecutedAutoInstructions []string `bson:"kpi_executed_auto_instructions,omitempty" json:"kpi_executed_auto_instructions,omitempty"`

	// is used only for not acked metrics
	NotAckedMetricType     string            `bson:"not_acked_metric_type,omitempty" json:"-"`
	NotAckedMetricSendTime *datetime.CpsTime `bson:"not_acked_metric_send_time,omitempty" json:"-"`
	NotAckedSince          *datetime.CpsTime `bson:"not_acked_since,omitempty" json:"-"`

	// InactiveAutoInstructionInProgress shows that autoremediation is launched and alarm is not active until the remediation is finished
	InactiveAutoInstructionInProgress bool `bson:"auto_instruction_in_progress,omitempty" json:"auto_instruction_in_progress,omitempty"`

	InactiveDelayMetaAlarmInProgress bool `bson:"inactive_delay_meta_alarm_in_progress,omitempty" json:"inactive_delay_meta_alarm_in_progress,omitempty"`
	// MetaAlarmInactiveDelay shows that an alarm is matched to some meta alarm rules with child_inactive_delay
	MetaAlarmInactiveDelay []MetaAlarmInactiveDelay `bson:"meta_alarm_inactive_delay,omitempty" json:"meta_alarm_inactive_delay,omitempty"`

	Healthcheck bool `bson:"healthcheck,omitempty" json:"-"`
}

Alarm represents an alarm document.

func (*Alarm) AddChild

func (a *Alarm) AddChild(childEID string)

func (*Alarm) AddParent

func (a *Alarm) AddParent(parentEID string) bool

func (*Alarm) CanActivate

func (a *Alarm) CanActivate() bool

func (*Alarm) Closable

func (a *Alarm) Closable(d time.Duration) bool

Closable checks the last step for it's state to be OK for at least d interval. Reference time is time.Now() when this function is called.

func (*Alarm) CropSteps

func (a *Alarm) CropSteps() bool

CropSteps calls Crop() on Alarm.Value.Steps with alarm parameters. returns true if the alarm was modified.

func (*Alarm) CurrentState

func (a *Alarm) CurrentState() CpsNumber

CurrentState returns the Current State of the Alarm

func (*Alarm) GetAppliedActions

func (a *Alarm) GetAppliedActions() (steps AlarmSteps)

GetAppliedActions fetches applied to alarm actions: ACK, Snooze, AssocTicket, DeclareTicket Result is in a sorted by timestamp AlarmSteps, ticket data when defined

func (*Alarm) GetDurationField

func (a *Alarm) GetDurationField(f string) (int64, bool)

GetDurationField is a magic getter for duration fields for easier field retrieving when matching alarm pattern

func (*Alarm) GetInfoVal

func (a *Alarm) GetInfoVal(f string) (interface{}, bool)

GetInfoVal is a magic getter for infos fields for easier field retrieving when matching alarm pattern

func (*Alarm) GetIntField

func (a *Alarm) GetIntField(f string) (int64, bool)

GetIntField is a magic getter for int fields for easier field retrieving when matching alarm pattern

func (*Alarm) GetMetaAlarmInactiveExpiration

func (a *Alarm) GetMetaAlarmInactiveExpiration(ruleId string) (datetime.CpsTime, bool)

func (*Alarm) GetRefField

func (a *Alarm) GetRefField(f string) (interface{}, bool)

GetRefField is a magic getter for reference fields for easier field retrieving when matching alarm pattern

func (*Alarm) GetStringArrayField

func (a *Alarm) GetStringArrayField(f string) ([]string, bool)

GetStringArrayField is a magic getter for string array fields for easier field retrieving when matching alarm pattern

func (*Alarm) GetStringField

func (a *Alarm) GetStringField(f string) (string, bool)

GetStringField is a magic getter for string fields for easier field retrieving when matching alarm pattern

func (*Alarm) GetTimeField

func (a *Alarm) GetTimeField(f string) (time.Time, bool)

GetTimeField is a magic getter for time fields for easier field retrieving when matching alarm pattern

func (*Alarm) HasChildByEID

func (a *Alarm) HasChildByEID(childEID string) bool

func (*Alarm) HasParentByEID

func (a *Alarm) HasParentByEID(parentEID string) bool

func (*Alarm) HasSingleAck

func (a *Alarm) HasSingleAck() bool

HasSingleAck returns true if the alarm has been acknowledged exactly once. Note that this method will return false if the alarm has received a first ack, an ackremove, and a second ack. It should be used to run actions on the first acknowledgement only.

func (*Alarm) HasUnlinkedParentByEID

func (a *Alarm) HasUnlinkedParentByEID(parentEID string) bool

func (*Alarm) IsAck

func (a *Alarm) IsAck() bool

IsAck check if an Alarm is acked

func (*Alarm) IsActivated

func (a *Alarm) IsActivated() bool

func (*Alarm) IsCanceled

func (a *Alarm) IsCanceled() bool

IsCanceled check if an Alarm is canceled

func (*Alarm) IsInActivePeriod

func (a *Alarm) IsInActivePeriod() bool

func (*Alarm) IsMalfunctioning

func (a *Alarm) IsMalfunctioning() bool

IsMalfunctioning...

func (*Alarm) IsMatched

func (a *Alarm) IsMatched(regex string, fields []string) bool

IsMatched tell if an alarm is catched by a regex

func (*Alarm) IsMetaAlarm

func (a *Alarm) IsMetaAlarm() bool

func (*Alarm) IsMetaChild

func (a *Alarm) IsMetaChild() bool

func (*Alarm) IsResolved

func (a *Alarm) IsResolved() bool

IsResolved tell if an alarm has been resolved

func (*Alarm) IsSnoozed

func (a *Alarm) IsSnoozed() bool

IsSnoozed check if an Alarm is snoozed

func (*Alarm) IsStateLocked

func (a *Alarm) IsStateLocked() bool

IsStateLocked checks that the Alarm is not Locked (by manual intervention for example)

func (*Alarm) RemoveChild

func (a *Alarm) RemoveChild(childEID string)

func (*Alarm) RemoveParent

func (a *Alarm) RemoveParent(parentEID string) bool

type AlarmChange

type AlarmChange struct {
	Type                            AlarmChangeType   `json:"Type"`
	PreviousState                   CpsNumber         `json:"PreviousState"`
	PreviousStateChange             datetime.CpsTime  `json:"PreviousStateChange"`
	PreviousStatus                  CpsNumber         `json:"PreviousStatus"`
	PreviousStatusChange            datetime.CpsTime  `json:"PreviousStatusChange"`
	PreviousPbehaviorTime           *datetime.CpsTime `json:"PreviousPbehaviorTime"`
	PreviousEntityPbehaviorTime     *datetime.CpsTime `json:"PreviousEntityPbehaviorTime"`
	PreviousPbehaviorTypeID         string            `json:"PreviousPbehaviorTypeID"`
	PreviousPbehaviorCannonicalType string            `json:"PreviousPbehaviorCannonicalType"`

	EventsCount int `json:"EventsCount"`
}

AlarmChange is a struct containing the type of change that occurred on an alarm, as well as its previous state.

func NewAlarmChange

func NewAlarmChange() AlarmChange

func NewAlarmChangeByAlarm

func NewAlarmChangeByAlarm(alarm Alarm, t ...AlarmChangeType) AlarmChange

func (*AlarmChange) GetTriggers

func (ac *AlarmChange) GetTriggers() []string

func (*AlarmChange) IsZero

func (ac *AlarmChange) IsZero() bool

type AlarmChangeType

type AlarmChangeType string

AlarmChangeType is a type representing a change that can occur on an alarm.

const (
	AlarmChangeTypeNone              AlarmChangeType = ""
	AlarmChangeTypeStateIncrease     AlarmChangeType = "stateinc"
	AlarmChangeTypeStateDecrease     AlarmChangeType = "statedec"
	AlarmChangeTypeCreate            AlarmChangeType = "create"
	AlarmChangeTypeCreateAndPbhEnter AlarmChangeType = "createandpbhenter"
	AlarmChangeTypeAck               AlarmChangeType = "ack"
	AlarmChangeTypeDoubleAck         AlarmChangeType = "doubleack"
	AlarmChangeTypeAckremove         AlarmChangeType = "ackremove"
	AlarmChangeTypeCancel            AlarmChangeType = "cancel"
	AlarmChangeTypeUncancel          AlarmChangeType = "uncancel"
	AlarmChangeTypeAssocTicket       AlarmChangeType = "assocticket"
	AlarmChangeTypeSnooze            AlarmChangeType = "snooze"
	AlarmChangeTypeUnsnooze          AlarmChangeType = "unsnooze"
	AlarmChangeTypeResolve           AlarmChangeType = "resolve"
	AlarmChangeTypeComment           AlarmChangeType = "comment"
	AlarmChangeTypeChangeState       AlarmChangeType = "changestate"
	AlarmChangeTypePbhEnter          AlarmChangeType = "pbhenter"
	AlarmChangeTypePbhLeave          AlarmChangeType = "pbhleave"
	AlarmChangeTypePbhLeaveAndEnter  AlarmChangeType = "pbhleaveandenter"
	AlarmChangeTypeUpdateStatus      AlarmChangeType = "changestatus"
	AlarmChangeTypeActivate          AlarmChangeType = "activate"

	AlarmChangeTypeWebhookStart                 AlarmChangeType = "webhookstart"
	AlarmChangeTypeWebhookComplete              AlarmChangeType = "webhookcomplete"
	AlarmChangeTypeWebhookFail                  AlarmChangeType = "webhookfail"
	AlarmChangeTypeDeclareTicketWebhook         AlarmChangeType = "declareticketwebhook"
	AlarmChangeTypeDeclareTicketWebhookFail     AlarmChangeType = "declareticketwebhookfail"
	AlarmChangeTypeAutoWebhookStart             AlarmChangeType = "autowebhookstart"
	AlarmChangeTypeAutoWebhookComplete          AlarmChangeType = "autowebhookcomplete"
	AlarmChangeTypeAutoWebhookFail              AlarmChangeType = "autowebhookfail"
	AlarmChangeTypeAutoDeclareTicketWebhook     AlarmChangeType = "autodeclareticketwebhook"
	AlarmChangeTypeAutoDeclareTicketWebhookFail AlarmChangeType = "autodeclareticketwebhookfail"

	// Following change types are used for manual instruction execution.
	AlarmChangeTypeInstructionStart    AlarmChangeType = "instructionstart"
	AlarmChangeTypeInstructionPause    AlarmChangeType = "instructionpause"
	AlarmChangeTypeInstructionResume   AlarmChangeType = "instructionresume"
	AlarmChangeTypeInstructionComplete AlarmChangeType = "instructioncomplete"
	AlarmChangeTypeInstructionFail     AlarmChangeType = "instructionfail"
	// AlarmChangeTypeInstructionAbort is used for manual and auto instruction execution.
	AlarmChangeTypeInstructionAbort AlarmChangeType = "instructionabort"
	// Following change types are used for auto instruction execution.
	AlarmChangeTypeAutoInstructionStart    AlarmChangeType = "autoinstructionstart"
	AlarmChangeTypeAutoInstructionComplete AlarmChangeType = "autoinstructioncomplete"
	AlarmChangeTypeAutoInstructionFail     AlarmChangeType = "autoinstructionfail"
	// Following change types are used for auto instruction triggers.
	AlarmChangeTypeAutoInstructionResultOk   AlarmChangeType = "autoinstructionresultok"
	AlarmChangeTypeAutoInstructionResultFail AlarmChangeType = "autoinstructionresultfail"
	// Following change types are used for job execution.
	AlarmChangeTypeInstructionJobStart    AlarmChangeType = "instructionjobstart"
	AlarmChangeTypeInstructionJobComplete AlarmChangeType = "instructionjobcomplete"
	AlarmChangeTypeInstructionJobFail     AlarmChangeType = "instructionjobfail"

	// Following change types are used for junit.
	AlarmChangeTypeJunitTestSuiteUpdate AlarmChangeType = "junittestsuiteupdate"
	AlarmChangeTypeJunitTestCaseUpdate  AlarmChangeType = "junittestcaseupdate"

	AlarmChangeTypeEnabled AlarmChangeType = "enabled"

	// AlarmChangeTypeAutoInstructionActivate is used to activate alarm when an autoremediation triggered by create trigger is completed
	AlarmChangeTypeAutoInstructionActivate AlarmChangeType = "autoinstructionactivate"

	// AlarmChangeEventsCount is used for eventscount trigger and alarm's events_count value should be added to the end of a trigger name, e.g. "eventscount3"
	AlarmChangeEventsCount AlarmChangeType = "eventscount"

	AlarmChangeTypeMetaAlarmChildActivate   AlarmChangeType = "metaalarmchildactivate"
	AlarmChangeTypeMetaAlarmChildDeactivate AlarmChangeType = "metaalarmchilddeactivate"
)

An AlarmChangeType can have the following values:

type AlarmStep

type AlarmStep struct {
	Type                   string           `bson:"_t" json:"_t"`
	Timestamp              datetime.CpsTime `bson:"t" json:"t"`
	Author                 string           `bson:"a" json:"a"`
	UserID                 string           `bson:"user_id,omitempty" json:"user_id,omitempty"`
	Message                string           `bson:"m" json:"m"`
	Role                   string           `bson:"role,omitempty" json:"role,omitempty"`
	Value                  CpsNumber        `bson:"val" json:"val"`
	StateCounter           CropCounter      `bson:"statecounter,omitempty" json:"statecounter,omitempty"`
	PbehaviorCanonicalType string           `bson:"pbehavior_canonical_type,omitempty" json:"pbehavior_canonical_type,omitempty"`
	Initiator              string           `bson:"initiator,omitempty" json:"initiator,omitempty"`
	// Execution contains id
	// - of instruction execution for instruction steps
	// - of webhook execution for webhook steps
	Execution string `bson:"exec,omitempty" json:"exec,omitempty"`

	TicketInfo `bson:",inline"`
}

AlarmStep represents a generic step used in an alarm.

func NewAlarmStep

func NewAlarmStep(stepType string, timestamp datetime.CpsTime, author, msg, userID, role, initiator string) AlarmStep

NewAlarmStep returns an AlarmStep. If the timestamp or author are empty, default values will be used to create an AlarmStep.

func NewMetaAlarmAttachStep

func NewMetaAlarmAttachStep(metaAlarm Alarm, ruleName string) AlarmStep

func NewTicketStep

func NewTicketStep(stepType string, timestamp datetime.CpsTime, author, msg, userID, role, initiator string, ticketInfo TicketInfo) AlarmStep

func (*AlarmStep) GetInitiator

func (s *AlarmStep) GetInitiator() string

type AlarmSteps

type AlarmSteps []AlarmStep

AlarmSteps is a sortable implementation of []*AlarmStep. Used for sorting steps in some functions. Implements sort.Interface

func (*AlarmSteps) Add

func (s *AlarmSteps) Add(step AlarmStep) error

Add handle adding a step to the list

func (AlarmSteps) Crop

func (s AlarmSteps) Crop(currentStatus *AlarmStep, cropNum int) (AlarmSteps, bool)

Crop steps by replacing stateinc and statedec steps after the current status with a statecounter step Returns :

  • the updated alarm steps
  • True if it was updated, false else

param currentStatus: the current status of the alarm. The steps will be cropped from this status param cropNum: crop only if we have at least cropNum steps with type AlarmStepStateIncrease or AlarmStepStateDecrease

func (AlarmSteps) Last

func (s AlarmSteps) Last() (AlarmStep, error)

Last returns the last step, if any, or returns an error.

func (AlarmSteps) Len

func (s AlarmSteps) Len() int

func (AlarmSteps) Swap

func (s AlarmSteps) Swap(i, j int)

func (AlarmSteps) UpdateStateCounter

func (s AlarmSteps) UpdateStateCounter(currentStatus *AlarmStep, currentStatusIdx int, counter CropCounter) AlarmSteps

UpdateStateCounter updates the alarm steps with the statecounter step Returns the updated AlarmSteps and the updated (or newly created) statecounter step. param currentStatus: the current status of the alarm. The statecounter step infos will come from it. param currentStatusIdx: the alarm current status' index. It is used to insert or update the statecounter step right after it. param counter: the crop counter to update or create the statecounter step from.

type AlarmValue

type AlarmValue struct {
	ACK         *AlarmStep  `bson:"ack,omitempty" json:"ack,omitempty"`
	Canceled    *AlarmStep  `bson:"canceled,omitempty" json:"canceled,omitempty"`
	Snooze      *AlarmStep  `bson:"snooze,omitempty" json:"snooze,omitempty"`
	State       *AlarmStep  `bson:"state,omitempty" json:"state,omitempty"`
	Status      *AlarmStep  `bson:"status,omitempty" json:"status,omitempty"`
	LastComment *AlarmStep  `bson:"last_comment,omitempty" json:"last_comment,omitempty"`
	ChangeState *AlarmStep  `bson:"change_state,omitempty" json:"change_state,omitempty"`
	Tickets     []AlarmStep `bson:"tickets,omitempty" json:"tickets,omitempty"`
	// Ticket contains the last created ticket
	Ticket *AlarmStep `bson:"ticket,omitempty" json:"ticket,omitempty"`
	Steps  AlarmSteps `bson:"steps" json:"steps"`

	Component         string            `bson:"component" json:"component"`
	Connector         string            `bson:"connector" json:"connector"`
	ConnectorName     string            `bson:"connector_name" json:"connector_name"`
	CreationDate      datetime.CpsTime  `bson:"creation_date" json:"creation_date"`
	ActivationDate    *datetime.CpsTime `bson:"activation_date,omitempty" json:"activation_date,omitempty"`
	DisplayName       string            `bson:"display_name" json:"display_name"`
	HardLimit         *CpsNumber        `bson:"hard_limit,omitempty" json:"hard_limit,omitempty"`
	InitialOutput     string            `bson:"initial_output" json:"initial_output"`
	Output            string            `bson:"output" json:"output"`
	InitialLongOutput string            `bson:"initial_long_output" json:"initial_long_output"`
	LongOutput        string            `bson:"long_output" json:"long_output"`
	LongOutputHistory []string          `bson:"long_output_history" json:"long_output_history"`
	LastUpdateDate    datetime.CpsTime  `bson:"last_update_date" json:"last_update_date"`
	LastEventDate     datetime.CpsTime  `bson:"last_event_date" json:"last_event_date"`
	Resource          string            `bson:"resource,omitempty" json:"resource,omitempty"`
	Resolved          *datetime.CpsTime `bson:"resolved,omitempty" json:"resolved,omitempty"`
	PbehaviorInfo     PbehaviorInfo     `bson:"pbehavior_info,omitempty" json:"pbehavior_info,omitempty"`
	Meta              string            `bson:"meta,omitempty" json:"meta,omitempty"`
	MetaValuePath     string            `bson:"meta_value_path,omitempty" json:"meta_value_path,omitempty"`

	Parents         []string `bson:"parents" json:"parents"`
	Children        []string `bson:"children" json:"children"`
	UnlinkedParents []string `bson:"unlinked_parents" json:"unlinked_parents"`

	StateChangesSinceStatusUpdate CpsNumber `bson:"state_changes_since_status_update,omitempty" json:"state_changes_since_status_update,omitempty"`
	TotalStateChanges             CpsNumber `bson:"total_state_changes,omitempty" json:"total_state_changes,omitempty"`
	// EventsCount accumulates count of check events.
	EventsCount CpsNumber `bson:"events_count,omitempty" json:"events_count,omitempty"`

	Infos map[string]map[string]interface{} `bson:"infos" json:"infos"`

	// store version of dynamic-infos rule
	RuleVersion map[string]string `bson:"infos_rule_version" json:"infos_rule_version"`

	// InactiveStart represents start of snooze or maintenance, pause, inactive pbehavior interval.
	// It's used only to compute InactiveDuration.
	InactiveStart *datetime.CpsTime `bson:"inactive_start,omitempty" json:"inactive_start"`
	// Duration represents a duration from creation date to resolve date.
	// Keep omitempty.
	Duration int64 `bson:"duration,omitempty" json:"duration"`
	// CurrentStateDuration represents a duration when an alarm was in current state.
	// Keep omitempty.
	CurrentStateDuration int64 `bson:"current_state_duration,omitempty" json:"current_state_duration"`
	// ActiveDuration represents a duration when an alarm wasn't in snooze or in maintenance, pause, inactive pbehavior interval.
	// Keep omitempty.
	ActiveDuration int64 `bson:"active_duration,omitempty" json:"active_duration"`
	// InactiveDuration represents a duration when an alarm was in snooze or in maintenance, pause, inactive pbehavior interval.
	InactiveDuration int64 `bson:"inactive_duration" json:"inactive_duration"`
	// SnoozeDuration represents a duration when an alarm was in snooze.
	SnoozeDuration int64 `bson:"snooze_duration" json:"snooze_duration"`
	// PbehaviorInactiveDuration represents a duration when an alarm was in maintenance, pause, inactive pbehavior interval.
	PbehaviorInactiveDuration int64 `bson:"pbh_inactive_duration" json:"pbh_inactive_duration"`
}

AlarmValue represents a full description of an alarm.

func (*AlarmValue) Transform

func (v *AlarmValue) Transform()

type AlarmWithEntity

type AlarmWithEntity struct {
	Alarm  Alarm  `bson:"alarm" json:"alarm"`
	Entity Entity `bson:"entity" json:"entity"`
}

AlarmWithEntity is an encapsulated type, mostly to facilitate the alarm manipulation for the post-processors

type ByTimestamp

type ByTimestamp struct {
	AlarmSteps
}

func (ByTimestamp) Less

func (s ByTimestamp) Less(i, j int) bool

type Coordinates

type Coordinates struct {
	Lat float64 `bson:"lat" json:"lat" binding:"required,latitude"`
	Lng float64 `bson:"lng" json:"lng" binding:"required,longitude"`
}

func (Coordinates) IsZero

func (c Coordinates) IsZero() bool

type CpsNumber

type CpsNumber int64

CpsNumber is here for compatibility with old python engines. It will force an int64 from a float64.

func (CpsNumber) CpsTimestamp

func (t CpsNumber) CpsTimestamp() datetime.CpsTime

CpsTimestamp convert a number to a timestamp

func (CpsNumber) Float64

func (t CpsNumber) Float64() float64

Float64 ...

func (CpsNumber) MarshalJSON

func (t CpsNumber) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Encoder interface

func (*CpsNumber) UnmarshalJSON

func (t *CpsNumber) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Decoder interface

type CropCounter

type CropCounter struct {
	StateChanges  int `bson:"statechanges" json:"statechanges"`
	Stateinc      int `bson:"stateinc" json:"stateinc"`
	Statedec      int `bson:"statedec" json:"statedec"`
	StateInfo     int `bson:"state:0,omitempty" json:"state:0,omitempty"`
	StateMinor    int `bson:"state:1,omitempty" json:"state:1,omitempty"`
	StateMajor    int `bson:"state:2,omitempty" json:"state:2,omitempty"`
	StateCritical int `bson:"state:3,omitempty" json:"state:3,omitempty"`
}

CropCounter provides an explicit way of counting the steps that were cropped.

func (CropCounter) IsZero

func (counter CropCounter) IsZero() bool

func (*CropCounter) MergeCounter

func (counter *CropCounter) MergeCounter(secondCounter CropCounter)

MergeCounter merges the current counter with the provided counter and returns the merged counter.

func (*CropCounter) UpdateWithStep

func (counter *CropCounter) UpdateWithStep(step AlarmStep)

UpdateWithStep updates the CropCounter with the provided step informations.

type Entity

type Entity struct {
	ID             string             `bson:"_id" json:"_id"`
	Name           string             `bson:"name" json:"name"`
	Description    string             `bson:"description" json:"description"`
	EnableHistory  []datetime.CpsTime `bson:"enable_history" json:"enable_history"`
	Measurements   interface{}        `bson:"measurements" json:"measurements"` // unused collection ids
	Enabled        bool               `bson:"enabled" json:"enabled"`
	Infos          map[string]Info    `bson:"infos" json:"infos"`
	ComponentInfos map[string]Info    `bson:"component_infos,omitempty" json:"component_infos,omitempty"`
	Type           string             `bson:"type" json:"type"`
	Category       string             `bson:"category" json:"category"`
	ImpactLevel    int64              `bson:"impact_level" json:"impact_level"`
	Created        datetime.CpsTime   `bson:"created" json:"created"`
	LastEventDate  *datetime.CpsTime  `bson:"last_event_date,omitempty" json:"last_event_date,omitempty"`

	Connector string `bson:"connector,omitempty" json:"connector,omitempty"`
	Component string `bson:"component,omitempty" json:"component,omitempty"`
	// ImpactedServices field is only for connectors, see entity service RecomputeIdleSince method.
	ImpactedServices []string `bson:"impacted_services" json:"-"`

	// LastIdleRuleApply is used to mark entity if some idle rule was applied.
	LastIdleRuleApply string `bson:"last_idle_rule_apply,omitempty" json:"last_idle_rule_apply,omitempty"`
	// IdleSince represents since when entity didn't receive any events.
	IdleSince *datetime.CpsTime `bson:"idle_since,omitempty" json:"idle_since,omitempty"`

	ImportSource string            `bson:"import_source,omitempty" json:"import_source"`
	Imported     *datetime.CpsTime `bson:"imported,omitempty" json:"imported"`

	PbehaviorInfo     PbehaviorInfo     `bson:"pbehavior_info,omitempty" json:"pbehavior_info,omitempty"`
	LastPbehaviorDate *datetime.CpsTime `bson:"last_pbehavior_date,omitempty" json:"last_pbehavior_date,omitempty"`

	SliAvailState int64 `bson:"sli_avail_state" json:"sli_avail_state"`

	Services         []string `bson:"services" json:"services,omitempty"`
	ServicesToAdd    []string `bson:"services_to_add,omitempty" json:"services_to_add,omitempty"`
	ServicesToRemove []string `bson:"services_to_remove,omitempty" json:"services_to_remove,omitempty"`

	// Coordinates is used only in api, add json tag if it's required in an event.
	Coordinates Coordinates `bson:"coordinates,omitempty" json:"-"`

	SoftDeleted *datetime.CpsTime `bson:"soft_deleted,omitempty" json:"soft_deleted,omitempty"`

	PerfData        []string          `bson:"perf_data,omitempty" json:"-"`
	PerfDataUpdated *datetime.CpsTime `bson:"perf_data_updated,omitempty" json:"-"`

	// IsNew and IsUpdated used in engine che in entity creation and eventfilter
	IsNew     bool `bson:"-" json:"-"`
	IsUpdated bool `bson:"-" json:"-"`

	Healthcheck bool `bson:"healthcheck,omitempty" json:"-"`

	StateInfo *StateInfo `bson:"state_info" json:"state_info"`

	ComponentStateSettings         bool `bson:"component_state_settings,omitempty" json:"component_state_settings,omitempty"`
	ComponentStateSettingsToAdd    bool `bson:"component_state_settings_to_add,omitempty" json:"component_state_settings_to_add,omitempty"`
	ComponentStateSettingsToRemove bool `bson:"component_state_settings_to_remove,omitempty" json:"component_state_settings_to_remove,omitempty"`
}

Entity ...

func (*Entity) EnsureInitialized

func (e *Entity) EnsureInitialized()

EnsureInitialized verifies that all complex structs are well initialized

func (*Entity) GetInfoVal

func (e *Entity) GetInfoVal(f string) (any, bool)

GetInfoVal is a magic getter for infos fields for easier field retrieving when matching entity pattern

func (*Entity) GetIntField

func (e *Entity) GetIntField(f string) (int64, bool)

GetIntField is a magic getter for int fields for easier field retrieving when matching entity pattern

func (*Entity) GetStringField

func (e *Entity) GetStringField(f string) (string, bool)

GetStringField is a magic getter for string fields for easier field retrieving when matching entity pattern

func (*Entity) GetTimeField

func (e *Entity) GetTimeField(f string) (time.Time, bool)

GetTimeField is a magic getter for time fields for easier field retrieving when matching entity pattern

type Event

type Event struct {
	ID            *string    `bson:"_id" json:"_id"`
	Connector     string     `bson:"connector" json:"connector"`
	ConnectorName string     `bson:"connector_name" json:"connector_name"`
	EventType     string     `bson:"event_type" json:"event_type"`
	Component     string     `bson:"component" json:"component"`
	Resource      string     `bson:"resource" json:"resource"`
	PerfData      string     `bson:"perf_data" json:"perf_data"`
	Status        *CpsNumber `bson:"status" json:"status"`
	SourceType    string     `bson:"source_type" json:"source_type"`
	LongOutput    string     `bson:"long_output" json:"long_output"`
	State         CpsNumber  `bson:"state" json:"state"`
	Output        string     `bson:"output" json:"output"`
	Alarm         *Alarm     `bson:"current_alarm" json:"current_alarm"`
	Entity        *Entity    `bson:"current_entity" json:"current_entity"`

	// AlarmID is used if an event is emitted for the specific alarm.
	AlarmID string `bson:"aid,omitempty" json:"aid,omitempty"`

	Author string `bson:"author" json:"author"`
	UserID string `bson:"user_id" json:"user_id"`

	Timestamp         datetime.CpsTime   `bson:"timestamp" json:"timestamp"`
	ReceivedTimestamp datetime.MicroTime `bson:"rt" json:"rt"`

	RK          string                 `bson:"routing_key" json:"routing_key"`
	Duration    CpsNumber              `bson:"duration,omitempty" json:"duration,omitempty"`
	StatName    string                 `bson:"stat_name" json:"stat_name"`
	Debug       bool                   `bson:"debug" json:"debug"`
	Role        string                 `bson:"role,omitempty" json:"role,omitempty"`
	ExtraInfos  map[string]interface{} `bson:"extra_infos" json:"extra"`
	AlarmChange *AlarmChange           `bson:"alarm_change" json:"alarm_change"`

	// Ticket related fields
	TicketInfo `bson:",inline"`

	// Tags contains external tags for alarm.
	Tags map[string]string `bson:"tags" json:"tags"`

	MetaAlarmRuleID    string `bson:"metaalarm_rule_id,omitempty" json:"metaalarm_rule_id,omitempty"`
	MetaAlarmValuePath string `bson:"metaalarm_value_path,omitempty" json:"metaalarm_value_path,omitempty"`

	MetaAlarmParents  []string `bson:"ma_parents,omitempty" json:"ma_parents,omitempty"`
	MetaAlarmChildren []string `bson:"ma_children,omitempty" json:"ma_children,omitempty"`

	// ManualMetaAlarmAutoResolve is used for manual meta alarms.
	ManualMetaAlarmAutoResolve bool `bson:"manual_meta_alarm_auto_resolve,omitempty" json:"manual_meta_alarm_auto_resolve,omitempty"`
	// DisplayName is used for manual meta alarms.
	DisplayName string `bson:"display_name,omitempty" json:"display_name,omitempty"`

	PbehaviorInfo PbehaviorInfo `bson:"pbehavior_info" json:"pbehavior_info"`

	// Initiator is used to detect who emits event.
	// InitiatorUser - UI
	// InitiatorSystem - engines
	// InitiatorExternal - third tool
	Initiator string `bson:"initiator" json:"initiator"`

	// Only for EventTypeRunDelayedScenario
	DelayedScenarioID   string `bson:"delayed_scenario_id,omitempty" json:"delayed_scenario_id,omitempty"`
	DelayedScenarioData string `bson:"delayed_scenario_data,omitempty" json:"delayed_scenario_data,omitempty"`

	// AddedToServices contains ids of entity services to which entity has been added as dependency.
	AddedToServices []string `bson:"added_to_services,omitempty" json:"added_to_services,omitempty"`
	// RemovedFromServices contains ids of entity services from which entity has been removed as dependency.
	RemovedFromServices []string `bson:"removed_from_services,omitempty" json:"removed_from_services,omitempty"`

	// IdleRuleApply is used if event is emitted by idle rule.
	IdleRuleApply string `bson:"idle_rule_apply,omitempty" json:"idle_rule_apply,omitempty"`

	// Execution is used only for instruction events: EventTypeInstructionStarted, EventTypeInstructionCompleted, etc..
	Execution string `bson:"execution,omitempty" json:"execution,omitempty"`

	// Instruction is used only for manual instructions kpi metrics
	Instruction string `bson:"instruction,omitempty" json:"instruction,omitempty"`

	// IsMetaAlarmUpdated is true if an alarm is added to a meta alarm on an event.
	IsMetaAlarmUpdated bool `bson:"ma_updated,omitempty" json:"ma_updated,omitempty"`
	// IsInstructionMatched is true if an alarm is matched to an auto instruction on an event.
	IsInstructionMatched bool `bson:"instr_matched,omitempty" json:"instr_matched,omitempty"`

	Healthcheck bool `bson:"healthcheck,omitempty" json:"healthcheck,omitempty"`

	StateSettingUpdated bool `bson:"state_setting_updated,omitempty" json:"state_setting_updated,omitempty"`
}

Event represents a canopsis event.

func (*Event) DetectSourceType

func (e *Event) DetectSourceType() string

func (*Event) Format

func (e *Event) Format()

Format an event

"timestamp" is fill with time.Now()
"event_type" is fill with EventTypeCheck

func (*Event) GetCompatRK

func (e *Event) GetCompatRK() string

GetCompatRK returns the event routing key. For compatibility only with old engines.

func (*Event) GetEID

func (e *Event) GetEID() string

GetEID generates an eid from an event

func (*Event) GetExtraInfoVal

func (e *Event) GetExtraInfoVal(f string) (interface{}, bool)

GetExtraInfoVal is a magic getter for extra infos fields for easier field retrieving when matching event pattern

func (*Event) GetIntField

func (e *Event) GetIntField(f string) (int64, bool)

GetIntField is a magic getter for int fields for easier field retrieving when matching event pattern

func (*Event) GetLockID

func (e *Event) GetLockID() string

GetLockID returns lock name that used to block alarm

func (*Event) GetPerfData

func (e *Event) GetPerfData() []PerfData

func (*Event) GetRequiredKeys

func (e *Event) GetRequiredKeys() []string

GetRequiredKeys read all declared json tags in the struct

func (*Event) GetStringField

func (e *Event) GetStringField(f string) (string, bool)

GetStringField is a magic getter for string fields for easier field retrieving when matching event pattern

func (*Event) InjectExtraInfos

func (e *Event) InjectExtraInfos(source []byte) error

InjectExtraInfos takes the raw JSON event document and puts any unknown field into Event.ExtraInfos

func (*Event) IsContextable

func (e *Event) IsContextable() bool

IsContextable tells you if the given event can lead to context enrichment.

func (*Event) IsMatched

func (e *Event) IsMatched(regex string, fields []string) bool

IsMatched tell if an event is catched by a regex

func (*Event) IsOnlyServiceUpdate

func (e *Event) IsOnlyServiceUpdate() bool

func (*Event) IsPbehaviorEvent

func (e *Event) IsPbehaviorEvent() bool

func (*Event) IsValid

func (e *Event) IsValid() error

IsValid checks if an Event is valid for Canopsis processing.

func (Event) MarshalEasyJSON

func (v Event) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*Event) SetField

func (e *Event) SetField(name string, value interface{}) (err error)

SetField sets the value of a field of an event given its name.

func (*Event) UnmarshalEasyJSON

func (v *Event) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type Exdate

type Exdate struct {
	Begin datetime.CpsTime `bson:"begin" json:"begin" swaggertype:"integer"`
	End   datetime.CpsTime `bson:"end" json:"end" swaggertype:"integer"`
}

type GenericEvent

type GenericEvent struct {
	Content interface{}
}

GenericEvent contains an interface so you can do this: body := `<a json document>` var gevent GenericEvent json.Unmarshal(body, &gevent.Content) gevent.PartialID(<rules>)

func (*GenericEvent) JSONUnmarshal

func (e *GenericEvent) JSONUnmarshal(body []byte) error

JSONUnmarshal is a shortcut for this: var event GenericEvent json.Unmarshal(body, &event.Content)

type Info

type Info struct {
	Name        string      `bson:"name,omitempty" json:"name"`
	Description string      `bson:"description,omitempty" json:"description"`
	Value       interface{} `bson:"value,omitempty" json:"value"`
}

Info contain extra values for the entity

type MetaAlarmInactiveDelay

type MetaAlarmInactiveDelay struct {
	ID      string           `bson:"_id"`
	Expired datetime.CpsTime `bson:"expired"`
}

type OptionalBool

type OptionalBool struct {
	// Set is a boolean indicating whether the value was set or not.
	Set bool

	// Value contains the value of the bool. It should only be taken into
	// account if Set is true.
	Value bool
}

OptionalBool is a wrapper around bool that implements the bson.Setter interface.

Using this type instead of bool in a struct allows to :

  • check whether the value was set or not in the bson document.
  • raise an error when trying to unmarshal a value that is not an integer.

Note that when trying to unmarshal a value that is not a bool, UnmarshalBSONValue will raise an error that will not be handled by bson.Unmarshal. If this error is not handled in the UnmarshalBSONValue method of an ancestor, calls to MongoDB queries may fail.

func (OptionalBool) MarshalBSONValue

func (s OptionalBool) MarshalBSONValue() (bsontype.Type, []byte, error)

func (*OptionalBool) UnmarshalBSONValue

func (s *OptionalBool) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

type OptionalInt64

type OptionalInt64 struct {
	// Set is a boolean indicating whether the value was set or not.
	Set bool

	// Value contains the value of the int64. It should only be taken into
	// account if Set is true.
	Value int64
}

OptionalInt64 is a wrapper around int64 that implements the bson.Setter interface.

Using this type instead of int64 in a struct allows to :

  • check whether the value was set or not in the bson document.
  • raise an error when trying to unmarshal a value that is not an integer.

Note that when trying to unmarshal a value that is not an integer, UnmarshalBSONValue will raise an error that will not be handled by bson.Unmarshal. If this error is not handled in the UnmarshalBSONValue method of an ancestor, calls to MongoDB queries may fail.

func (OptionalInt64) MarshalBSONValue

func (i OptionalInt64) MarshalBSONValue() (bsontype.Type, []byte, error)

func (*OptionalInt64) UnmarshalBSONValue

func (i *OptionalInt64) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

type OptionalInterface

type OptionalInterface struct {
	// Set is a boolean indicating whether the value was set or not.
	Set bool

	// Value contains the value of the interface{}. It should only be taken
	// into account if Set is true.
	Value interface{}
}

OptionalInterface is a wrapper around interface{} that implements the bson.Setter interface.

Using this type instead of interface{} in a struct allows to check whether the value was set or not in the bson document.

func (OptionalInterface) MarshalBSONValue

func (i OptionalInterface) MarshalBSONValue() (bsontype.Type, []byte, error)

func (*OptionalInterface) UnmarshalBSONValue

func (i *OptionalInterface) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

type OptionalRegexp

type OptionalRegexp struct {
	// Set is a boolean indicating whether the value was set or not.
	Set bool

	// Value contains the value of the regular expression. It should only be
	// taken into account if Set is true.
	Value utils.RegexExpression
}

OptionalRegexp is a wrapper around regexp.Regexp that implements the bson.Setter interface.

Using this type in a struct allows to :

  • check whether the value was set or not in the bson document.
  • automatically compile a regular expression.
  • raise an error when trying to unmarshal a value that is not a valid regular expression.

Note that when trying to unmarshal a value that is not a valid regular expression, UnmarshalBSONValue will raise an error that will not be handled by bson.Unmarshal. If this error is not handled in the UnmarshalBSONValue method of an ancestor, calls to MongoDB queries may fail.

func (OptionalRegexp) MarshalBSONValue

func (r OptionalRegexp) MarshalBSONValue() (bsontype.Type, []byte, error)

func (*OptionalRegexp) UnmarshalBSONValue

func (r *OptionalRegexp) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

type OptionalString

type OptionalString struct {
	// Set is a boolean indicating whether the value was set or not.
	Set bool

	// Value contains the value of the string. It should only be taken into
	// account if Set is true.
	Value string
}

OptionalString is a wrapper around string that implements the bson.Setter interface.

Using this type instead of string in a struct allows to :

  • check whether the value was set or not in the bson document.
  • raise an error when trying to unmarshal a value that is not an integer.

Note that when trying to unmarshal a value that is not a string, UnmarshalBSONValue will raise an error that will not be handled by bson.Unmarshal. If this error is not handled in the UnmarshalBSONValue method of an ancestor, calls to MongoDB queries may fail.

func (OptionalString) MarshalBSONValue

func (s OptionalString) MarshalBSONValue() (bsontype.Type, []byte, error)

func (*OptionalString) UnmarshalBSONValue

func (s *OptionalString) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

type OptionalStringArray

type OptionalStringArray struct {
	Set   bool
	Value []string
}

func (OptionalStringArray) MarshalBSONValue

func (a OptionalStringArray) MarshalBSONValue() (bsontype.Type, []byte, error)

func (*OptionalStringArray) UnmarshalBSONValue

func (a *OptionalStringArray) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

type PbehaviorInfo

type PbehaviorInfo struct {
	// Timestamp is time when entity enters pbehavior.
	// Use pointer of CpsTime to unmarshal null and undefined to nil pointer instead of zero CpsTime.
	Timestamp *datetime.CpsTime `bson:"timestamp" json:"timestamp" swaggertype:"integer"`
	// ID is ID of pbehavior.PBehavior.
	ID string `bson:"id" json:"id"`
	// Name is Name of pbehavior.PBehavior.
	Name string `bson:"name" json:"name"`
	// ReasonName is Name of pbehavior.Reason.
	ReasonName string `bson:"reason_name" json:"reason_name"`
	// ReasonID is ID of pbehavior.Reason.
	ReasonID string `bson:"reason" json:"reason"`
	// TypeID is ID of pbehavior.Type.
	TypeID string `bson:"type" json:"type"`
	// TypeName is Name of pbehavior.Type.
	TypeName string `bson:"type_name" json:"type_name"`
	// CanonicalType is Type of pbehavior.Type.
	CanonicalType string `bson:"canonical_type" json:"canonical_type"`
}

PbehaviorInfo represents current state of entity.

func (*PbehaviorInfo) GetStringField

func (i *PbehaviorInfo) GetStringField(f string) (string, bool)

GetStringField is a magic getter for string fields for easier field retrieving when matching pbehavior info pattern

func (*PbehaviorInfo) Is

func (i *PbehaviorInfo) Is(t string) bool

func (*PbehaviorInfo) IsActive

func (i *PbehaviorInfo) IsActive() bool

func (*PbehaviorInfo) IsDefaultActive

func (i *PbehaviorInfo) IsDefaultActive() bool

func (PbehaviorInfo) IsZero

func (i PbehaviorInfo) IsZero() bool

func (*PbehaviorInfo) OneOf

func (i *PbehaviorInfo) OneOf(t []string) bool

func (PbehaviorInfo) Same

func (i PbehaviorInfo) Same(v PbehaviorInfo) bool

type PerfData

type PerfData struct {
	Name  string
	Value float64
	Unit  string
}

type StateInfo

type StateInfo struct {
	ID               string          `bson:"_id" json:"_id"`
	InheritedPattern *pattern.Entity `bson:"inherited_pattern,omitempty" json:"inherited_pattern,omitempty"`
}

type TicketInfo

type TicketInfo struct {
	Ticket            string            `bson:"ticket,omitempty" json:"ticket,omitempty"`
	TicketURL         string            `bson:"ticket_url,omitempty" json:"ticket_url,omitempty"`
	TicketComment     string            `bson:"ticket_comment,omitempty" json:"ticket_comment,omitempty"`
	TicketSystemName  string            `bson:"ticket_system_name,omitempty" json:"ticket_system_name,omitempty"`
	TicketMetaAlarmID string            `bson:"ticket_meta_alarm_id,omitempty" json:"ticket_meta_alarm_id,omitempty"`
	TicketRuleID      string            `bson:"ticket_rule_id,omitempty" json:"ticket_rule_id,omitempty"`
	TicketRuleName    string            `bson:"ticket_rule_name,omitempty" json:"ticket_rule_name,omitempty"`
	TicketData        map[string]string `bson:"ticket_data,omitempty" json:"ticket_data,omitempty"`
}

func (TicketInfo) GetStepMessage

func (t TicketInfo) GetStepMessage() string

Jump to

Keyboard shortcuts

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