Documentation ¶
Overview ¶
Package monitor holds rules related files
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReportRuleSetLoaded ¶
func ReportRuleSetLoaded(sender events.EventSender, statsdClient statsd.ClientInterface, policies []*PolicyState)
ReportRuleSetLoaded reports to Datadog that a new ruleset was loaded
Types ¶
type HeartbeatEvent ¶
type HeartbeatEvent struct { events.CustomEventCommonFields Policy *PolicyState `json:"policy"` }
HeartbeatEvent is used to report the policies that has been loaded easyjson:json
func (HeartbeatEvent) MarshalEasyJSON ¶
func (v HeartbeatEvent) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (HeartbeatEvent) ToJSON ¶
func (e HeartbeatEvent) ToJSON() ([]byte, error)
ToJSON marshal using json format
func (*HeartbeatEvent) UnmarshalEasyJSON ¶
func (v *HeartbeatEvent) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
type PolicyMonitor ¶
PolicyMonitor defines a policy monitor
func NewPolicyMonitor ¶
func NewPolicyMonitor(statsdClient statsd.ClientInterface, perRuleMetricEnabled bool) *PolicyMonitor
NewPolicyMonitor returns a new Policy monitor
func (*PolicyMonitor) ReportHeartbeatEvent ¶
func (pm *PolicyMonitor) ReportHeartbeatEvent(sender events.EventSender)
ReportHeartbeatEvent sends HeartbeatEvents reporting the current set of policies
func (*PolicyMonitor) SetPolicies ¶
func (pm *PolicyMonitor) SetPolicies(policies []*PolicyState)
SetPolicies sets the policies to monitor
type PolicyState ¶
type PolicyState struct { Name string `json:"name"` Version string `json:"version"` Source string `json:"source"` Rules []*RuleState `json:"rules"` }
PolicyState is used to report policy was loaded easyjson:json
func NewPoliciesState ¶
func NewPoliciesState(ruleSets map[string]*rules.RuleSet, err *multierror.Error, includeInternalPolicies bool) []*PolicyState
NewPoliciesState returns the states of policies and rules
func PolicyStateFromRuleDefinition ¶
func PolicyStateFromRuleDefinition(def *rules.RuleDefinition) *PolicyState
PolicyStateFromRuleDefinition returns a policy state based on the rule definition
func (PolicyState) MarshalEasyJSON ¶
func (v PolicyState) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (*PolicyState) UnmarshalEasyJSON ¶
func (v *PolicyState) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
type RuleAction ¶
type RuleAction struct { Filter *string `json:"filter,omitempty"` Set *RuleSetAction `json:"set,omitempty"` Kill *RuleKillAction `json:"kill,omitempty"` }
RuleAction is used to report policy was loaded easyjson:json
func (RuleAction) MarshalEasyJSON ¶
func (v RuleAction) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (*RuleAction) UnmarshalEasyJSON ¶
func (v *RuleAction) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
type RuleKillAction ¶
type RuleKillAction struct { Signal string `json:"signal,omitempty"` Scope string `json:"scope,omitempty"` }
RuleKillAction is used to report the 'kill' action easyjson:json
func (RuleKillAction) MarshalEasyJSON ¶
func (v RuleKillAction) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (*RuleKillAction) UnmarshalEasyJSON ¶
func (v *RuleKillAction) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
type RuleSetAction ¶
type RuleSetAction struct { Name string `json:"name,omitempty"` Value interface{} `json:"value,omitempty"` Field string `json:"field,omitempty"` Append bool `json:"append,omitempty"` Scope string `json:"scope,omitempty"` }
RuleSetAction is used to report 'set' action easyjson:json
func (RuleSetAction) MarshalEasyJSON ¶
func (v RuleSetAction) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (*RuleSetAction) UnmarshalEasyJSON ¶
func (v *RuleSetAction) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
type RuleSetLoadedReport ¶
type RuleSetLoadedReport struct { Rule *rules.Rule Event *events.CustomEvent }
RuleSetLoadedReport represents the rule and the custom event related to a RuleSetLoaded event, ready to be dispatched
type RuleState ¶
type RuleState struct { ID string `json:"id"` Version string `json:"version,omitempty"` Expression string `json:"expression"` Status string `json:"status"` Message string `json:"message,omitempty"` Tags map[string]string `json:"tags,omitempty"` Actions []RuleAction `json:"actions,omitempty"` }
RuleState defines a loaded rule easyjson:json
func RuleStateFromDefinition ¶
func RuleStateFromDefinition(def *rules.RuleDefinition, status string, message string) *RuleState
RuleStateFromDefinition returns a rule state based on the rule definition
func (RuleState) MarshalEasyJSON ¶
MarshalEasyJSON supports easyjson.Marshaler interface
func (*RuleState) UnmarshalEasyJSON ¶
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
type RulesetLoadedEvent ¶
type RulesetLoadedEvent struct { events.CustomEventCommonFields Policies []*PolicyState `json:"policies"` }
RulesetLoadedEvent is used to report that a new ruleset was loaded easyjson:json
func (RulesetLoadedEvent) MarshalEasyJSON ¶
func (v RulesetLoadedEvent) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (RulesetLoadedEvent) ToJSON ¶
func (e RulesetLoadedEvent) ToJSON() ([]byte, error)
ToJSON marshal using json format
func (*RulesetLoadedEvent) UnmarshalEasyJSON ¶
func (v *RulesetLoadedEvent) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface