Extracting data from unstructured logs text from multiple records
We have a requirement to extract data from unstructured logs data and capture the results in a custom format. We have implemented the solution using the ExtractText and ReplaceText Processors but we are not getting the expected results,
Please find the details of the input data, current implementation, current output, and expected output format below and help us with your expertise to improvise this using the NiFi Processors.
Input File Content :
<13>Jul 18 11:39:11 test234104.test.gmail.ae AgentDevice=WindowsLog AgentLogFile=Security PluginVersion=100.3.1.22 Source=Microsoft-Windows-Security-Auditing Computer=mycomputer1 OriginatingComputer=102.123.33.1 User= Domain= EventID=4688 EventIDCode=4688 EventType=8 EventCategory=13312
{122}Aug 18 11:39:11 test234104.test.gmail.ae PluginVersion=200.3.1.22 Source=Microsoft-Windows-Security-Auditing AgentDevice=WindowsLog AgentLogFile=Security Computer=mycomputer2.gmail.com OriginatingComputer=125.123.33.1 EventID=4688_2 EventIDCode=4688_2 EventType=8_2 EventCategory=13312_2
Current Implementation :

We have used Regex within the "ExtractText" processor for extracting the data of 3 attributes

Computer = Computer=(.+?)(\t)
event_type = EventType=(.+?)(\t)
eventID = EventID=(.+?)(\t)
Used "ReplaceText" to construct the custom output format,

computer = ${Computer}
event_id = ${eventID}
event_category = ${event_category}
event_type = ${event_type}
Current Output :
computer = mycomputer1
event_id = 4688
event_category = 1
event_type = 8
computer = mycomputer1
event_id = 4688
event_type = 8
computer = mycomputer1
event_id = 4688
event_type = 8
Expected Output Format :
computer = mycomputer1
event_id = 4688
event_type = 8
computer = mycomputer2.gmail.com
event_id = 4688_2
event_type = 8_2
This solution works fine when the data is just a single line item. But when there are multiple records, then data from the first record is repeated and extra records are added for empty lines. Please help us with a generic solution that can handle any number of rows in the input file and extract data for multiple attributes using regex.

