<?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 do I extract fields with Rex? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392916#M114297</link>
    <description>&lt;P&gt;Hi @sarit_s,&lt;/P&gt;

&lt;P&gt;If you have three different events, then use the following for each of the lines. &lt;BR /&gt;
Line 1:  &lt;CODE&gt;...| rex field=_raw "copy\sand\supload\s(?&amp;lt;Status&amp;gt;\w+)[^:]+:\s+(?&amp;lt;StatusTime&amp;gt;[^\n]+)"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Line 2:  &lt;CODE&gt;...|  rex field=_raw "going\sto\scopy\stotal\ssize\sof:\s+(?&amp;lt;TotalSize&amp;gt;[^\n]+)"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Line 3:  &lt;CODE&gt;...| rex field=_raw "starting\stime:\s+(?&amp;lt;StartingTime&amp;gt;.+)"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;You could also combine them as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| rex field=_raw "copy\sand\supload\s(?&amp;lt;Status&amp;gt;\w+)[^:]+:\s+(?&amp;lt;StatusTime&amp;gt;[^\n]+)"|  rex field=_raw "going\sto\scopy\stotal\ssize\sof:\s+(?&amp;lt;TotalSize&amp;gt;[^\n]+)"| rex field=_raw "starting\stime:\s+(?&amp;lt;StartingTime&amp;gt;.+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know how that works out for you.&lt;/P&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
David&lt;/P&gt;</description>
    <pubDate>Tue, 28 May 2019 16:51:36 GMT</pubDate>
    <dc:creator>DavidHourani</dc:creator>
    <dc:date>2019-05-28T16:51:36Z</dc:date>
    <item>
      <title>How do I extract fields with Rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392909#M114290</link>
      <description>&lt;P&gt;Hello&lt;BR /&gt;
I have these events :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;copy and upload completed for day:  2019-05-27 Tue May 28 12:24:40 UTC 2019
going to copy total size of:  25.1 MiB
starting time:  Tue May 28 12:24:40 UTC 2019
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to extract from the first line the string completed (it can be also failed). &lt;BR /&gt;
I'd like to name it &lt;EM&gt;Status&lt;/EM&gt;, and &lt;EM&gt;StatusTime&lt;/EM&gt; for the the first date and time.&lt;BR /&gt;
From second line, the size and name it &lt;EM&gt;TotalSize.&lt;/EM&gt;&lt;BR /&gt;
From third line I want the date, time, and to name it &lt;EM&gt;StartingTime&lt;/EM&gt;.&lt;/P&gt;

&lt;P&gt;How do I do this?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 12:37:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392909#M114290</guid>
      <dc:creator>sarit_s</dc:creator>
      <dc:date>2019-05-28T12:37:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract fields with Rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392910#M114291</link>
      <description>&lt;P&gt;The below SPL should show the desired end status. This can also be done within props and transforms if you wish for this to be done for all data of that specific sourcetype.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval test="copy and upload completed for day:  2019-05-27 Tue May 28 12:24:40 UTC 2019~ 
going to copy total size of:  25.1 MiB~
starting time:  Tue May 28 12:24:40 UTC 2019" 
| fields - _time 
| rex field=test "(\w*\s){3}(?&amp;lt;Status&amp;gt;\w*)[^:]*:\s+(?&amp;lt;StatusTime&amp;gt;[^\n]*)\n[^:]*:\s+(?&amp;lt;TotalSize&amp;gt;[^\n]*)\n[^:]*:\s+(?&amp;lt;StartingTime&amp;gt;.*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This can also be done within props and transforms if you wish for this to be done for all data of that specific sourcetype.&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 12:52:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392910#M114291</guid>
      <dc:creator>cmakepeace_nfcu</dc:creator>
      <dc:date>2019-05-28T12:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract fields with Rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392911#M114292</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Please try below regex&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourBaseSearch&amp;gt;
| rex field=_raw "^(?:[^\s]*[\s]){3}(?&amp;lt;Status&amp;gt;\w+)[^\:]*\:\s+(?&amp;lt;StatusTime&amp;gt;[^\v]*)\v[^\:]*\:\s+(?&amp;lt;TotalSize&amp;gt;[^\v]*)\v[^\:]*\:\s+(?&amp;lt;StartingTime&amp;gt;[^\v]*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Regex101 URL with sample data you have provided : &lt;A href="https://regex101.com/r/a5Rbki/1"&gt;https://regex101.com/r/a5Rbki/1&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 13:00:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392911#M114292</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2019-05-28T13:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract fields with Rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392912#M114293</link>
      <description>&lt;P&gt;it returns empty results &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 15:43:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392912#M114293</guid>
      <dc:creator>sarit_s</dc:creator>
      <dc:date>2019-05-28T15:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract fields with Rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392913#M114294</link>
      <description>&lt;P&gt;it returns empty results &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 15:43:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392913#M114294</guid>
      <dc:creator>sarit_s</dc:creator>
      <dc:date>2019-05-28T15:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract fields with Rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392914#M114295</link>
      <description>&lt;P&gt;Is it multiline event? If yes then you need to provide whole sample event, part of event will not work.&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 15:47:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392914#M114295</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2019-05-28T15:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract fields with Rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392915#M114296</link>
      <description>&lt;P&gt;each event in separet line, just as i wrote at my questions&lt;BR /&gt;
i think it should be rex for each line&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; copy and upload completed for day:  2019-05-27 Tue May 28 12:24:40 UTC 2019
 going to copy total size of:  25.1 MiB
 starting time:  Tue May 28 12:24:40 UTC 2019
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 May 2019 15:50:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392915#M114296</guid>
      <dc:creator>sarit_s</dc:creator>
      <dc:date>2019-05-28T15:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract fields with Rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392916#M114297</link>
      <description>&lt;P&gt;Hi @sarit_s,&lt;/P&gt;

&lt;P&gt;If you have three different events, then use the following for each of the lines. &lt;BR /&gt;
Line 1:  &lt;CODE&gt;...| rex field=_raw "copy\sand\supload\s(?&amp;lt;Status&amp;gt;\w+)[^:]+:\s+(?&amp;lt;StatusTime&amp;gt;[^\n]+)"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Line 2:  &lt;CODE&gt;...|  rex field=_raw "going\sto\scopy\stotal\ssize\sof:\s+(?&amp;lt;TotalSize&amp;gt;[^\n]+)"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Line 3:  &lt;CODE&gt;...| rex field=_raw "starting\stime:\s+(?&amp;lt;StartingTime&amp;gt;.+)"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;You could also combine them as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| rex field=_raw "copy\sand\supload\s(?&amp;lt;Status&amp;gt;\w+)[^:]+:\s+(?&amp;lt;StatusTime&amp;gt;[^\n]+)"|  rex field=_raw "going\sto\scopy\stotal\ssize\sof:\s+(?&amp;lt;TotalSize&amp;gt;[^\n]+)"| rex field=_raw "starting\stime:\s+(?&amp;lt;StartingTime&amp;gt;.+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know how that works out for you.&lt;/P&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
David&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 16:51:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392916#M114297</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-05-28T16:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract fields with Rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392917#M114298</link>
      <description>&lt;P&gt;Hi David,&lt;BR /&gt;
this is how the results looks like :&lt;/P&gt;

&lt;P&gt;Status          StatusTime              TotalSize                                               StartingTime&lt;BR /&gt;
                                             Tue May 28 12:24:40 UTC 2019         Tue May 28 12:24:40 UTC 2019&lt;BR /&gt;
                                              Tue May 28 11:27:29 UTC 2019        Tue May 28 11:27:29 UTC 2019&lt;BR /&gt;
completed   2019-05-27 Tue May 28 12:24:40 UTC 2019 2019-05-27 Tue May 28 12:24:40 UTC 2019 2019-05-27 Tue May 28 12:24:40 UTC 2019&lt;BR /&gt;
completed   2019-05-27  2019-05-27  2019-05-27&lt;BR /&gt;
total          25.1 MiB                       25.1 MiB                                                            25.1 MiB&lt;BR /&gt;
total          5.1 MiB                          5.1 MiB                                                                     5.1 MiB&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 18:40:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392917#M114298</guid>
      <dc:creator>sarit_s</dc:creator>
      <dc:date>2019-05-28T18:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract fields with Rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392918#M114299</link>
      <description>&lt;P&gt;Hi @sarit_s, updated the answer, have a look and try again ! &lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 18:59:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392918#M114299</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-05-28T18:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract fields with Rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392919#M114300</link>
      <description>&lt;P&gt;This should do it :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ...| rex field=_raw "copy\sand\supload\s(?&amp;lt;Status&amp;gt;\w+)[^:]+:\s+(?&amp;lt;StatusTime&amp;gt;[^\n]+)"|  rex field=_raw "going\sto\scopy\stotal\ssize\sof:\s+(?&amp;lt;TotalSize&amp;gt;[^\n]+)"| rex field=_raw "starting\stime:\s+(?&amp;lt;StartingTime&amp;gt;.+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 May 2019 19:04:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392919#M114300</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-05-28T19:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract fields with Rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392920#M114301</link>
      <description>&lt;P&gt;Hi @DavidHourani &lt;BR /&gt;
Thanks !!&lt;BR /&gt;
it is almost perfect&lt;/P&gt;

&lt;P&gt;just the rex for StatusTime should be separeted to 2 fields :&lt;/P&gt;

&lt;P&gt;this is the result:&lt;BR /&gt;
2019-05-27 Tue May 28 12:24:40 UTC 2019&lt;BR /&gt;
and i need 2019-05-27 to be one part and the rest as second part&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 19:08:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392920#M114301</guid>
      <dc:creator>sarit_s</dc:creator>
      <dc:date>2019-05-28T19:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract fields with Rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392921#M114302</link>
      <description>&lt;P&gt;i  did something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw "copy\sand\supload\s(?&amp;lt;Status&amp;gt;\w+)[^:]+:\s+(?&amp;lt;RunningTime&amp;gt;\S+)(?&amp;lt;StatusTime&amp;gt;.+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;is that ok ?&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 19:10:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392921#M114302</guid>
      <dc:creator>sarit_s</dc:creator>
      <dc:date>2019-05-28T19:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract fields with Rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392922#M114303</link>
      <description>&lt;P&gt;Looks good, you can add the space between the two fields as well to avoid having it in StatusTime :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | rex field=_raw "copy\sand\supload\s(?&amp;lt;Status&amp;gt;\w+)[^:]+:\s+(?&amp;lt;RunningTime&amp;gt;\S+)\s(?&amp;lt;StatusTime&amp;gt;.+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 May 2019 19:16:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392922#M114303</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-05-28T19:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract fields with Rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392923#M114304</link>
      <description>&lt;P&gt;perfect&lt;BR /&gt;
thanks !&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 19:20:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-fields-with-Rex/m-p/392923#M114304</guid>
      <dc:creator>sarit_s</dc:creator>
      <dc:date>2019-05-28T19:20:10Z</dc:date>
    </item>
  </channel>
</rss>

