|
@@ -227,6 +227,9 @@ func stageidx(stage string, stages []string) int {
|
|
|
return -1
|
|
|
}
|
|
|
|
|
|
+var ParseDump bool
|
|
|
+var StageParseCache map[string]map[string]types.Event
|
|
|
+
|
|
|
func /*(u types.UnixParser)*/ Parse(ctx UnixParserCtx, xp types.Event, nodes []Node) (types.Event, error) {
|
|
|
var event types.Event = xp
|
|
|
|
|
@@ -250,7 +253,14 @@ func /*(u types.UnixParser)*/ Parse(ctx UnixParserCtx, xp types.Event, nodes []N
|
|
|
log.Tracef("INPUT '%s'", event.Line.Raw)
|
|
|
}
|
|
|
|
|
|
+ if ParseDump {
|
|
|
+ StageParseCache = make(map[string]map[string]types.Event)
|
|
|
+ }
|
|
|
+
|
|
|
for _, stage := range ctx.Stages {
|
|
|
+ if ParseDump {
|
|
|
+ StageParseCache[stage] = make(map[string]types.Event)
|
|
|
+ }
|
|
|
/* if the node is forward in stages, seek to its stage */
|
|
|
/* this is for example used by testing system to inject logs in post-syslog-parsing phase*/
|
|
|
if stageidx(event.Stage, ctx.Stages) > stageidx(stage, ctx.Stages) {
|
|
@@ -267,14 +277,14 @@ func /*(u types.UnixParser)*/ Parse(ctx UnixParserCtx, xp types.Event, nodes []N
|
|
|
|
|
|
isStageOK := false
|
|
|
for idx, node := range nodes {
|
|
|
- clog := log.WithFields(log.Fields{
|
|
|
- "node-name": node.rn,
|
|
|
- "stage": event.Stage,
|
|
|
- })
|
|
|
//Only process current stage's nodes
|
|
|
if event.Stage != node.Stage {
|
|
|
continue
|
|
|
}
|
|
|
+ clog := log.WithFields(log.Fields{
|
|
|
+ "node-name": node.rn,
|
|
|
+ "stage": event.Stage,
|
|
|
+ })
|
|
|
clog.Tracef("Processing node %d/%d -> %s", idx, len(nodes), node.rn)
|
|
|
if ctx.Profiling {
|
|
|
node.Profiling = true
|
|
@@ -286,6 +296,13 @@ func /*(u types.UnixParser)*/ Parse(ctx UnixParserCtx, xp types.Event, nodes []N
|
|
|
clog.Tracef("node (%s) ret : %v", node.rn, ret)
|
|
|
if ret {
|
|
|
isStageOK = true
|
|
|
+ if ParseDump {
|
|
|
+ evtcopy := types.Event{}
|
|
|
+ if err := types.Clone(&event, &evtcopy); err != nil {
|
|
|
+ log.Fatalf("while cloning Event in parser : %s", err)
|
|
|
+ }
|
|
|
+ StageParseCache[stage][node.Name] = evtcopy
|
|
|
+ }
|
|
|
}
|
|
|
if ret && node.OnSuccess == "next_stage" {
|
|
|
clog.Debugf("node successful, stop end stage %s", stage)
|