<?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 fields from single event(s) consisting of mutiple lines in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-single-event-s-consisting-of-mutiple-lines/m-p/223020#M65618</link>
    <description>&lt;P&gt;Hi ashabc,&lt;/P&gt;

&lt;P&gt;take a look at this answer &lt;A href="http://answers.splunk.com/answers/305727/why-is-my-rex-statement-unable-to-extract-the-fiel.html#answer-306962"&gt;http://answers.splunk.com/answers/305727/why-is-my-rex-statement-unable-to-extract-the-fiel.html#answer-306962&lt;/A&gt; to learn about &lt;CODE&gt;pcregextest&lt;/CODE&gt; And how you can Test regex in Splunk.&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
    <pubDate>Sat, 12 Sep 2015 08:48:25 GMT</pubDate>
    <dc:creator>MuS</dc:creator>
    <dc:date>2015-09-12T08:48:25Z</dc:date>
    <item>
      <title>Extract fields from single event(s) consisting of mutiple lines</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-single-event-s-consisting-of-mutiple-lines/m-p/223018#M65616</link>
      <description>&lt;P&gt;I have a csv file that has only one column without any header. The data set includes values for userid, property1, property2, property3 and then again userid, propperty1, property2, property3 and so on. How can I extract fields useird, property1, property2 and property3 ?&lt;/P&gt;

&lt;P&gt;Tried something like below (e.g. for userid), does not work&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.....| rex field=_raw "(?&amp;lt;userid&amp;gt;^(.*)\n)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Sep 2015 23:41:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-single-event-s-consisting-of-mutiple-lines/m-p/223018#M65616</guid>
      <dc:creator>ashabc</dc:creator>
      <dc:date>2015-09-11T23:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: Extract fields from single event(s) consisting of mutiple lines</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-single-event-s-consisting-of-mutiple-lines/m-p/223019#M65617</link>
      <description>&lt;P&gt;Can you post an example of the data? Does the data just contain the values or is there something unique to each line that could be useful to key in on for the extraction process.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Sep 2015 04:51:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-single-event-s-consisting-of-mutiple-lines/m-p/223019#M65617</guid>
      <dc:creator>Runals</dc:creator>
      <dc:date>2015-09-12T04:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: Extract fields from single event(s) consisting of mutiple lines</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-single-event-s-consisting-of-mutiple-lines/m-p/223020#M65618</link>
      <description>&lt;P&gt;Hi ashabc,&lt;/P&gt;

&lt;P&gt;take a look at this answer &lt;A href="http://answers.splunk.com/answers/305727/why-is-my-rex-statement-unable-to-extract-the-fiel.html#answer-306962"&gt;http://answers.splunk.com/answers/305727/why-is-my-rex-statement-unable-to-extract-the-fiel.html#answer-306962&lt;/A&gt; to learn about &lt;CODE&gt;pcregextest&lt;/CODE&gt; And how you can Test regex in Splunk.&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Sat, 12 Sep 2015 08:48:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-single-event-s-consisting-of-mutiple-lines/m-p/223020#M65618</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-09-12T08:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: Extract fields from single event(s) consisting of mutiple lines</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-single-event-s-consisting-of-mutiple-lines/m-p/223021#M65619</link>
      <description>&lt;P&gt;Here is sample data for 2 users. It basically contains a set of strings and numbers. The userid will be string, followed by some other form of id (property1) in number form, then 2 other properties, both strings and so on.&lt;/P&gt;

&lt;P&gt;user1&lt;BR /&gt;
101253&lt;BR /&gt;
DTZ&lt;BR /&gt;
Penrith, Cumberland&lt;BR /&gt;
user2&lt;BR /&gt;
2151614&lt;BR /&gt;
FCC&lt;BR /&gt;
Balnd, Temora&lt;/P&gt;</description>
      <pubDate>Sun, 13 Sep 2015 23:18:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-single-event-s-consisting-of-mutiple-lines/m-p/223021#M65619</guid>
      <dc:creator>ashabc</dc:creator>
      <dc:date>2015-09-13T23:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: Extract fields from single event(s) consisting of mutiple lines</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-single-event-s-consisting-of-mutiple-lines/m-p/223022#M65620</link>
      <description>&lt;P&gt;Based on the just provided examples you can try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval foo="user1
101253
DTZ
Penrith, Cumberland
user2
2151614
FCC
Balnd, Temora" | rex max_match=0 field=foo "user\d[\r\n](?&amp;lt;userID&amp;gt;[^\r\n]*)[\r\n](?&amp;lt;property1&amp;gt;[^\r\n]*)[\r\n](?&amp;lt;property2&amp;gt;[^\r\n]*)" | table userID, property1, property2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or use the internal &lt;CODE&gt;pcregextest&lt;/CODE&gt; like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$SPLUNK_HOME/bin/splunk cmd pcregextest mregex="user\d[\r\n](?&amp;lt;userID&amp;gt;[^\r\n]*)[\r\n](?&amp;lt;property1&amp;gt;[^\r\n]*)[\r\n](?&amp;lt;property2&amp;gt;[^\r\n]*)" test_str="user1
&amp;gt;     101253
&amp;gt;     DTZ
&amp;gt;     Penrith, Cumberland
&amp;gt;     user2
&amp;gt;     2151614
&amp;gt;     FCC
&amp;gt;     Balnd, Temora"
Original Pattern: 'user\d[\r\n](?&amp;lt;userID&amp;gt;[^\r\n]*)[\r\n](?&amp;lt;property1&amp;gt;[^\r\n]*)[\r\n](?&amp;lt;property2&amp;gt;[^\r\n]*)'
Expanded Pattern: 'user\d[\r\n](?&amp;lt;userID&amp;gt;[^\r\n]*)[\r\n](?&amp;lt;property1&amp;gt;[^\r\n]*)[\r\n](?&amp;lt;property2&amp;gt;[^\r\n]*)'
Regex compiled successfully. Capture group count = 3. Named capturing groups = 3.
SUCCESS - match against: 'user1
    101253
    DTZ
    Penrith, Cumberland
    user2
    2151614
    FCC
    Balnd, Temora'

#### Capturing group data ##### 
Group |            Name | Value
--------------------------------------
    1 |          userID |     101253
    2 |       property1 |     DTZ
    3 |       property2 |     Penrith, Cumberland
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 13 Sep 2015 23:40:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-single-event-s-consisting-of-mutiple-lines/m-p/223022#M65620</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-09-13T23:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: Extract fields from single event(s) consisting of mutiple lines</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-single-event-s-consisting-of-mutiple-lines/m-p/223023#M65621</link>
      <description>&lt;P&gt;Its kind of work. &lt;/P&gt;

&lt;P&gt;What I still don't get it is you used eval foo="data_string". Its OK for 2 sets of sample data. When I have thousands of data in the csv file, how can I tackle that?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2015 10:53:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-single-event-s-consisting-of-mutiple-lines/m-p/223023#M65621</guid>
      <dc:creator>ashabc</dc:creator>
      <dc:date>2015-09-16T10:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: Extract fields from single event(s) consisting of mutiple lines</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-single-event-s-consisting-of-mutiple-lines/m-p/223024#M65622</link>
      <description>&lt;P&gt;He was using gentimes and the eval as a way to test the methodology. If you do the search as&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex max_match=0 field=foo "user\d[\r\n](?&amp;lt;userID&amp;gt;[^\r\n]*)[\r\n](?&amp;lt;property1&amp;gt;[^\r\n]*)[\r\n](?&amp;lt;property2&amp;gt;[^\r\n]*)" | table userID, property1, property2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It should work. Certainly change the "field=" part of the rex command to fit the sourcetype and field that contains the data.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2015 14:13:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-single-event-s-consisting-of-mutiple-lines/m-p/223024#M65622</guid>
      <dc:creator>Runals</dc:creator>
      <dc:date>2015-09-16T14:13:43Z</dc:date>
    </item>
  </channel>
</rss>

