|
@@ -92,7 +92,7 @@ func (n *Node) validate(pctx *UnixParserCtx) error {
|
|
break
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if method_found == false {
|
|
|
|
|
|
+ if !method_found {
|
|
return fmt.Errorf("the method '%s' doesn't exist", static.Method)
|
|
return fmt.Errorf("the method '%s' doesn't exist", static.Method)
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -120,10 +120,10 @@ func (n *Node) process(p *types.Event, ctx UnixParserCtx) (bool, error) {
|
|
clog.Debugf("Event leaving node : ko")
|
|
clog.Debugf("Event leaving node : ko")
|
|
return false, nil
|
|
return false, nil
|
|
}
|
|
}
|
|
- switch output.(type) {
|
|
|
|
|
|
+ switch out := output.(type) {
|
|
case bool:
|
|
case bool:
|
|
/* filter returned false, don't process Node */
|
|
/* filter returned false, don't process Node */
|
|
- if output.(bool) == false {
|
|
|
|
|
|
+ if !out {
|
|
NodeState = false
|
|
NodeState = false
|
|
clog.Debugf("eval(FALSE) '%s'", n.Filter)
|
|
clog.Debugf("eval(FALSE) '%s'", n.Filter)
|
|
clog.Debugf("Event leaving node : ko")
|
|
clog.Debugf("Event leaving node : ko")
|
|
@@ -142,7 +142,7 @@ func (n *Node) process(p *types.Event, ctx UnixParserCtx) (bool, error) {
|
|
NodeState = true
|
|
NodeState = true
|
|
}
|
|
}
|
|
|
|
|
|
- if n.Profiling == true && n.Name != "" {
|
|
|
|
|
|
+ if n.Profiling && n.Name != "" {
|
|
NodesHits.With(prometheus.Labels{"source": p.Line.Src, "name": n.Name}).Inc()
|
|
NodesHits.With(prometheus.Labels{"source": p.Line.Src, "name": n.Name}).Inc()
|
|
}
|
|
}
|
|
set := false
|
|
set := false
|
|
@@ -188,14 +188,14 @@ func (n *Node) process(p *types.Event, ctx UnixParserCtx) (bool, error) {
|
|
switch output.(type) {
|
|
switch output.(type) {
|
|
case bool:
|
|
case bool:
|
|
/* filter returned false, don't process Node */
|
|
/* filter returned false, don't process Node */
|
|
- if output.(bool) == true {
|
|
|
|
|
|
+ if output.(bool) {
|
|
clog.Infof("Event is whitelisted by Expr !")
|
|
clog.Infof("Event is whitelisted by Expr !")
|
|
p.Whitelisted = true
|
|
p.Whitelisted = true
|
|
set = true
|
|
set = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if set == true {
|
|
|
|
|
|
+ if set {
|
|
p.WhiteListReason = n.Whitelist.Reason
|
|
p.WhiteListReason = n.Whitelist.Reason
|
|
/*huglily wipe the ban order if the event is whitelisted and it's an overflow */
|
|
/*huglily wipe the ban order if the event is whitelisted and it's an overflow */
|
|
if p.Type == types.OVFLW { /*don't do this at home kids */
|
|
if p.Type == types.OVFLW { /*don't do this at home kids */
|
|
@@ -217,7 +217,7 @@ func (n *Node) process(p *types.Event, ctx UnixParserCtx) (bool, error) {
|
|
return false, err
|
|
return false, err
|
|
}
|
|
}
|
|
clog.Tracef("\tsub-node (%s) ret : %v (strategy:%s)", leaf.rn, ret, n.OnSuccess)
|
|
clog.Tracef("\tsub-node (%s) ret : %v (strategy:%s)", leaf.rn, ret, n.OnSuccess)
|
|
- if ret == true {
|
|
|
|
|
|
+ if ret {
|
|
NodeState = true
|
|
NodeState = true
|
|
/* if chil is successful, stop processing */
|
|
/* if chil is successful, stop processing */
|
|
if n.OnSuccess == "next_stage" {
|
|
if n.OnSuccess == "next_stage" {
|
|
@@ -280,15 +280,15 @@ func (n *Node) process(p *types.Event, ctx UnixParserCtx) (bool, error) {
|
|
}
|
|
}
|
|
|
|
|
|
//grok or leafs failed, don't process statics
|
|
//grok or leafs failed, don't process statics
|
|
- if NodeState == false {
|
|
|
|
- if n.Profiling == true && n.Name != "" {
|
|
|
|
|
|
+ if !NodeState {
|
|
|
|
+ if n.Profiling && n.Name != "" {
|
|
NodesHitsKo.With(prometheus.Labels{"source": p.Line.Src, "name": n.Name}).Inc()
|
|
NodesHitsKo.With(prometheus.Labels{"source": p.Line.Src, "name": n.Name}).Inc()
|
|
}
|
|
}
|
|
clog.Debugf("Event leaving node : ko")
|
|
clog.Debugf("Event leaving node : ko")
|
|
return NodeState, nil
|
|
return NodeState, nil
|
|
}
|
|
}
|
|
|
|
|
|
- if n.Profiling == true && n.Name != "" {
|
|
|
|
|
|
+ if n.Profiling && n.Name != "" {
|
|
NodesHitsOk.With(prometheus.Labels{"source": p.Line.Src, "name": n.Name}).Inc()
|
|
NodesHitsOk.With(prometheus.Labels{"source": p.Line.Src, "name": n.Name}).Inc()
|
|
}
|
|
}
|
|
if len(n.Statics) > 0 {
|
|
if len(n.Statics) > 0 {
|
|
@@ -302,7 +302,7 @@ func (n *Node) process(p *types.Event, ctx UnixParserCtx) (bool, error) {
|
|
clog.Tracef("! No node statics")
|
|
clog.Tracef("! No node statics")
|
|
}
|
|
}
|
|
|
|
|
|
- if NodeState == true {
|
|
|
|
|
|
+ if NodeState {
|
|
clog.Debugf("Event leaving node : ok")
|
|
clog.Debugf("Event leaving node : ok")
|
|
log.Tracef("node is successful, check strategy")
|
|
log.Tracef("node is successful, check strategy")
|
|
if n.OnSuccess == "next_stage" {
|
|
if n.OnSuccess == "next_stage" {
|
|
@@ -336,7 +336,7 @@ func (n *Node) compile(pctx *UnixParserCtx) error {
|
|
log.Debugf("compile, node is %s", n.Stage)
|
|
log.Debugf("compile, node is %s", n.Stage)
|
|
/* if the node has debugging enabled, create a specific logger with debug
|
|
/* if the node has debugging enabled, create a specific logger with debug
|
|
that will be used only for processing this node ;) */
|
|
that will be used only for processing this node ;) */
|
|
- if n.Debug == true {
|
|
|
|
|
|
+ if n.Debug {
|
|
var clog = logrus.New()
|
|
var clog = logrus.New()
|
|
clog.SetLevel(log.DebugLevel)
|
|
clog.SetLevel(log.DebugLevel)
|
|
n.logger = clog.WithFields(log.Fields{
|
|
n.logger = clog.WithFields(log.Fields{
|
|
@@ -414,10 +414,10 @@ func (n *Node) compile(pctx *UnixParserCtx) error {
|
|
if len(n.SuccessNodes) > 0 {
|
|
if len(n.SuccessNodes) > 0 {
|
|
for idx, _ := range n.SuccessNodes {
|
|
for idx, _ := range n.SuccessNodes {
|
|
/*propagate debug/stats to child nodes*/
|
|
/*propagate debug/stats to child nodes*/
|
|
- if n.SuccessNodes[idx].Debug == false && n.Debug == true {
|
|
|
|
|
|
+ if !n.SuccessNodes[idx].Debug && n.Debug {
|
|
n.SuccessNodes[idx].Debug = true
|
|
n.SuccessNodes[idx].Debug = true
|
|
}
|
|
}
|
|
- if n.SuccessNodes[idx].Profiling == false && n.Profiling == true {
|
|
|
|
|
|
+ if !n.SuccessNodes[idx].Profiling && n.Profiling {
|
|
n.SuccessNodes[idx].Profiling = true
|
|
n.SuccessNodes[idx].Profiling = true
|
|
}
|
|
}
|
|
n.SuccessNodes[idx].Stage = n.Stage
|
|
n.SuccessNodes[idx].Stage = n.Stage
|
|
@@ -468,7 +468,7 @@ func (n *Node) compile(pctx *UnixParserCtx) error {
|
|
valid = true
|
|
valid = true
|
|
}
|
|
}
|
|
|
|
|
|
- if valid == false {
|
|
|
|
|
|
+ if !valid {
|
|
/* node is empty, error force return */
|
|
/* node is empty, error force return */
|
|
n.logger.Infof("Node is empty: %s", spew.Sdump(n))
|
|
n.logger.Infof("Node is empty: %s", spew.Sdump(n))
|
|
n.Stage = ""
|
|
n.Stage = ""
|