types

package
v0.0.0-...-d841f61 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: AGPL-3.0 Imports: 24 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
)

Alarm consts

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"
	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

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

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"
	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

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

Entity types

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

Variables

This section is empty.

Functions

func AlarmID

func AlarmID(connector, connectorName, entityID string) string

AlarmID build an alarmid from given parameters. Used by Alarm.AlarmID()

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 ResolveSnoozeAfterPbhLeave

func ResolveSnoozeAfterPbhLeave(timestamp CpsTime, alarm *Alarm)

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) Ack

func (a *Alarm) Ack(event Event) AlarmStep

Ack an alarm

func (*Alarm) Activate

func (a *Alarm) Activate()

func (Alarm) AlarmComponentID

func (a Alarm) AlarmComponentID() string

AlarmComponentID is like Alarm.AlarmID() but uses Alarm.Value.Component instead of Alarm.EntityID

func (Alarm) AlarmID

func (a Alarm) AlarmID() string

AlarmID returns current alarm's alarmid.

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

func (a *Alarm) AssocTicket(event Event) AlarmStep

AssocTicket associate a ticket number to an alarm

func (Alarm) CacheID

func (a Alarm) CacheID() string

CacheID implements cache.Cache interface

func (*Alarm) Cancel

func (a *Alarm) Cancel(event Event) AlarmStep

Cancel cancel an alarm

func (*Alarm) ChangeState

func (a *Alarm) ChangeState(event Event) AlarmStep

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

func (a Alarm) Closable(baggotTime time.Duration) bool

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) Comment

func (a *Alarm) Comment(event Event) AlarmStep

Comment comment an alarm

func (*Alarm) ComputeStatus

func (a *Alarm) ComputeStatus(alarmConfig config.AlarmConfig) CpsNumber

ComputeStatus of an Alarm from an Event

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) CurrentStatus

func (a *Alarm) CurrentStatus(alarmConfig config.AlarmConfig) CpsNumber

CurrentStatus returns the Current status of the alarm

func (*Alarm) DeclareTicket

func (a *Alarm) DeclareTicket(event Event) AlarmStep

DeclareTicket ask for a creation

func (*Alarm) Done

func (a *Alarm) Done(event Event) AlarmStep

Done mark an alarm as done

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) GetUpdate

func (a *Alarm) GetUpdate() bson.M

GetUpdate returns mongo updates from last update.

func (Alarm) HasChildByEID

func (a Alarm) HasChildByEID(childEID 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) 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) IsFlapping

func (a Alarm) IsFlapping(alarmConfig config.AlarmConfig) bool

IsFlapping check if an Alarm is currently flapping

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) IsMetaChildren

func (a Alarm) IsMetaChildren() 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) IsStealthy

func (a Alarm) IsStealthy(alarmConfig config.AlarmConfig) bool

IsStealthy checks if an Alarm is currently stealthy

func (*Alarm) PartialUpdateAck

func (a *Alarm) PartialUpdateAck(timestamp CpsTime, author, output, role, initiator string) error

PartialUpdateAck add ack step to alarm. It saves mongo updates.

func (*Alarm) PartialUpdateActivate

func (a *Alarm) PartialUpdateActivate(timestamp CpsTime) error

func (*Alarm) PartialUpdateAddStep

func (a *Alarm) PartialUpdateAddStep(stepType string, timestamp CpsTime, author, msg, role, initiator string) error

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 (a *Alarm) PartialUpdateComment(timestamp CpsTime, author, output, role, initiator string) error

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 (a *Alarm) PartialUpdateDone(timestamp CpsTime, author, output, role, initiator string) error

func (*Alarm) PartialUpdateEventsCount

func (a *Alarm) PartialUpdateEventsCount()

func (*Alarm) PartialUpdateLastEventDate

func (a *Alarm) PartialUpdateLastEventDate(timestamp CpsTime)

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 (a *Alarm) PartialUpdatePbhLeave(timestamp CpsTime, author, output, role, initiator string) error

func (*Alarm) PartialUpdatePbhLeaveAndEnter

func (a *Alarm) PartialUpdatePbhLeaveAndEnter(timestamp CpsTime, pbehaviorInfo PbehaviorInfo, author, output, role, initiator string) error

func (*Alarm) PartialUpdateResolve

func (a *Alarm) PartialUpdateResolve(timestamp CpsTime) error

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 (a *Alarm) PartialUpdateState(timestamp CpsTime, state CpsNumber, output string,
	alarmConfig config.AlarmConfig) error

func (*Alarm) PartialUpdateStatus

func (a *Alarm) PartialUpdateStatus(timestamp CpsTime, output string, alarmConfig config.AlarmConfig) error

func (*Alarm) PartialUpdateUnack

func (a *Alarm) PartialUpdateUnack(timestamp CpsTime, author, output, role, initiator string) error

PartialUpdateUnack deletes ack step from alarm. It saves mongo updates.

func (*Alarm) PartialUpdateUncancel

func (a *Alarm) PartialUpdateUncancel(timestamp CpsTime, author, output, role,
	initiator string, alarmConfig config.AlarmConfig) error

func (*Alarm) PartialUpdateUnsnooze

func (a *Alarm) PartialUpdateUnsnooze() error

func (*Alarm) PbhEnter

func (a *Alarm) PbhEnter(event Event) AlarmStep

func (*Alarm) PbhLeave

func (a *Alarm) PbhLeave(event Event) AlarmStep

func (*Alarm) Resolve

func (a *Alarm) Resolve(timestamp *CpsTime)

Resolve mark as resolved an Alarm with a timestamp [sic]

func (*Alarm) ResolveCancel

func (a *Alarm) ResolveCancel(timestamp *CpsTime)

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

func (a *Alarm) SnoozeFromEvent(event Event) (AlarmStep, error)

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) UnSnooze

func (a *Alarm) UnSnooze()

UnSnooze cancel a snooze

func (*Alarm) Unack

func (a *Alarm) Unack(event Event) AlarmStep

Unack removes an ack on an alarm

func (*Alarm) Uncancel

func (a *Alarm) Uncancel(event Event) AlarmStep

Uncancel uncancel an alarm

func (*Alarm) Update

func (a *Alarm) Update(e Event, alarmConfig config.AlarmConfig) bool

Update an alarm from an Event

func (*Alarm) UpdateLongOutput

func (a *Alarm) UpdateLongOutput(newOutput string)

UpdateLongOutput updates an alarm output field

func (*Alarm) UpdateOutput

func (a *Alarm) UpdateOutput(newOutput string)

UpdateOutput updates an alarm output field

func (*Alarm) UpdateState

func (a *Alarm) UpdateState(stateValue CpsNumber, ts CpsTime)

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 NewAlarmStepFromAction(stepType string, event Event) AlarmStep

func NewAlarmStepFromEvent

func NewAlarmStepFromEvent(stepType string, event Event) AlarmStep

NewAlarmStepFromEvent returns an AlarmStep.

func NewMetaAlarmAttachStep

func NewMetaAlarmAttachStep(metaAlarm Alarm, ruleName string) AlarmStep

func (AlarmStep) NewTicket

func (s AlarmStep) NewTicket(value string, data map[string]string) AlarmTicket

NewTicket creates a Ticket Step from a normal step TODO: annihilate this heresy (Ticket has a distinct format from other classical steps !)

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

type CpsDuration time.Duration

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

func (t CpsNumber) CpsTimestamp() 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 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

type CpsTime struct {
	time.Time
}

CpsTime allows conversion from time.Time to time.Time.Unix()

func NewCpsTime

func NewCpsTime(timestamp int64) CpsTime

NewCpsTime create a CpsTime from a timestamp

func (CpsTime) Format

func (t CpsTime) Format() string

Format easilly format a CpsTime as a string

func (CpsTime) MarshalBSONValue

func (t CpsTime) MarshalBSONValue() (bsontype.Type, []byte, error)

MarshalBSONValue converts from CpsTime to timestamp as bytes

func (CpsTime) MarshalJSON

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

MarshalJSON converts from CpsTime to timestamp as bytes

func (*CpsTime) UnmarshalBSONValue

func (t *CpsTime) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

UnmarshalBSONValue converts from timestamp as bytes to CpsTime

func (*CpsTime) UnmarshalJSON

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

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

func NewDedupList(rawlist ...string) DedupList

NewDedupList creates a new DedupList struct.

func (*DedupList) Add

func (i *DedupList) Add(items ...string)

Add some items to the list

func (*DedupList) Del

func (i *DedupList) Del(items ...string)

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) Exists

func (i DedupList) Exists(item string) bool

Exists returns true if the item exists in the list

func (DedupList) List

func (i DedupList) List() []string

List returns an unordered slice

func (DedupList) Map

func (i DedupList) Map() map[string]bool

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

func (i DedupList) MarshalBinary() ([]byte, error)

MarshalBinary ...

func (DedupList) MarshalJSON

func (i DedupList) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Encoder

func (*DedupList) UnmarshalBinary

func (i *DedupList) UnmarshalBinary(in []byte) error

UnmarshalBinary ...

func (*DedupList) UnmarshalJSON

func (i *DedupList) UnmarshalJSON(in []byte) error

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) CacheID

func (e Entity) CacheID() string

CacheID implements cache.Cache interface

func (*Entity) EnsureInitialized

func (e *Entity) EnsureInitialized()

EnsureInitialized verifies that all complex structs are well initialized

func (*Entity) GetUpsertMongoBson

func (e *Entity) GetUpsertMongoBson(newImpacts []string, newDepends []string) bson.M

func (Entity) HasDepend

func (e Entity) HasDepend(depend string) bool

func (Entity) HasImpact

func (e Entity) HasImpact(impact string) bool

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 NewEventFromAlarm(alarm Alarm) Event

func NewEventFromJSON

func NewEventFromJSON(body []byte) (Event, error)

NewEventFromJSON create an Event from a raw json

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
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

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) GetLockID

func (e *Event) GetLockID() string

GetLockID returns lock name that used to block alarm

func (*Event) GetRequiredKeys

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

GetRequiredKeys read all declared json tags in the struct

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) IsPbehaviorEvent

func (e *Event) IsPbehaviorEvent() bool

func (Event) IsValid

func (e Event) IsValid() error

IsValid checks if an Event is valid for Canopsis processing. the error returned, if any, is of type errt.UnknownError

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.

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

func NewInfo

func NewInfo(name string, description string, value interface{}) Info

NewInfo instanciate a new info struct [sic]

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 (e RPCError) MarshalJSON() ([]byte, error)

func (*RPCError) UnmarshalJSON

func (e *RPCError) UnmarshalJSON(b []byte) error

type RPCPBehaviorEvent

type RPCPBehaviorEvent struct {
	Alarm  *Alarm                    `json:"alarm"`
	Entity *Entity                   `json:"entity"`
	Params ActionPBehaviorParameters `json:"params"`
}

type RPCPBehaviorResultEvent

type RPCPBehaviorResultEvent struct {
	Alarm    *Alarm    `json:"alarm"`
	PbhEvent Event     `json:"event"`
	Error    *RPCError `json:"error"`
}

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 RPCWebhookEvent struct {
	Parameters   WebhookParameters      `json:"parameters"`
	Alarm        *Alarm                 `json:"alarm"`
	AckResources bool                   `json:"ack_resources"`
	Header       map[string]string      `json:"header,omitempty"`
	Response     map[string]interface{} `json:"response,omitempty"`
	Message      string                 `json:"message"`
}

type RPCWebhookResultEvent

type RPCWebhookResultEvent struct {
	Alarm           *Alarm                 `json:"alarm"`
	AlarmChangeType AlarmChangeType        `json:"alarm_change_type"`
	Header          map[string]string      `json:"header,omitempty"`
	Response        map[string]interface{} `json:"response,omitempty"`
	Error           *RPCError              `json:"error"`
}

type Templater

type Templater interface {
	Template(data interface{}) error
}

type WebhookBasicAuth

type WebhookBasicAuth struct {
	Username string `bson:"username" json:"username"`
	Password string `bson:"password" json:"password"`
}

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"`
}

Jump to

Keyboard shortcuts

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