Skip to main content
Solved

Multiple events are not getting generated

  • Jan 15, 2025 2:04 PM UTC
  • 3 replies
  • 60 views

Forum|alt.badge.img+1
Content backfill required

Best answer by rajukg11

I see the problem.  Please keep in mind whenever you are using the for loop in the parser you must initialize the variables you will be using in the loop.  Otherwise the results are unpredictable - by that I mean when you run the parser you may get no errors but when you run again you may get errors.  So you got lucky when you submitted the parser.  And also you may not have encountered this particular log on which it was failing at the time of validation.  So if you run the parser again on the log you sent here it will fail and also succeed.  To fix this this is what you have to do - add the mutate command to initialize the event to be null in the for loop:

    for index, msg in gi_event {

      mutate {

        replace => {

         "event" => ""

        }

      }

      mutate {

 

        convert => {

 

            "msg.src_port" => "integer"

 

View original

3 replies

rajukg11
Staff
Forum|alt.badge.img+6
  • Staff
  • Answer
  • Jan 15, 2025 6:31 PM UTC

I see the problem.  Please keep in mind whenever you are using the for loop in the parser you must initialize the variables you will be using in the loop.  Otherwise the results are unpredictable - by that I mean when you run the parser you may get no errors but when you run again you may get errors.  So you got lucky when you submitted the parser.  And also you may not have encountered this particular log on which it was failing at the time of validation.  So if you run the parser again on the log you sent here it will fail and also succeed.  To fix this this is what you have to do - add the mutate command to initialize the event to be null in the for loop:

    for index, msg in gi_event {

      mutate {

        replace => {

         "event" => ""

        }

      }

      mutate {

 

        convert => {

 

            "msg.src_port" => "integer"

 


Forum|alt.badge.img+1
  • Author
  • New Member
  • Jan 16, 2025 8:44 AM UTC

I see the problem.  Please keep in mind whenever you are using the for loop in the parser you must initialize the variables you will be using in the loop.  Otherwise the results are unpredictable - by that I mean when you run the parser you may get no errors but when you run again you may get errors.  So you got lucky when you submitted the parser.  And also you may not have encountered this particular log on which it was failing at the time of validation.  So if you run the parser again on the log you sent here it will fail and also succeed.  To fix this this is what you have to do - add the mutate command to initialize the event to be null in the for loop:

    for index, msg in gi_event {

      mutate {

        replace => {

         "event" => ""

        }

      }

      mutate {

 

        convert => {

 

            "msg.src_port" => "integer"

 


Thanks for the clarification provided. We have incorporated the logic of initialising the event to null in our parser code but still we encounter the same issue(i.e) Only one event is getting generated during live log ingestion


rajukg11
Staff
Forum|alt.badge.img+6
  • Staff
  • Jan 16, 2025 7:48 PM UTC

Please post the json log where you are seeing this problem.  Make sure to obfuscate the data before posting.