<?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: How to extract fields from a single file containing multiple sourcetypes, each with multiline events ? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-fields-from-a-single-file-containing-multiple/m-p/32504#M5779</link>
    <description>&lt;P&gt;Hi David,&lt;/P&gt;

&lt;P&gt;thanks for your answer, I've tried and it works great!&lt;/P&gt;

&lt;P&gt;What I forgot to mention is that I would need to have an event for each line; so if I search for sourcetype=App01trace and field3=393222 and field5=19, I should get only this line&lt;/P&gt;

&lt;P&gt;3 0 393222 0 19 148 8838300 &lt;/P&gt;</description>
    <pubDate>Mon, 27 Jun 2011 22:42:14 GMT</pubDate>
    <dc:creator>mzorzi</dc:creator>
    <dc:date>2011-06-27T22:42:14Z</dc:date>
    <item>
      <title>How to extract fields from a single file containing multiple sourcetypes, each with multiline events ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-fields-from-a-single-file-containing-multiple/m-p/32502#M5777</link>
      <description>&lt;P&gt;My source file is like:&lt;/P&gt;

&lt;P&gt;============================  &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;App01trace&lt;BR /&gt;&lt;BR /&gt;
           3          0      393222            0          19         148     8838300&lt;BR /&gt;&lt;BR /&gt;
           4          0      458759            0          29          15           0&lt;BR /&gt;&lt;BR /&gt;
           4          0      458759            0          31          12           0&lt;BR /&gt;&lt;BR /&gt;
           5          0      524296            0          61         170     8869500&lt;BR /&gt;&lt;BR /&gt;
App02trace&lt;BR /&gt;&lt;BR /&gt;
           4          0      327685              2032           0               0      0             0                NULL&lt;BR /&gt;&lt;BR /&gt;
           6          0      393222              2032           0               0           0             0                NULL&lt;BR /&gt;&lt;BR /&gt;
           5          0      458760              2032           0               0           0             0                NULL&lt;BR /&gt;&lt;BR /&gt;
App03trace&lt;BR /&gt;&lt;BR /&gt;
          21          1     2959165            3           8           1              1 P&lt;BR /&gt;&lt;BR /&gt;
          22          9      859165            3           12          6              1 R    &lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;============================  &lt;/P&gt;

&lt;P&gt;I would like to associate to each App0.trace a different sourcetype, and then associate each value to a different field, specific for that sourcetype.&lt;/P&gt;

&lt;P&gt;I've tried the following steps:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;In inputs.conf I assign my source file to a fix sourcetype [testbb]&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;I then use [testbb] to define a stanza props.conf, like this:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;[testbb]&lt;BR /&gt;&lt;BR /&gt;
SHOULD_LINEMERGE = true&lt;BR /&gt;&lt;BR /&gt;
BREAK_ONLY_BEFORE_DATE = false&lt;BR /&gt;&lt;BR /&gt;
LINE_BREAKER = ([\r\n]+)(App01trace|App02trace|App03trace)&lt;BR /&gt;&lt;BR /&gt;
TRANSFORMS-App01trace=tr-App01trace&lt;BR /&gt;&lt;BR /&gt;
TRANSFORMS-App02trace=tr-App02trace&lt;BR /&gt;&lt;BR /&gt;
TRANSFORMS-App03trace=tr-App03trace&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;In transforms.conf I extract the three different sourcetypes, like:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;[tr-App01trace]&lt;BR /&gt;&lt;BR /&gt;
REGEX    = App01trace&lt;BR /&gt;&lt;BR /&gt;
DEST_KEY = MetaData:Sourcetype&lt;BR /&gt;&lt;BR /&gt;
FORMAT   = sourcetype::App01trace &lt;/P&gt;
&lt;/BLOCKQUOTE&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;Finally I create another stanza in props.conf for sourcetype [App01trace] where I perform the search time extractions (using Extract)&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;My problem is that it only extracts the fields from the first line of each sub block, not for every line. So supposing the third field for App03trace is called app03field3, I get  app03field3=2959165 but the value 859165 doesn't get extracted.&lt;/P&gt;

&lt;P&gt;That doesn't surprise me as the LINE_BREAKER has been already executed for that stream.&lt;/P&gt;

&lt;P&gt;What should I change to achieve my goal?&lt;BR /&gt;&lt;BR /&gt;
Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2011 09:29:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-fields-from-a-single-file-containing-multiple/m-p/32502#M5777</guid>
      <dc:creator>mzorzi</dc:creator>
      <dc:date>2011-06-22T09:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from a single file containing multiple sourcetypes, each with multiline events ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-fields-from-a-single-file-containing-multiple/m-p/32503#M5778</link>
      <description>&lt;P&gt;mzorzi,&lt;/P&gt;

&lt;P&gt;You may want to change to using PROPS instead of EXTRACT.  This way you can specify MV_ADD=True which will create multivalue fields based on your search time extraction.&lt;/P&gt;

&lt;P&gt;Given a sample of:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;App01trace
3 0 393222 0 19 148 8838300
4 0 458759 0 29 15 0
4 0 458759 0 31 12 0
5 0 524296 0 61 170 8869500 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The following configuration:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;## props.conf
[App01trace]
REPORT-kv_for_app01trace = kv_for_app01trace

## transforms.conf
[kv_for_app01trace]
REGEX = ([^\s]+)\s([^\s]+)\s([^\s]+)\s([^\s]+)\s([^\s]+)\s([^\s]+)\s([^\s]+)
FORMAT = field1::$1 field2::$2 field3::$3 field4::$4 field5::$5 field6::$6 field7::$7
MV_ADD = True
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Will give you the following fields and values:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;field1 = [3, 4, 4, 5]
field2 = [0, 0, 0, 0]
field3 = [393222, 458759, 458759, 524296]
filed4 = [0, 0, 0, 0]
field5 = [19, 29, 31, 61]
field6 = [148, 15, 12, 170]
field7 = [8838300, 0, 0, 8869500]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There are additional ways of performing extractions using search commands, but this is the best way to do via props.conf.&lt;/P&gt;

&lt;P&gt;-David&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2011 01:34:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-fields-from-a-single-file-containing-multiple/m-p/32503#M5778</guid>
      <dc:creator>hazekamp</dc:creator>
      <dc:date>2011-06-24T01:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from a single file containing multiple sourcetypes, each with multiline events ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-fields-from-a-single-file-containing-multiple/m-p/32504#M5779</link>
      <description>&lt;P&gt;Hi David,&lt;/P&gt;

&lt;P&gt;thanks for your answer, I've tried and it works great!&lt;/P&gt;

&lt;P&gt;What I forgot to mention is that I would need to have an event for each line; so if I search for sourcetype=App01trace and field3=393222 and field5=19, I should get only this line&lt;/P&gt;

&lt;P&gt;3 0 393222 0 19 148 8838300 &lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2011 22:42:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-fields-from-a-single-file-containing-multiple/m-p/32504#M5779</guid>
      <dc:creator>mzorzi</dc:creator>
      <dc:date>2011-06-27T22:42:14Z</dc:date>
    </item>
  </channel>
</rss>

