Documentation ¶
Index ¶
- Constants
- func AlarmID(connector, connectorName, entityID string) string
- func AsInteger(value interface{}) (int64, bool)
- func GenDisplayName(tpl *template.Template) string
- func InterfaceToString(v interface{}) (string, error)
- func InterfaceToStringSlice(v interface{}) ([]string, error)
- func ResolveSnoozeAfterPbhLeave(timestamp CpsTime, alarm *Alarm)
- type ActionPBehaviorParameters
- type Alarm
- func (a *Alarm) Ack(event Event) AlarmStep
- func (a *Alarm) Activate()
- func (a Alarm) AlarmComponentID() string
- func (a Alarm) AlarmID() string
- func (a *Alarm) ApplyActions(steps AlarmSteps, ticket *AlarmTicket) (done bool, err error)
- func (a *Alarm) AssocTicket(event Event) AlarmStep
- func (a Alarm) CacheID() string
- func (a *Alarm) Cancel(event Event) AlarmStep
- func (a *Alarm) ChangeState(event Event) AlarmStep
- func (a *Alarm) CleanUpdate()
- func (a Alarm) Closable(baggotTime time.Duration) bool
- func (a *Alarm) Comment(event Event) AlarmStep
- func (a *Alarm) ComputeStatus(alarmConfig config.AlarmConfig) CpsNumber
- func (a *Alarm) CropSteps() bool
- func (a *Alarm) CurrentState() CpsNumber
- func (a *Alarm) CurrentStatus(alarmConfig config.AlarmConfig) CpsNumber
- func (a *Alarm) DeclareTicket(event Event) AlarmStep
- func (a *Alarm) Done(event Event) AlarmStep
- func (a *Alarm) GetAppliedActions() (steps AlarmSteps, ticket *AlarmTicket)
- func (a *Alarm) GetUpdate() bson.M
- func (a Alarm) HasChildByEID(childEID string) bool
- func (a Alarm) HasSingleAck() bool
- func (a Alarm) IsAck() bool
- func (a Alarm) IsActivated() bool
- func (a Alarm) IsCanceled() bool
- func (a Alarm) IsFlapping(alarmConfig config.AlarmConfig) bool
- func (a Alarm) IsInActivePeriod() bool
- func (a Alarm) IsMalfunctioning() bool
- func (a Alarm) IsMatched(regex string, fields []string) bool
- func (a Alarm) IsMetaAlarm() bool
- func (a Alarm) IsMetaChildren() bool
- func (a *Alarm) IsResolved() bool
- func (a Alarm) IsSnoozed() bool
- func (a *Alarm) IsStateLocked() bool
- func (a Alarm) IsStealthy(alarmConfig config.AlarmConfig) bool
- func (a *Alarm) PartialUpdateAck(timestamp CpsTime, author, output, role, initiator string) error
- func (a *Alarm) PartialUpdateActivate(timestamp CpsTime) error
- func (a *Alarm) PartialUpdateAddStep(stepType string, timestamp CpsTime, author, msg, role, initiator string) error
- func (a *Alarm) PartialUpdateAssocTicket(timestamp CpsTime, author, ticketNumber, role, initiator string) error
- func (a *Alarm) PartialUpdateCancel(timestamp CpsTime, author, output, role, initiator string, ...) error
- func (a *Alarm) PartialUpdateChangeState(state CpsNumber, timestamp CpsTime, author, output, role, initiator string) error
- func (a *Alarm) PartialUpdateComment(timestamp CpsTime, author, output, role, initiator string) error
- func (a *Alarm) PartialUpdateCropSteps()
- func (a *Alarm) PartialUpdateDeclareTicket(timestamp CpsTime, author, output, ticketNumber string, data map[string]string, ...) error
- func (a *Alarm) PartialUpdateDone(timestamp CpsTime, author, output, role, initiator string) error
- func (a *Alarm) PartialUpdateEventsCount()
- func (a *Alarm) PartialUpdateLastEventDate(timestamp CpsTime)
- func (a *Alarm) PartialUpdateNoEvents(state CpsNumber, timestamp CpsTime, author, output, role, initiator string, ...) error
- func (a *Alarm) PartialUpdatePbhEnter(timestamp CpsTime, pbehaviorInfo PbehaviorInfo, ...) error
- func (a *Alarm) PartialUpdatePbhLeave(timestamp CpsTime, author, output, role, initiator string) error
- func (a *Alarm) PartialUpdatePbhLeaveAndEnter(timestamp CpsTime, pbehaviorInfo PbehaviorInfo, ...) error
- func (a *Alarm) PartialUpdateResolve(timestamp CpsTime) error
- func (a *Alarm) PartialUpdateSnooze(timestamp CpsTime, duration CpsNumber, author, output, role, initiator string) error
- func (a *Alarm) PartialUpdateState(timestamp CpsTime, state CpsNumber, output string, ...) error
- func (a *Alarm) PartialUpdateStatus(timestamp CpsTime, output string, alarmConfig config.AlarmConfig) error
- func (a *Alarm) PartialUpdateUnack(timestamp CpsTime, author, output, role, initiator string) error
- func (a *Alarm) PartialUpdateUncancel(timestamp CpsTime, author, output, role, initiator string, ...) error
- func (a *Alarm) PartialUpdateUnsnooze() error
- func (a *Alarm) PbhEnter(event Event) AlarmStep
- func (a *Alarm) PbhLeave(event Event) AlarmStep
- func (a *Alarm) Resolve(timestamp *CpsTime)
- func (a *Alarm) ResolveCancel(timestamp *CpsTime)
- func (a *Alarm) Snooze(timestamp CpsTime, duration CpsNumber, author, output, role, initiator string) (AlarmStep, error)
- func (a *Alarm) SnoozeFromEvent(event Event) (AlarmStep, error)
- func (a *Alarm) Ticket(stepType string, timestamp CpsTime, author string, ticketNumber string, ...) AlarmStep
- func (a *Alarm) UnSnooze()
- func (a *Alarm) Unack(event Event) AlarmStep
- func (a *Alarm) Uncancel(event Event) AlarmStep
- func (a *Alarm) Update(e Event, alarmConfig config.AlarmConfig) bool
- func (a *Alarm) UpdateLongOutput(newOutput string)
- func (a *Alarm) UpdateOutput(newOutput string)
- func (a *Alarm) UpdateState(stateValue CpsNumber, ts CpsTime)
- func (a *Alarm) UpdateStatus(timestamp CpsTime, author, message string, alarmConfig config.AlarmConfig) bool
- type AlarmChange
- type AlarmChangeType
- type AlarmStep
- func NewAlarmStep(stepType string, timestamp CpsTime, author string, msg string, role string, ...) AlarmStep
- func NewAlarmStepFromAction(stepType string, event Event) AlarmStep
- func NewAlarmStepFromEvent(stepType string, event Event) AlarmStep
- func NewMetaAlarmAttachStep(metaAlarm Alarm, ruleName string) AlarmStep
- type AlarmSteps
- func (s *AlarmSteps) Add(step AlarmStep) error
- func (s AlarmSteps) Crop(currentStatus *AlarmStep, cropNum int) (AlarmSteps, bool)
- func (s AlarmSteps) Last() (AlarmStep, error)
- func (s AlarmSteps) Len() int
- func (s AlarmSteps) Swap(i, j int)
- func (s AlarmSteps) UpdateStateCounter(currentStatus *AlarmStep, currentStatusIdx int, counter CropCounter) AlarmSteps
- type AlarmTicket
- type AlarmValue
- type AlarmWithEntity
- type ByTimestamp
- type ContextInformation
- type CpsDuration
- func (t CpsDuration) Duration() time.Duration
- func (t CpsDuration) MarshalBSONValue() (bsontype.Type, []byte, error)
- func (t CpsDuration) MarshalJSON() ([]byte, error)
- func (t *CpsDuration) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error
- func (t *CpsDuration) UnmarshalJSON(b []byte) error
- type CpsNumber
- type CpsShortDuration
- func (t CpsShortDuration) Duration() time.Duration
- func (t CpsShortDuration) MarshalBSONValue() (bsontype.Type, []byte, error)
- func (t CpsShortDuration) MarshalJSON() ([]byte, error)
- func (t CpsShortDuration) String() string
- func (t *CpsShortDuration) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error
- func (t *CpsShortDuration) UnmarshalJSON(b []byte) error
- type CpsTime
- type CropCounter
- type DedupList
- func (i *DedupList) Add(items ...string)
- func (i *DedupList) Del(items ...string)
- func (i *DedupList) EnsureInitialized()
- func (i DedupList) Exists(item string) bool
- func (i DedupList) List() []string
- func (i DedupList) Map() map[string]bool
- func (i DedupList) MarshalBinary() ([]byte, error)
- func (i DedupList) MarshalJSON() ([]byte, error)
- func (i *DedupList) UnmarshalBinary(in []byte) error
- func (i *DedupList) UnmarshalJSON(in []byte) error
- type DurationWithEnabled
- type DurationWithUnit
- type Entity
- type Event
- func (e *Event) DetectSourceType() string
- func (e *Event) Format()
- func (e *Event) GenerateContextInformations() []ContextInformation
- func (e *Event) GetCompatRK() string
- func (e *Event) GetEID() string
- func (e *Event) GetLockID() string
- func (e *Event) GetRequiredKeys() []string
- func (e *Event) InjectExtraInfos(source []byte) error
- func (e Event) IsContextable() bool
- func (e Event) IsMatched(regex string, fields []string) bool
- func (e *Event) IsPbehaviorEvent() bool
- func (e Event) IsValid() error
- func (e *Event) SetField(name string, value interface{}) (err error)
- type GenericEvent
- type Info
- type Operation
- type OperationAssocTicketParameters
- type OperationChangeStateParameters
- type OperationDeclareTicketParameters
- type OperationParameters
- type OperationPbhParameters
- type OperationSnoozeParameters
- type PbehaviorInfo
- type PerfData
- type RPCAxeEvent
- type RPCAxeResultEvent
- type RPCError
- type RPCPBehaviorEvent
- type RPCPBehaviorResultEvent
- type RPCServiceEvent
- type RPCServiceResultEvent
- type RPCWebhookEvent
- type RPCWebhookResultEvent
- type Templater
- type WebhookBasicAuth
- type WebhookDeclareTicket
- type WebhookParameters
- type WebhookRequest
Constants ¶
const ( ActionTypeAck = EventTypeAck ActionTypeAckRemove = EventTypeAckremove ActionTypeAssocTicket = EventTypeAssocTicket ActionTypeCancel = EventTypeCancel ActionTypeChangeState = EventTypeChangestate ActionTypeSnooze = EventTypeSnooze ActionTypePbehavior = "pbehavior" ActionTypeWebhook = "webhook" )
const ( AlarmStepCropMinStates = 20 AlarmStepsHardLimit = 2000 )
Alarm consts
const ( InitiatorUser = "user" InitiatorSystem = "system" InitiatorExternal = "external" )
event initiators
const ( SourceTypeResource = "resource" SourceTypeComponent = "component" SourceTypeConnector = "connector" SourceTypeService = "service" SourceTypeMetaAlarm = "metaalarm" )
Source types
const ( EventTypeAck = "ack" EventTypeAckremove = "ackremove" EventTypeAssocTicket = "assocticket" EventTypeCalendar = "calendar" EventTypeCancel = "cancel" EventTypeCheck = "check" EventTypeComment = "comment" EventTypeConsolidation = "consolidation" // EventTypeDeclareTicket is used for manual declareticket trigger which is designed // to trigger webhook with declare ticket parameter. EventTypeDeclareTicket = "declareticket" // EventTypeDeclareTicketWebhook is triggered after declare ticket creation by webhook. EventTypeDeclareTicketWebhook = "declareticketwebhook" EventTypeDone = "done" EventTypeDowntime = "downtime" EventTypeEue = "eue" EventTypeLog = "log" EventTypeChangestate = "changestate" EventTypeKeepstate = "keepstate" EventTypePBehavior = "pbehavior" EventTypePerf = "perf" EventTypeSelector = "selector" EventTypeSLA = "sla" EventTypeSnooze = "snooze" EventTypeUnsnooze = "unsnooze" EventTypeTrap = "trap" EventTypeStatCounterInc = "statcounterinc" EventTypeStatDuration = "statduration" EventTypeStatStateInterval = "statstateinterval" EventTypeUncancel = "uncancel" EventTypeUser = "user" EventTypeMetaAlarm = "metaalarm" EventTypeMetaAlarmUpdated = "metaalarmupdated" EventTypePbhEnter = "pbhenter" EventTypePbhLeaveAndEnter = "pbhleaveandenter" EventTypePbhLeave = "pbhleave" EventTypePbhCreate = "pbhcreate" EventTypeResolveDone = "resolve_done" EventTypeResolveCancel = "resolve_cancel" EventTypeResolveClose = "resolve_close" EventTypeUpdateStatus = "updatestatus" EventManualMetaAlarmGroup = "manual_metaalarm_group" EventManualMetaAlarmUngroup = "manual_metaalarm_ungroup" EventManualMetaAlarmUpdate = "manual_metaalarm_update" EventTypeActivate = "activate" EventTypeRunDelayedScenario = "run_delayed_scenario" EventTypeInstructionStarted = "instructionstarted" EventTypeInstructionPaused = "instructionpaused" EventTypeInstructionResumed = "instructionresumed" EventTypeInstructionCompleted = "instructioncompleted" EventTypeInstructionAborted = "instructionaborted" EventTypeInstructionFailed = "instructionfailed" EventTypeInstructionJobStarted = "instructionjobstarted" EventTypeInstructionJobCompleted = "instructionjobcompleted" EventTypeInstructionJobAborted = "instructionjobaborted" EventTypeInstructionJobFailed = "instructionjobfailed" // EventTypeRecomputeEntityService is used to recompute service context graph and state. EventTypeRecomputeEntityService = "recomputeentityservice" // EventTypeUpdateEntityService is used to update service cache in engines. EventTypeUpdateEntityService = "updateentityservice" // 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" // EventTypeAlarmSkipped is used to check alarm in service counters if alarm was skipped // during service recompute. EventTypeAlarmSkipped = "alarmskipped" // 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" EventTypeStateIncrease = "stateinc" EventTypeStateDecrease = "statedec" EventTypeStatusIncrease = "statusinc" EventTypeStatusDecrease = "statusdec" // EventTypeNoEvents is used to create alarm for entity by idle rule. EventTypeNoEvents = "noevents" )
Event types
const ( ConnectorEngineService = "service" ConnectorJunit = "junit" )
const ( AlarmStateOK = iota AlarmStateMinor AlarmStateMajor AlarmStateCritical AlarmStateUnknown )
Alarm states
const ( AlarmStateTitleOK = "ok" AlarmStateTitleMinor = "minor" AlarmStateTitleMajor = "major" AlarmStateTitleCritical = "critical" )
const ( AlarmStatusOff = iota AlarmStatusOngoing AlarmStatusStealthy AlarmStatusFlapping AlarmStatusCancelled AlarmStatusNoEvents )
Alarm statuses
const ( AlarmStatusTitleOff = "off" AlarmStatusTitleOngoing = "ongoing" AlarmStatusTitleStealthy = "stealthy" AlarmStatusTitleFlapping = "flapping" AlarmStatusTitleCancelled = "cancelled" )
const ( AlarmStepStateIncrease = "stateinc" AlarmStepStateDecrease = "statedec" AlarmStepStatusIncrease = "statusinc" AlarmStepStatusDecrease = "statusdec" AlarmStepAck = "ack" AlarmStepAckRemove = "ackremove" AlarmStepCancel = "cancel" AlarmStepUncancel = "uncancel" AlarmStepComment = "comment" AlarmStepDone = "done" AlarmStepDeclareTicket = "declareticket" AlarmStepAssocTicket = "assocticket" AlarmStepSnooze = "snooze" AlarmStepPbehavior = "pbehavior" AlarmStepStateCounter = "statecounter" AlarmStepChangeState = "changestate" AlarmStepPbhEnter = "pbhenter" AlarmStepPbhLeave = "pbhleave" AlarmStepMetaAlarmAttach = "metaalarmattach" AlarmStepInstructionStart = "instructionstart" AlarmStepInstructionPause = "instructionpause" AlarmStepInstructionResume = "instructionresume" AlarmStepInstructionComplete = "instructioncomplete" AlarmStepInstructionAbort = "instructionabort" AlarmStepInstructionFail = "instructionfail" AlarmStepInstructionJobStart = "instructionjobstart" AlarmStepInstructionJobComplete = "instructionjobcomplete" AlarmStepInstructionJobAbort = "instructionjobabort" AlarmStepInstructionJobFail = "instructionjobfail" AlarmStepJunitTestSuiteUpdate = "junittestsuiteupdate" AlarmStepJunitTestCaseUpdate = "junittestcaseupdate" )
Alarm steps
const ( EntityTypeConnector = "connector" EntityTypeComponent = "component" EntityTypeResource = "resource" EntityTypeService = "service" EntityTypeMetaAlarm = "metaalarm" )
Entity types
const EntityDefaultImpactLevel = 1
const (
StepEngineCorrelationAuthor = "engine.correlation"
)
Variables ¶
This section is empty.
Functions ¶
func AsInteger ¶
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 InterfaceToString ¶
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 ¶
Types ¶
type ActionPBehaviorParameters ¶
type ActionPBehaviorParameters struct { Author string `bson:"author" json:"author"` Name string `bson:"name" json:"name"` Reason string `bson:"reason" json:"reason"` Type string `bson:"type" json:"type"` RRule string `bson:"rrule" json:"rrule"` Tstart *int64 `bson:"tstart,omitempty" json:"tstart,omitempty"` Tstop *int64 `bson:"tstop,omitempty" json:"tstop,omitempty"` StartOnTrigger *bool `bson:"start_on_trigger,omitempty" json:"start_on_trigger,omitempty" mapstructure:"start_on_trigger,omitempty"` Duration *struct { Seconds int64 `bson:"seconds" json:"seconds"` Unit string `bson:"unit" json:"unit"` } `bson:"duration,omitempty" json:"duration,omitempty"` }
func (*ActionPBehaviorParameters) Template ¶
func (p *ActionPBehaviorParameters) Template(data interface{}) error
type Alarm ¶
type Alarm struct { ID string `bson:"_id" json:"_id"` Time CpsTime `bson:"t" json:"t"` EntityID string `bson:"d" json:"d"` Value AlarmValue `bson:"v" json:"v"` // contains filtered or unexported fields }
Alarm represents an alarm document.
func NewAlarm ¶
func NewAlarm(event Event, alarmConfig config.AlarmConfig) (Alarm, error)
NewAlarm creates en new Alarm from an Event
func (Alarm) AlarmComponentID ¶
AlarmComponentID is like Alarm.AlarmID() but uses Alarm.Value.Component instead of Alarm.EntityID
func (*Alarm) ApplyActions ¶
func (a *Alarm) ApplyActions(steps AlarmSteps, ticket *AlarmTicket) (done bool, err error)
Apply actions (ACK, Snooze, AssocTicket, DeclareTicket) from steps to alarm
func (*Alarm) AssocTicket ¶
AssocTicket associate a ticket number to an alarm
func (*Alarm) ChangeState ¶
ChangeState force the state of an alarm
func (*Alarm) CleanUpdate ¶
func (a *Alarm) CleanUpdate()
CleanUpdate removes mongo updates. Call it after succeeded update.
func (Alarm) Closable ¶
Closable checks the last step for it's state to be OK for at least baggotTime. Reference time is time.Now() when this function is called.
func (*Alarm) ComputeStatus ¶
func (a *Alarm) ComputeStatus(alarmConfig config.AlarmConfig) CpsNumber
ComputeStatus of an Alarm from an Event
func (*Alarm) CropSteps ¶
CropSteps calls Crop() on Alarm.Value.Steps with alarm parameters. returns true if the alarm was modified.
func (*Alarm) CurrentState ¶
CurrentState returns the Current State of the Alarm
func (*Alarm) CurrentStatus ¶
func (a *Alarm) CurrentStatus(alarmConfig config.AlarmConfig) CpsNumber
CurrentStatus returns the Current status of the alarm
func (*Alarm) DeclareTicket ¶
DeclareTicket ask for a creation
func (*Alarm) GetAppliedActions ¶
func (a *Alarm) GetAppliedActions() (steps AlarmSteps, ticket *AlarmTicket)
GetAppliedActions fetches applied to alarm actions: ACK, Snooze, AssocTicket, DeclareTicket Result is in a sorted by timestamp AlarmSteps, ticket data when defined
func (Alarm) HasChildByEID ¶
func (Alarm) HasSingleAck ¶
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) IsActivated ¶
func (Alarm) IsFlapping ¶
func (a Alarm) IsFlapping(alarmConfig config.AlarmConfig) bool
IsFlapping check if an Alarm is currently flapping
func (Alarm) IsInActivePeriod ¶
func (Alarm) IsMetaAlarm ¶
func (Alarm) IsMetaChildren ¶
func (*Alarm) IsResolved ¶
IsResolved tell if an alarm has been resolved
func (*Alarm) IsStateLocked ¶
IsStateLocked checks that the Alarm is not Locked (by manual intervention for example)
func (Alarm) IsStealthy ¶
func (a Alarm) IsStealthy(alarmConfig config.AlarmConfig) bool
IsStealthy checks if an Alarm is currently stealthy
func (*Alarm) PartialUpdateAck ¶
PartialUpdateAck add ack step to alarm. It saves mongo updates.
func (*Alarm) PartialUpdateActivate ¶
func (*Alarm) PartialUpdateAddStep ¶
func (*Alarm) PartialUpdateAssocTicket ¶
func (a *Alarm) PartialUpdateAssocTicket(timestamp CpsTime, author, ticketNumber, role, initiator string) error
PartialUpdateAssocTicket add ticket to alarm. It saves mongo updates.
func (*Alarm) PartialUpdateCancel ¶
func (a *Alarm) PartialUpdateCancel(timestamp CpsTime, author, output, role, initiator string, alarmConfig config.AlarmConfig) error
PartialUpdateCancel add canceled and status change steps to alarm. It saves mongo updates.
func (*Alarm) PartialUpdateChangeState ¶
func (a *Alarm) PartialUpdateChangeState(state CpsNumber, timestamp CpsTime, author, output, role, initiator string) error
PartialUpdateChangeState add state change step to alarm. It saves mongo updates.
func (*Alarm) PartialUpdateComment ¶
func (*Alarm) PartialUpdateCropSteps ¶
func (a *Alarm) PartialUpdateCropSteps()
func (*Alarm) PartialUpdateDeclareTicket ¶
func (a *Alarm) PartialUpdateDeclareTicket(timestamp CpsTime, author, output, ticketNumber string, data map[string]string, role, initiator string) error
PartialUpdateDeclareTicket add ticket to alarm. It saves mongo updates.
func (*Alarm) PartialUpdateDone ¶
func (*Alarm) PartialUpdateEventsCount ¶
func (a *Alarm) PartialUpdateEventsCount()
func (*Alarm) PartialUpdateLastEventDate ¶
func (*Alarm) PartialUpdateNoEvents ¶
func (a *Alarm) PartialUpdateNoEvents(state CpsNumber, timestamp CpsTime, author, output, role, initiator string, alarmConfig config.AlarmConfig) error
PartialUpdateNoEvents add state step to alarm. It saves mongo updates.
func (*Alarm) PartialUpdatePbhEnter ¶
func (a *Alarm) PartialUpdatePbhEnter(timestamp CpsTime, pbehaviorInfo PbehaviorInfo, author, output, role, initiator string) error
func (*Alarm) PartialUpdatePbhLeave ¶
func (*Alarm) PartialUpdatePbhLeaveAndEnter ¶
func (a *Alarm) PartialUpdatePbhLeaveAndEnter(timestamp CpsTime, pbehaviorInfo PbehaviorInfo, author, output, role, initiator string) error
func (*Alarm) PartialUpdateResolve ¶
func (*Alarm) PartialUpdateSnooze ¶
func (a *Alarm) PartialUpdateSnooze(timestamp CpsTime, duration CpsNumber, author, output, role, initiator string) error
PartialUpdateSnooze add snooze step to alarm. It saves mongo updates.
func (*Alarm) PartialUpdateState ¶
func (*Alarm) PartialUpdateStatus ¶
func (*Alarm) PartialUpdateUnack ¶
PartialUpdateUnack deletes ack step from alarm. It saves mongo updates.
func (*Alarm) PartialUpdateUncancel ¶
func (*Alarm) PartialUpdateUnsnooze ¶
func (*Alarm) ResolveCancel ¶
ResolveCancel forces alarm resolution on cancel
func (*Alarm) Snooze ¶
func (a *Alarm) Snooze(timestamp CpsTime, duration CpsNumber, author, output, role, initiator string) (AlarmStep, error)
Snooze apply a snooze step to an Alarm
func (*Alarm) SnoozeFromEvent ¶
SnoozeFromEvent apply a snooze step to an Alarm
func (*Alarm) Ticket ¶
func (a *Alarm) Ticket(stepType string, timestamp CpsTime, author string, ticketNumber string, role string, data map[string]string, initiator string) AlarmStep
Ticket add a ticket on an alarm
func (*Alarm) Update ¶
func (a *Alarm) Update(e Event, alarmConfig config.AlarmConfig) bool
Update an alarm from an Event
func (*Alarm) UpdateLongOutput ¶
UpdateLongOutput updates an alarm output field
func (*Alarm) UpdateOutput ¶
UpdateOutput updates an alarm output field
func (*Alarm) UpdateState ¶
UpdateState updates alarm's state to stateValue if it worst
func (*Alarm) UpdateStatus ¶
func (a *Alarm) UpdateStatus(timestamp CpsTime, author, message string, alarmConfig config.AlarmConfig) bool
UpdateStatus recomputes the status of the alarm. If the status changes, a new step is added to the alarm, with the timestamp, author and message given in parameters.
type AlarmChange ¶
type AlarmChange struct { Type AlarmChangeType PreviousState CpsNumber PreviousStateChange CpsTime PreviousStatus CpsNumber PreviousStatusChange CpsTime PreviousPbehaviorTypeID string PreviousPbehaviorCannonicalType string }
AlarmChange is a struct containing the type of change that occured on an alarm, as well as its previous state.
func NewAlarmChange ¶
func NewAlarmChange() AlarmChange
func (*AlarmChange) GetTriggers ¶
func (ac *AlarmChange) GetTriggers() []string
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" AlarmChangeTypeAckremove AlarmChangeType = "ackremove" AlarmChangeTypeCancel AlarmChangeType = "cancel" AlarmChangeTypeUncancel AlarmChangeType = "uncancel" AlarmChangeTypeAssocTicket AlarmChangeType = "assocticket" AlarmChangeTypeSnooze AlarmChangeType = "snooze" AlarmChangeTypeUnsnooze AlarmChangeType = "unsnooze" AlarmChangeTypeResolve AlarmChangeType = "resolve" AlarmChangeTypeDone AlarmChangeType = "done" AlarmChangeTypeComment AlarmChangeType = "comment" AlarmChangeTypeChangeState AlarmChangeType = "changestate" AlarmChangeTypePbhEnter AlarmChangeType = "pbhenter" AlarmChangeTypePbhLeave AlarmChangeType = "pbhleave" AlarmChangeTypePbhLeaveAndEnter AlarmChangeType = "pbhleaveandenter" AlarmChangeTypeUpdateStatus AlarmChangeType = "changestatus" AlarmChangeTypeActivate AlarmChangeType = "activate" // AlarmChangeTypeDeclareTicket is used for manual declareticket trigger which is designed // to trigger webhook with declare ticket parameter. AlarmChangeTypeDeclareTicket AlarmChangeType = "declareticket" // AlarmChangeTypeDeclareTicketWebhook is triggered after declare ticket creation by webhook. AlarmChangeTypeDeclareTicketWebhook AlarmChangeType = "declareticketwebhook" // Following consts are used for instruction. AlarmChangeTypeInstructionStart AlarmChangeType = "instructionstart" AlarmChangeTypeInstructionPause AlarmChangeType = "instructionpause" AlarmChangeTypeInstructionResume AlarmChangeType = "instructionresume" AlarmChangeTypeInstructionComplete AlarmChangeType = "instructioncomplete" AlarmChangeTypeInstructionAbort AlarmChangeType = "instructionabort" AlarmChangeTypeInstructionFail AlarmChangeType = "instructionfail" AlarmChangeTypeInstructionJobStart AlarmChangeType = "instructionjobstart" AlarmChangeTypeInstructionJobComplete AlarmChangeType = "instructionjobcomplete" AlarmChangeTypeInstructionJobAbort AlarmChangeType = "instructionjobabort" AlarmChangeTypeInstructionJobFail AlarmChangeType = "instructionjobfail" AlarmChangeTypeJunitTestSuiteUpdate AlarmChangeType = "junittestsuiteupdate" AlarmChangeTypeJunitTestCaseUpdate AlarmChangeType = "junittestcaseupdate" )
An AlarmChangeType can have the following values:
type AlarmStep ¶
type AlarmStep struct { Type string `bson:"_t" json:"_t"` Timestamp CpsTime `bson:"t" json:"t"` Author string `bson:"a" json:"a"` 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"` Initiator string `bson:"initiator,omitempty"` }
AlarmStep represents a generic step used in an alarm.
func NewAlarmStep ¶
func NewAlarmStep(stepType string, timestamp CpsTime, author string, msg string, role string, initiator string) AlarmStep
NewAlarmStep returns an AlarmStep. If the timestamp or author are empty, default values will be used to create an AlarmStep.
func NewAlarmStepFromAction ¶
func NewAlarmStepFromEvent ¶
NewAlarmStepFromEvent returns an AlarmStep.
func NewMetaAlarmAttachStep ¶
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 AlarmTicket ¶
type AlarmTicket struct { Type string `bson:"_t" json:"_t"` Timestamp CpsTime `bson:"t" json:"t"` Author string `bson:"a" json:"a"` Message string `bson:"m" json:"m"` Role string `bson:"role,omitempty" json:"role,omitempty"` Value string `bson:"val" json:"val"` Data map[string]string }
AlarmTicket step is distinct from generic alarm step because value is a string TODO: move string value to message (and in py and js too)
type AlarmValue ¶
type AlarmValue struct { ACK *AlarmStep `bson:"ack,omitempty" json:"ack,omitempty"` Canceled *AlarmStep `bson:"canceled,omitempty" json:"canceled,omitempty"` Done *AlarmStep `bson:"done,omitempty" json:"done,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"` Ticket *AlarmTicket `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 CpsTime `bson:"creation_date" json:"creation_date"` ActivationDate *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 CpsTime `bson:"last_update_date" json:"last_update_date"` LastEventDate CpsTime `bson:"last_event_date" json:"last_event_date"` Resource string `bson:"resource,omitempty" json:"resource,omitempty"` Resolved *CpsTime `bson:"resolved,omitempty" json:"resolved,omitempty"` PbehaviorInfo PbehaviorInfo `bson:"pbehavior_info,omitempty" json:"pbehavior_info,omitempty"` Tags []string `bson:"tags" json:"tags"` 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"` 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"` Extra map[string]interface{} `bson:"extra" json:"extra"` Infos map[string]map[string]interface{} `bson:"infos" json:"infos"` // store version of dynamic-infos rule RuleVersion map[string]string `bson:"infos_rule_version"` }
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 ContextInformation ¶
type ContextInformation struct { ID string // Entity ID Name string Type string Impacts []string Depends []string }
ContextInformation regroup context values necessary for creating a new entity
func (*ContextInformation) NewEntity ¶
func (ci *ContextInformation) NewEntity() Entity
NewEntity create an entity from ContextInformation struct
type CpsDuration ¶
CpsDuration allow conversions from/to time.Duration to/from string
func (CpsDuration) Duration ¶
func (t CpsDuration) Duration() time.Duration
Duration return the CpsDuration casted to time.Duration
func (CpsDuration) MarshalBSONValue ¶
func (t CpsDuration) MarshalBSONValue() (bsontype.Type, []byte, error)
MarshalBSONValue converts from CpsDuration to bytes
func (CpsDuration) MarshalJSON ¶
func (t CpsDuration) MarshalJSON() ([]byte, error)
MarshalJSON converts a CpsDuration to string
func (*CpsDuration) UnmarshalBSONValue ¶
func (t *CpsDuration) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error
UnmarshalBSONValue converts from bytes to CpsDuration
func (*CpsDuration) UnmarshalJSON ¶
func (t *CpsDuration) UnmarshalJSON(b []byte) error
UnmarshalJSON converts a string to CpsDuration
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 ¶
CpsTimestamp convert a number to a timestamp
func (CpsNumber) MarshalJSON ¶
MarshalJSON implements json.Encoder interface
func (*CpsNumber) UnmarshalJSON ¶
UnmarshalJSON implements json.Decoder interface
type CpsShortDuration ¶
type CpsShortDuration int64
CpsShortDuration allow conversions from/to time.Duration to/from string
func ParseCpsShortDuration ¶
func ParseCpsShortDuration(str string) (CpsShortDuration, error)
func (CpsShortDuration) Duration ¶
func (t CpsShortDuration) Duration() time.Duration
Duration return the CpsShortDuration casted to time.Duration
func (CpsShortDuration) MarshalBSONValue ¶
func (t CpsShortDuration) MarshalBSONValue() (bsontype.Type, []byte, error)
MarshalBSONValue converts from CpsShortDuration to bytes
func (CpsShortDuration) MarshalJSON ¶
func (t CpsShortDuration) MarshalJSON() ([]byte, error)
MarshalJSON converts a CpsDuration to string
func (CpsShortDuration) String ¶
func (t CpsShortDuration) String() string
func (*CpsShortDuration) UnmarshalBSONValue ¶
func (t *CpsShortDuration) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error
UnmarshalBSONValue converts from bytes to CpsShortDuration
func (*CpsShortDuration) UnmarshalJSON ¶
func (t *CpsShortDuration) UnmarshalJSON(b []byte) error
UnmarshalJSON converts a string to CpsShortDuration
type CpsTime ¶
CpsTime allows conversion from time.Time to time.Time.Unix()
func NewCpsTime ¶
NewCpsTime create a CpsTime from a timestamp
func (CpsTime) MarshalBSONValue ¶
MarshalBSONValue converts from CpsTime to timestamp as bytes
func (CpsTime) MarshalJSON ¶
MarshalJSON converts from CpsTime to timestamp as bytes
func (*CpsTime) UnmarshalBSONValue ¶
UnmarshalBSONValue converts from timestamp as bytes to CpsTime
func (*CpsTime) UnmarshalJSON ¶
UnmarshalJSON converts from string to CpsTime
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 DedupList ¶
type DedupList struct {
// contains filtered or unexported fields
}
DedupList is not to be used directly, use NewDedupList instead.
func NewDedupList ¶
NewDedupList creates a new DedupList struct.
func (*DedupList) Del ¶
Del some items from the list. This function is VERY slow, avoid making multiple calls since for each call if the DedupList has to be modified, the internal cached list is recomputed. Prefer call Del(items...) where items is a []string
func (*DedupList) EnsureInitialized ¶
func (i *DedupList) EnsureInitialized()
EnsureInitialized ensure internal states to be initialized
func (DedupList) Map ¶
Map returns a copy of the underlying map[string]bool The bool value has no meaning, it's only here so we can deduplicate using a standard map.
func (DedupList) MarshalBinary ¶
MarshalBinary ...
func (DedupList) MarshalJSON ¶
MarshalJSON implements json.Encoder
func (*DedupList) UnmarshalBinary ¶
UnmarshalBinary ...
func (*DedupList) UnmarshalJSON ¶
UnmarshalJSON implements json.Decoder
type DurationWithEnabled ¶
type DurationWithEnabled struct { DurationWithUnit `bson:",inline"` Enabled *bool `bson:"enabled" json:"enabled" binding:"required"` }
type DurationWithUnit ¶
type DurationWithUnit struct { Seconds int64 `bson:"seconds" json:"seconds" binding:"required,min=1"` Unit string `bson:"unit" json:"unit" binding:"required,oneof=s m h d w M y"` }
DurationWithUnit represent duration with user-preferred units
func (DurationWithUnit) Duration ¶
func (t DurationWithUnit) Duration() time.Duration
type Entity ¶
type Entity struct { ID string `bson:"_id" json:"_id"` Name string `bson:"name" json:"name"` Description string `bson:"description" json:"description"` Impacts []string `bson:"impact" json:"impact"` // impacted_services field is only for connectors, see entity service RecomputeIdleSince method ImpactedServices []string `bson:"impacted_services" json:"-"` Depends []string `bson:"depends" json:"depends"` EnableHistory []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"` Component string `bson:"component,omitempty" json:"component,omitempty"` Category string `bson:"category" json:"category"` ImpactLevel int64 `bson:"impact_level" json:"impact_level"` IsNew bool `bson:"-" json:"-"` AlarmsCumulativeData struct { // Only for Service. // WatchedCount is count of unresolved alarms. WatchedCount int64 `bson:"watched_count"` // WatchedPbheaviorCount contains counters of unresolved and in pbehavior alarms. WatchedPbheaviorCount map[string]int64 `bson:"watched_pbehavior_count"` // WatchedNotAckedCount is count of unresolved and not acked and active (by pbehavior) alarms. WatchedNotAckedCount int64 `bson:"watched_not_acked_count"` } `bson:"alarms_cumulative_data,omitempty" json:"-"` Created CpsTime `bson:"created" json:"created"` LastEventDate *CpsTime `bson:"last_event_date,omitempty" json:"last_event_date,omitempty"` // 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 *CpsTime `bson:"idle_since,omitempty" json:"idle_since,omitempty"` }
Entity ...
func NewEntity ¶
func NewEntity(id string, name string, entityType string, infos map[string]Info, impacts, depends []string) Entity
NewEntity instanciate a new entity struct [sic]
func (*Entity) EnsureInitialized ¶
func (e *Entity) EnsureInitialized()
EnsureInitialized verifies that all complex structs are well initialized
func (*Entity) GetUpsertMongoBson ¶
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"` PerfDataArray []PerfData `bson:"perf_data_array" json:"perf_data_array"` Status *CpsNumber `bson:"status" json:"status"` Timestamp CpsTime `bson:"timestamp" json:"timestamp"` StateType *CpsNumber `bson:"state_type" json:"state_type"` 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"` Author string `bson:"author" json:"author"` RK string `bson:"routing_key" json:"routing_key"` // AckResources is used to ack all resource alarms on ack component alarm. // It also adds declare ticket to all resource alarms on ack webhook. // It's still used by some old users but meta alarms must be used instead. AckResources bool `json:"ack_resources"` Duration *CpsNumber `json:"duration"` Ticket string `bson:"ticket" json:"ticket"` 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{} `json:"extra"` AlarmChange *AlarmChange `bson:"alarm_change" json:"alarm_change"` MetaAlarmRuleID string `bson:"metaalarm_rule_id" json:"metaalarm_rule_id"` MetaAlarmValuePath string `bson:"metaalarm_value_path" json:"metaalarm_value_path"` MetaAlarmParents *[]string `bson:"ma_parents" json:"ma_parents"` MetaAlarmChildren *[]string `bson:"ma_children" json:"ma_children"` 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"` // 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"` ExecutionTime time.Duration `bson:"execution_time" json:"execution_time"` // PbhParameters is used only with EventTypePbhCreate PbhParameters string `bson:"pbh_parameters,omitempty" json:"pbh_parameters,omitempty"` // IdleRuleApply is used if event is emitted by idle rule. IdleRuleApply string `bson:"idle_rule_apply,omitempty" json:"idle_rule_apply,omitempty"` }
Event represents a canopsis event.
func NewEventFromAlarm ¶
func NewEventFromJSON ¶
NewEventFromJSON create an Event from a raw json
func (*Event) DetectSourceType ¶
func (*Event) Format ¶
func (e *Event) Format()
Format an event
"timestamp" is fill with time.Now() "event_type" is fill with EventTypeCheck if "entity" is not null, "impacts" and "depends" are ensured to be initialized
func (*Event) GenerateContextInformations ¶
func (e *Event) GenerateContextInformations() []ContextInformation
GenerateContextInformations generate connector, component and resource entity informations. First element is always connector Second element is always component Third element doesnt exists if event is not SourceTypeResource, otherwise it is resource
func (*Event) GetCompatRK ¶
GetCompatRK returns the event routing key. For compatibility only with old engines.
func (*Event) GetRequiredKeys ¶
GetRequiredKeys read all declared json tags in the struct
func (*Event) InjectExtraInfos ¶
InjectExtraInfos takes the raw JSON event document and puts any unknown field into Event.ExtraInfos
func (Event) IsContextable ¶
IsContextable tells you if the given event can lead to context enrichment.
func (*Event) IsPbehaviorEvent ¶
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)
func (*GenericEvent) PartialID ¶
func (e *GenericEvent) PartialID(heartBeatItem heartbeat.Item) (string, error)
PartialID builds the event ID, as a string, from the heartBeatItem configuration. Given this event:
{ "connector": "zabbix", "connector_name": "instance1", "component": "localhost", ... }
And the given heartBeatItem:
li := NewHeartBeatItem(time.Minute*5) li.AddMapping("connector", "zabbix") li.AddMapping("connector_name", "instance1")
PartialID will return "connector:zabbix.connector_name:instance1" as ID. Keys will alphabetically sorted!
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 Operation ¶
type Operation struct { Type string `bson:"type"` Parameters interface{} `bson:"parameters,omitempty"` }
Operation represents alarm modification operation.
type OperationAssocTicketParameters ¶
type OperationAssocTicketParameters struct { Ticket string `bson:"ticket" json:"ticket"` Output string `bson:"output" json:"output"` Author string `bson:"author" json:"author"` }
func (*OperationAssocTicketParameters) Template ¶
func (p *OperationAssocTicketParameters) Template(data interface{}) error
type OperationChangeStateParameters ¶
type OperationChangeStateParameters struct { State CpsNumber `bson:"state" json:"state"` Output string `bson:"output" json:"output"` Author string `bson:"author" json:"author"` }
func (*OperationChangeStateParameters) Template ¶
func (p *OperationChangeStateParameters) Template(data interface{}) error
type OperationDeclareTicketParameters ¶
type OperationDeclareTicketParameters struct { Ticket string `bson:"ticket" json:"ticket"` Data map[string]string `bson:"data" json:"data"` Output string `bson:"output" json:"output"` Author string `bson:"author" json:"author"` }
func (*OperationDeclareTicketParameters) Template ¶
func (p *OperationDeclareTicketParameters) Template(data interface{}) error
type OperationParameters ¶
type OperationParameters struct { Output string `bson:"output" json:"output"` Author string `bson:"author" json:"author"` }
OperationParameters represents default operation parameters.
func (*OperationParameters) Template ¶
func (p *OperationParameters) Template(data interface{}) error
type OperationPbhParameters ¶
type OperationPbhParameters struct { PbehaviorInfo PbehaviorInfo `json:"pbehavior_info"` Output string `json:"output"` Author string `json:"author"` }
type OperationSnoozeParameters ¶
type OperationSnoozeParameters struct { Duration DurationWithUnit `bson:"duration" json:"duration"` Output string `bson:"output" json:"output"` Author string `bson:"author" json:"author"` }
func (*OperationSnoozeParameters) Template ¶
func (p *OperationSnoozeParameters) Template(data interface{}) error
type PbehaviorInfo ¶
type PbehaviorInfo struct { // ID is ID of pbehavior.PBehavior. ID string `bson:"id" json:"id"` // Name is Name of pbehavior.PBehavior. Name string `bson:"name" json:"name"` // Reason is Name of pbehavior.Reason. Reason 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) 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
type PerfData ¶
type PerfData struct { Metric string `bson:"metric" json:"metric"` Unit string `bson:"unit" json:"unit"` Value float64 `bson:"value" json:"value"` }
PerfData represents a perf data array
type RPCAxeEvent ¶
type RPCAxeEvent struct { EventType string `json:"event_type"` Parameters interface{} `json:"parameters,omitempty"` Alarm *Alarm `json:"alarm"` Entity *Entity `json:"entity"` }
func (*RPCAxeEvent) UnmarshalJSON ¶
func (e *RPCAxeEvent) UnmarshalJSON(b []byte) error
type RPCAxeResultEvent ¶
type RPCAxeResultEvent struct { Alarm *Alarm `json:"alarm"` AlarmChangeType AlarmChangeType `json:"alarm_change"` Error *RPCError `json:"error"` }
type RPCError ¶
type RPCError struct {
Error error
}
func (RPCError) MarshalJSON ¶
func (*RPCError) UnmarshalJSON ¶
type RPCPBehaviorEvent ¶
type RPCPBehaviorEvent struct { Alarm *Alarm `json:"alarm"` Entity *Entity `json:"entity"` Params ActionPBehaviorParameters `json:"params"` }
type RPCPBehaviorResultEvent ¶
type RPCServiceEvent ¶
type RPCServiceEvent struct { Alarm *Alarm `json:"alarm"` Entity *Entity `json:"entity"` AlarmChange *AlarmChange `json:"alarm_change"` }
type RPCServiceResultEvent ¶
type RPCServiceResultEvent struct {
Error *RPCError `json:"error"`
}
type RPCWebhookEvent ¶
type RPCWebhookResultEvent ¶
type WebhookBasicAuth ¶
type WebhookDeclareTicket ¶
type WebhookDeclareTicket struct { EmptyResponse bool `bson:"empty_response" json:"empty_response" mapstructure:"empty_response"` TicketID string `bson:"ticket_id" json:"ticket_id" mapstructure:"ticket_id"` IsRegexp bool `bson:"is_regexp" json:"is_regexp" mapstructure:"is_regexp"` Fields map[string]string `bson:",inline" mapstructure:",remain"` }
func (WebhookDeclareTicket) MarshalJSON ¶
func (t WebhookDeclareTicket) MarshalJSON() ([]byte, error)
func (*WebhookDeclareTicket) UnmarshalJSON ¶
func (t *WebhookDeclareTicket) UnmarshalJSON(b []byte) error
type WebhookParameters ¶
type WebhookParameters struct { Request WebhookRequest `bson:"request" json:"request"` DeclareTicket *WebhookDeclareTicket `bson:"declare_ticket,omitempty" json:"declare_ticket,omitempty" mapstructure:"declare_ticket,omitempty"` RetryCount int64 `bson:"retry_count,omitempty" json:"retry_count,omitempty" mapstructure:"retry_count"` RetryDelay *DurationWithUnit `bson:"retry_delay,omitempty" json:"retry_delay,omitempty" mapstructure:"retry_delay"` }
func (*WebhookParameters) Template ¶
func (p *WebhookParameters) Template(data interface{}) error
type WebhookRequest ¶
type WebhookRequest struct { URL string `bson:"url" json:"url"` Method string `bson:"method" json:"method"` Auth *WebhookBasicAuth `bson:"auth,omitempty" json:"auth,omitempty"` Headers map[string]string `bson:"headers,omitempty" json:"headers,omitempty"` Payload string `bson:"payload,omitempty" json:"payload,omitempty"` SkipVerify bool `bson:"skip_verify" json:"skip_verify" mapstructure:"skip_verify"` }