<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: how to read file content and extract specific lines in nifi from .txt log files in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/how-to-read-file-content-and-extract-specific-lines-in-nifi/m-p/286339#M212384</link>
    <description>&lt;P&gt;Just a heads up:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Splitting the file into individual records may provide additional flexibility, but if the case is straightforward enough, I do think it is recommended to use processors (like route text) that avoid creating a flow file for each line.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Dec 2019 16:45:19 GMT</pubDate>
    <dc:creator>DennisJaheruddi</dc:creator>
    <dc:date>2019-12-25T16:45:19Z</dc:date>
    <item>
      <title>how to read file content and extract specific lines in nifi from .txt log files</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-read-file-content-and-extract-specific-lines-in-nifi/m-p/286059#M212191</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;New in NiFi. Hence need guidance on achieving the desired result.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Scenario:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;1. Multiple .txt log files&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. each .txt log file contains many lines&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Requirement:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;1. Read each .txt log file and extract only those lines that has "Three.Link resp:". Below snippet for example is from abc.txt&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;09/10/18 20:06:07.581 DEBUG: (Radio) One.Link DONE
09/10/18 20:06:07.963 34, 0, 0, 0, 0, -99
09/10/18 20:06:08.591 DEBUG: (Radio) Two.Link request
09/10/18 20:06:08.601 DEBUG: (Radio) Three.Link resp: -1 abc-34664 0 10-Sep 12:06:02 0 .00 .00 .00 .00 0 0 0 -99 -99
09/10/18 20:06:08.601 DEBUG: (Radio) One.Link DONE
09/10/18 20:06:08.983 34, 0, 0, 0, 0, -99
09/10/18 20:06:09.600 DEBUG: (Radio) Two.Link request
09/10/18 20:06:09.611 DEBUG: (Radio) Three.Link resp: -1 abc-34664 0 10-Sep 12:06:03 0 .00 .00 .00 .00 0 0 0 -99 -99
09/10/18 20:06:09.611 DEBUG: (Radio) One.Link DONE&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I am trying to do is to extract only those lines from abc.txt which contains "Three.Link resp:" and write it to another file containing only those lines as shown below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;09/10/18 20:06:08.601 DEBUG: (Radio) Three.Link resp: -1 abc-34664 0 10-Sep 12:06:02 0 .00 .00 .00 .00 0 0 0 -99 -99
09/10/18 20:06:09.611 DEBUG: (Radio) Three.Link resp: -1 abc-34664 0 10-Sep 12:06:03 0 .00 .00 .00 .00 0 0 0 -99 -99&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used the ExtractText processor with regex expression :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;^.*Three.Link resp.*$&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;which works correctly. Please refer to regex.com wherein the regex expression seems to work to extract the entire line from the text:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;&amp;lt;a href="&lt;A href="https://regex101.com/r/Ggtl74/2" target="_blank"&gt;https://regex101.com/r/Ggtl74/2&lt;/A&gt;" target="_blank"&amp;gt;&lt;A href="https://regex101.com/r/Ggtl74/2&amp;lt;/a" target="_blank"&gt;https://regex101.com/r/Ggtl74/2&amp;lt;/a&lt;/A&gt;&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But when I place the same regex expression in ExtractText processor, this does not work at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone please advise how to achieve this?? Why does NiFi processor does seem to apply the regex expression or am I not understanding something here??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2019 04:13:22 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-read-file-content-and-extract-specific-lines-in-nifi/m-p/286059#M212191</guid>
      <dc:creator>Fierymech</dc:creator>
      <dc:date>2019-12-20T04:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to read file content and extract specific lines in nifi from .txt log files</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-read-file-content-and-extract-specific-lines-in-nifi/m-p/286245#M212319</link>
      <description>&lt;P&gt;Extract text is for getting some text&amp;nbsp; from the content and putting it in an attribute. This does not sound like what you want. Also it will match the regex to the whole flowfile so again probably not what you want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you only want to keep certain lines from a flowfile, the processor to use seems to be RouteText.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example of this:&amp;nbsp;&lt;A href="https://community.cloudera.com/t5/Support-Questions/Filtering-records-from-a-file-using-NiFi/td-p/184346" target="_blank"&gt;https://community.cloudera.com/t5/Support-Questions/Filtering-records-from-a-file-using-NiFi/td-p/184346&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2019 11:39:06 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-read-file-content-and-extract-specific-lines-in-nifi/m-p/286245#M212319</guid>
      <dc:creator>DennisJaheruddi</dc:creator>
      <dc:date>2019-12-24T11:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to read file content and extract specific lines in nifi from .txt log files</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-read-file-content-and-extract-specific-lines-in-nifi/m-p/286263#M212336</link>
      <description>&lt;P&gt;This is a very basic use case scenario for NiFi. &amp;nbsp; &amp;nbsp; I would recommend that once you get the file into NiFi you split it line by line. &amp;nbsp;Once you have the log file splits, then you do the match logic on each single line. &amp;nbsp; Route the lines you want down stream and handle them accordingly. &amp;nbsp; There are many ways to do this, and the fun part of NiFi is discovering what works best for you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a NiFi Template I have that checks log files:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/steven-dfheinz/NiFi-Templates/blob/master/Get_File_Demo.xml" target="_blank"&gt;https://github.com/steven-dfheinz/NiFi-Templates/blob/master/Get_File_Demo.xml&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this answers helps solve your issue, please make it as Accepted Solution.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2019 12:43:37 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-read-file-content-and-extract-specific-lines-in-nifi/m-p/286263#M212336</guid>
      <dc:creator>stevenmatison</dc:creator>
      <dc:date>2019-12-24T12:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to read file content and extract specific lines in nifi from .txt log files</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-read-file-content-and-extract-specific-lines-in-nifi/m-p/286286#M212348</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/31428"&gt;@DennisJaheruddi&lt;/a&gt;&amp;nbsp;...This definitely helps and I tested it and seems like it did extracted the requisite lines. I created the below regex expression and applied it to RouteText processor and as of now it seems to be working.&lt;/P&gt;&lt;LI-CODE lang="java"&gt;\d{0,2}\/\d{0,2}\/\d{0,2}\s\d{0,2}\:\d{0,2}\:\d{0,2}\.\d{0,4}[ \t]+DEBUG\:[ \t]+\(Radio\)\sThree\.Link\sresp\:[ \t]+-?[\d]{0,4}\s[A-Za-z]{0,4}\-\d{0,7}[ \t]+\d{0,6}\s\d{0,2}-?[A-Za-z]{0,3}\s\d{0,2}\:\d{0,2}\:\d{0,2}[ \t]+\d{0,6}\s\d{0,4}\.\d{0,4}\s\d{0,4}\.\d{0,4}\s-?\d{0,4}\.\d{0,4}\s-?\d{0,4}\.\d{0,4}[ \t]+-?\d{0,4}[ \t]+-?\d{0,4}[ \t]+-?\d{0,4}[ \t]+-?\d{0,4}\s-?\d{0,6}$&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;I would still like to test the flow in detail before I mark your solution as the Accepted solution. I would really appreciate your patience for the same.&lt;/P&gt;&lt;P&gt;Will keep you posted.&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2019 18:12:19 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-read-file-content-and-extract-specific-lines-in-nifi/m-p/286286#M212348</guid>
      <dc:creator>Fierymech</dc:creator>
      <dc:date>2019-12-24T18:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to read file content and extract specific lines in nifi from .txt log files</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-read-file-content-and-extract-specific-lines-in-nifi/m-p/286287#M212349</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/60150"&gt;@stevenmatison&lt;/a&gt;&amp;nbsp;.... I will be surely taking the template from your github and test it out as well. Do give me sometime to test this method as well. Appreciate your advise a lot!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2019 18:16:30 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-read-file-content-and-extract-specific-lines-in-nifi/m-p/286287#M212349</guid>
      <dc:creator>Fierymech</dc:creator>
      <dc:date>2019-12-24T18:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to read file content and extract specific lines in nifi from .txt log files</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-read-file-content-and-extract-specific-lines-in-nifi/m-p/286339#M212384</link>
      <description>&lt;P&gt;Just a heads up:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Splitting the file into individual records may provide additional flexibility, but if the case is straightforward enough, I do think it is recommended to use processors (like route text) that avoid creating a flow file for each line.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Dec 2019 16:45:19 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-read-file-content-and-extract-specific-lines-in-nifi/m-p/286339#M212384</guid>
      <dc:creator>DennisJaheruddi</dc:creator>
      <dc:date>2019-12-25T16:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to read file content and extract specific lines in nifi from .txt log files</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-read-file-content-and-extract-specific-lines-in-nifi/m-p/286365#M212400</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/31428"&gt;@DennisJaheruddi&lt;/a&gt;&amp;nbsp;....Thanks much for making the Christmas more merrier &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I agree to your statement and have configured the flow accordingly. I am marking your reply as accepted solution. Great advise and kudos to you again.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Dec 2019 07:03:42 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-read-file-content-and-extract-specific-lines-in-nifi/m-p/286365#M212400</guid>
      <dc:creator>Fierymech</dc:creator>
      <dc:date>2019-12-26T07:03:42Z</dc:date>
    </item>
  </channel>
</rss>

