<?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>topic Re: Extract multiple lines from search output in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-multiple-lines-from-search-output/m-p/174189#M49981</link>
    <description>&lt;P&gt;Sorry about that. Expected result should be,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Time    EveID                                  ComputerName         
_time   Event Code=4742              MyHost.com
_time   Event Code=4772              MyHost2.com
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;etc..&lt;/P&gt;</description>
    <pubDate>Thu, 23 Oct 2014 12:52:14 GMT</pubDate>
    <dc:creator>kkossery</dc:creator>
    <dc:date>2014-10-23T12:52:14Z</dc:date>
    <item>
      <title>Extract multiple lines from search output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-multiple-lines-from-search-output/m-p/174187#M49979</link>
      <description>&lt;P&gt;Experts,&lt;/P&gt;

&lt;P&gt;I have a Event Log output using the search string&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="WinEventLog:Security" "eventcode=4767" OR "eventcode=4777" OR "eventcode=4741" OR "eventcode=4742" OR "eventcode=4742" OR "eventcode=4743" OR "eventcode=4744" OR "eventcode=4745" OR "eventcode=4746" OR "eventcode=4739"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The output would be, after truncating it,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;10/22/2014 11:49:09 AM
LogName=Security
SourceName=Microsoft Windows security auditing.
EventCode=4742
EventType=0
Type=Information
ComputerName=HostName
TaskCategory=Computer Account Management
OpCode=Info
RecordNumber=3344821
Keywords=Audit Success
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;etc. for each event code ID. &lt;/P&gt;

&lt;P&gt;I would like the lines 1, 4 and 7 from the output for example. &lt;BR /&gt;
I used regex and was able to get to one line but do not know how to match the other 4th and 7th line only. See my expression below,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;EveID&amp;gt;EventCode\S+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That would match Event Code=4742 but how do you expand the expression to include line 4 and line 7. &lt;/P&gt;

&lt;P&gt;Thank you. &lt;/P&gt;</description>
      <pubDate>Thu, 23 Oct 2014 12:26:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-multiple-lines-from-search-output/m-p/174187#M49979</guid>
      <dc:creator>kkossery</dc:creator>
      <dc:date>2014-10-23T12:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: Extract multiple lines from search output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-multiple-lines-from-search-output/m-p/174188#M49980</link>
      <description>&lt;P&gt;What is the expected result of line 4 and line 7? Should line 4 be &lt;CODE&gt;ComputerName&lt;/CODE&gt; and line 7 &lt;CODE&gt;RecordNumber&lt;/CODE&gt; ? I'm asking because &lt;CODE&gt;EventCode&lt;/CODE&gt; is not line 1....&lt;/P&gt;</description>
      <pubDate>Thu, 23 Oct 2014 12:45:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-multiple-lines-from-search-output/m-p/174188#M49980</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-10-23T12:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: Extract multiple lines from search output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-multiple-lines-from-search-output/m-p/174189#M49981</link>
      <description>&lt;P&gt;Sorry about that. Expected result should be,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Time    EveID                                  ComputerName         
_time   Event Code=4742              MyHost.com
_time   Event Code=4772              MyHost2.com
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;etc..&lt;/P&gt;</description>
      <pubDate>Thu, 23 Oct 2014 12:52:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-multiple-lines-from-search-output/m-p/174189#M49981</guid>
      <dc:creator>kkossery</dc:creator>
      <dc:date>2014-10-23T12:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: Extract multiple lines from search output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-multiple-lines-from-search-output/m-p/174190#M49982</link>
      <description>&lt;P&gt;Something like this might do the job:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="WinEventLog:Security" "eventcode=4767" OR "eventcode=4777" OR "eventcode=4741" OR "eventcode=4742" OR "eventcode=4742" OR "eventcode=4743" OR "eventcode=4744" OR "eventcode=4745" OR "eventcode=4746" OR "eventcode=4739" | rex "(?m)(?&amp;lt;EveID&amp;gt;EventCode=\S*)[\s\S]*ComputerName=(?&amp;lt;ComputerName&amp;gt;\S+)\s+TaskCategory=(?&amp;lt;TaskCategory&amp;gt;[\s\S]+?)\n" | table _time EveID ComputerName TaskCategory
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Oct 2014 12:59:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-multiple-lines-from-search-output/m-p/174190#M49982</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2014-10-23T12:59:16Z</dc:date>
    </item>
    <item>
      <title>Re: Extract multiple lines from search output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-multiple-lines-from-search-output/m-p/174191#M49983</link>
      <description>&lt;P&gt;or to answer the question how to get the nth line...try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="WinEventLog:Security" "eventcode=4767" OR "eventcode=4777" OR "eventcode=4741" OR "eventcode=4742" OR "eventcode=4742" OR "eventcode=4743" OR "eventcode=4744" OR "eventcode=4745" OR "eventcode=4746" OR "eventcode=4739"
| rex field=_raw "([^\n]*\n){3}([^\n]\w+\=(?&amp;lt;EveID&amp;gt;.*))" 
| rex field=_raw "([^\n]*\n){6}([^\n]\w+\=(?&amp;lt;ComputerName&amp;gt;.*))" 
| table EveID,ComputerName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 23 Oct 2014 13:03:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-multiple-lines-from-search-output/m-p/174191#M49983</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-10-23T13:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: Extract multiple lines from search output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-multiple-lines-from-search-output/m-p/174192#M49984</link>
      <description>&lt;P&gt;Thank richgalloway. How do we also add &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;TaskCategory=Computer Account Management
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;to this. Since this has a white space, I'm unable to figure out how to include the sentence "Computer Account Management"&lt;/P&gt;</description>
      <pubDate>Thu, 23 Oct 2014 13:21:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-multiple-lines-from-search-output/m-p/174192#M49984</guid>
      <dc:creator>kkossery</dc:creator>
      <dc:date>2014-10-23T13:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: Extract multiple lines from search output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-multiple-lines-from-search-output/m-p/174193#M49985</link>
      <description>&lt;P&gt;I've updated my answer to include TaskCategory.&lt;BR /&gt;
You can probably work out how to add it to @MuS's solution.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Oct 2014 13:32:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-multiple-lines-from-search-output/m-p/174193#M49985</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2014-10-23T13:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: Extract multiple lines from search output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-multiple-lines-from-search-output/m-p/174194#M49986</link>
      <description>&lt;P&gt;Thanks MuS. I'll use your output too on a different problem. &lt;/P&gt;</description>
      <pubDate>Thu, 23 Oct 2014 13:55:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-multiple-lines-from-search-output/m-p/174194#M49986</guid>
      <dc:creator>kkossery</dc:creator>
      <dc:date>2014-10-23T13:55:07Z</dc:date>
    </item>
  </channel>
</rss>

