<?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: Field extraction in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction/m-p/484722#M135671</link>
    <description>&lt;P&gt;| eval time=strptime(mvdedup(time),"%m/%d/%Y %H:%M")&lt;BR /&gt;
 | rex "(?\d+.\d+.\d{4}\s\d+:\d+)"&lt;/P&gt;

&lt;P&gt;in this order it worked as expected, after the other rex expressions and before the stats, so it ended up like this&lt;/P&gt;

&lt;P&gt;your_search&lt;BR /&gt;
 | eval raw=replace(_raw,"\\n","&lt;BR /&gt;
  ") &lt;BR /&gt;
 | makemv delim="&lt;BR /&gt;
  " raw &lt;BR /&gt;
 | streamstats count as session &lt;BR /&gt;
 | mvexpand raw &lt;BR /&gt;
 | rename raw as _raw&lt;BR /&gt;
 | rex "^\s+(?\d+.\d+.\d{4}\s\d+:\d+)"&lt;BR /&gt;
 | rex "(?:\d+ )(?[\w ]+)\s+(?\d+.\d{2})"&lt;BR /&gt;
 | rex "GRAND TOTAL\s+(?\d+.\d{2})" &lt;BR /&gt;
 | rex "\s+(?\d{8})\s+(?\w+), (?\w+)" &lt;BR /&gt;
 | rex "Check No.:\s+(?\d{8})" &lt;BR /&gt;
 | eval time=strptime(mvdedup(time),"%m/%d/%Y %H:%M")&lt;BR /&gt;
 | rex "(?\d+.\d+.\d{4}\s\d+:\d+)"&lt;BR /&gt;
 | stats list(*) as * by session &lt;BR /&gt;
 | table session time user_id first_name last_name items amounts ground_total check_no&lt;/P&gt;

&lt;P&gt;you've been amazingly helpful, thanks a lot!&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 03:47:28 GMT</pubDate>
    <dc:creator>maxitroncoso</dc:creator>
    <dc:date>2020-09-30T03:47:28Z</dc:date>
    <item>
      <title>Field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction/m-p/484714#M135663</link>
      <description>&lt;P&gt;I'm trying to extract fields from this event using regular expressions, &lt;/P&gt;

&lt;P&gt;Multiple times I receive the following error.. I tried to avoid it by creating fields out of  every part of the event&lt;/P&gt;

&lt;P&gt;"The extraction failed. If you are extracting multiple fields, try removing one or more fields. Start with extractions that are embedded within longer text strings."&lt;/P&gt;

&lt;P&gt;The fields I'd like to extract are:&lt;BR /&gt;
FIRST ITEM (and every other item that goes after it)&lt;BR /&gt;
FIRST ITEM AMOUNT ( The number that goes before first item)&lt;BR /&gt;
GRAND TOTAL&lt;BR /&gt;
LASTNAME&lt;BR /&gt;
FIRSTNAME&lt;BR /&gt;
The 8 digit number that goes before LASTNAME&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  "receipt-text":"  COMPANY NAME INTERNATIONAL\n      Branch name goes here\n            App name\n\n         1/16/2020 22:30  \nServer:123  App Name          \nGuests:0      \n_________________________________\n          appName User\n      1 First Item     5.00\n      2 Second Item                 7.00\n        @ 3.50\n\n       \n      Gross Sales     12.00\n         Discount      0.00\n         Subtotal     12.00\n              Tax      0.00\n   Service Charge      2.16   \n  Delivery Charge      1.95  \n   Additional Tip      0.00\n            Total     16.11\n\n\nUser                       16.11\n  12345678 LASTNAME, FIRSTNAME\n\n       GRAND TOTAL         16.11\n\n______________________________________\nT1234 C300      1/16/2020 22:30\n______________________________________      \n\n \n\nAdditional Tip    $___________________\n\n\n\nTotal             $___________________\n\n\n\n\n______________________________________\nSignature\n         ***************\n   A 18% service charge is included\n  in your bill, however, please use\n   the Additional Tip line to\n  recognize outstanding service.\n         ***************\nCheck No.: 12345678\n@##12345678@"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any help you can deliver to point me into the right direction, I'd be really happy.&lt;BR /&gt;
I hope I'm soon able to help other people aswell&lt;BR /&gt;
If you've come this far, thanks a lot for reading my issue!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 18:49:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction/m-p/484714#M135663</guid>
      <dc:creator>maxitroncoso</dc:creator>
      <dc:date>2020-01-17T18:49:58Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction/m-p/484715#M135664</link>
      <description>&lt;P&gt;If the field extraction in the GUi didn't work for you, did you try six different regular expressions using the rex command? If so, what exactly were your expressions?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 19:00:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction/m-p/484715#M135664</guid>
      <dc:creator>efavreau</dc:creator>
      <dc:date>2020-01-17T19:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction/m-p/484716#M135665</link>
      <description>&lt;P&gt;UPDATED: add time and check_no&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your_search
| eval raw=replace(_raw,"\\\n","
 ") 
| makemv delim="
 " raw 
| streamstats count as session 
| mvexpand raw 
| rename raw as _raw
| rex "^\s+(?&amp;lt;time&amp;gt;\d+.\d+.\d{4}\s\d+\:\d+)"
| rex "(?:\d+ )(?&amp;lt;items&amp;gt;[\w ]+)\s+(?&amp;lt;amounts&amp;gt;\d+\.\d{2})"
| rex "GRAND TOTAL\s+(?&amp;lt;ground_total&amp;gt;\d+\.\d{2})" 
| rex "\s+(?&amp;lt;user_id&amp;gt;\d{8})\s+(?&amp;lt;last_name&amp;gt;\w+), (?&amp;lt;first_name&amp;gt;\w+)" 
| rex "Check No\.:\s+(?&amp;lt;check_no&amp;gt;\d{8})" 
| stats list(*) as * by session 
| eval time=strptime(time,"%m/%d/%Y %H:%M")
| fieldformat time=strftime(time,"%m/%d/%Y %H:%M")
| table session time user_id first_name last_name items amounts ground_total check_no
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;Previous my answer:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="   \"receipt-text\":\"  COMPANY NAME INTERNATIONAL\n      Branch name goes here\n            App name\n\n         1/16/2020 22:30  \nServer:123  App Name          \nGuests:0      \n_________________________________\n          appName User\n      1 First Item     5.00\n      2 Second Item                 7.00\n        @ 3.50\n\n       \n      Gross Sales     12.00\n         Discount      0.00\n         Subtotal     12.00\n              Tax      0.00\n   Service Charge      2.16   \n  Delivery Charge      1.95  \n   Additional Tip      0.00\n            Total     16.11\n\n\nUser                       16.11\n  12345678 LASTNAME, FIRSTNAME\n\n       GRAND TOTAL         16.11\n\n______________________________________\nT1234 C300      1/16/2020 22:30\n______________________________________      \n\n \n\nAdditional Tip    $___________________\n\n\n\nTotal             $___________________\n\n\n\n\n______________________________________\nSignature\n         ***************\n   A 18% service charge is included\n  in your bill, however, please use\n   the Additional Tip line to\n  recognize outstanding service.\n         ***************\nCheck No.: 12345678\n@##12345678@"
| eval raw=replace(_raw,"\\\n","
")
| makemv delim="
" raw
| streamstats count as session
| mvexpand raw
| rename raw as _raw
| rex "(?:\d+ )(?&amp;lt;items&amp;gt;[\w ]+)\s+(?&amp;lt;amounts&amp;gt;\d+\.\d{2})"
| rex "GRAND TOTAL\s+(?&amp;lt;ground_total&amp;gt;\d+\.\d{2})"
| rex "\s+(?&amp;lt;user_id&amp;gt;\d{8})\s+(?&amp;lt;last_name&amp;gt;\w+), (?&amp;lt;first_name&amp;gt;\w+)"
| stats list(*) as * by session
| table session user_id first_name last_name items amounts ground_total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi, @maxitroncoso&lt;BR /&gt;
&lt;EM&gt;items&lt;/EM&gt; and &lt;EM&gt;amounts&lt;/EM&gt; are one-on-one.&lt;BR /&gt;
As I don't know how you display these, I create like above.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jan 2020 01:08:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction/m-p/484716#M135665</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-18T01:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction/m-p/484717#M135666</link>
      <description>&lt;P&gt;@to4kawa thanks  a lot for your swift answer, I took what you wrote and it worked as intended!&lt;/P&gt;

&lt;P&gt;I tried the following expression in order to add a date and time column to the table, but whenever I use it, instead of one date and time I get a lot per event&lt;/P&gt;

&lt;P&gt;| eval indextime= strftime(_indextime,"%Y-%m-%d %H:%M:%S")&lt;/P&gt;

&lt;P&gt;I also figured out that I would need to extract the number after Check No.&lt;BR /&gt;
Tried to do so with the following expression:&lt;/P&gt;

&lt;P&gt;| rex "nCheck No.:\s+(?\d{8})"&lt;/P&gt;

&lt;P&gt;but i'm getting empty results on that column, any idea of why that may be?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2020 17:34:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction/m-p/484717#M135666</guid>
      <dc:creator>maxitroncoso</dc:creator>
      <dc:date>2020-01-20T17:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction/m-p/484718#M135667</link>
      <description>&lt;P&gt;As my query runs, &lt;CODE&gt;\n&lt;/CODE&gt; is remove.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "Check No\.:\s+(?&amp;lt;check_no&amp;gt;\d{8})"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;try this.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2020 22:14:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction/m-p/484718#M135667</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-20T22:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction/m-p/484719#M135668</link>
      <description>&lt;P&gt;hi, @maxitroncoso &lt;BR /&gt;
I update my answer, add time and check_no. please confirm.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2020 19:43:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction/m-p/484719#M135668</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-21T19:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction/m-p/484720#M135669</link>
      <description>&lt;P&gt;Checknumber works as intended (I replaced it for order_number) but time is empty&lt;/P&gt;

&lt;P&gt;| eval time=strptime(time,"%m/%d/%Y %H:%M")&lt;BR /&gt;
 | fieldformat time=strftime(time,"%m/%d/%Y %H:%M")&lt;BR /&gt;
 | table session time user_id first_name last_name items amounts ground_total check_no&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:47:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction/m-p/484720#M135669</guid>
      <dc:creator>maxitroncoso</dc:creator>
      <dc:date>2020-09-30T03:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction/m-p/484721#M135670</link>
      <description>&lt;P&gt;&lt;CODE&gt;| rex "^\s+(?&amp;lt;time&amp;gt;\d+.\d+.\d{4}\s\d+\:\d+)"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This rex may not be working in your actual log.&lt;BR /&gt;
Since there were actually two &lt;EM&gt;time&lt;/EM&gt; displayed, this regular expression was used to exclude one.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| rex "(?&amp;lt;time&amp;gt;\d+.\d+.\d{4}\s\d+\:\d+)"&lt;/CODE&gt;&lt;BR /&gt;
and&lt;BR /&gt;
&lt;CODE&gt;| eval time=strptime(mvdedup(time),"%m/%d/%Y %H:%M")&lt;/CODE&gt;&lt;BR /&gt;
This might be better.&lt;/P&gt;

&lt;P&gt;Run it line by line and check &lt;CODE&gt;rex&lt;/CODE&gt; result, if &lt;EM&gt;time&lt;/EM&gt; is extracted.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2020 21:48:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction/m-p/484721#M135670</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-21T21:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction/m-p/484722#M135671</link>
      <description>&lt;P&gt;| eval time=strptime(mvdedup(time),"%m/%d/%Y %H:%M")&lt;BR /&gt;
 | rex "(?\d+.\d+.\d{4}\s\d+:\d+)"&lt;/P&gt;

&lt;P&gt;in this order it worked as expected, after the other rex expressions and before the stats, so it ended up like this&lt;/P&gt;

&lt;P&gt;your_search&lt;BR /&gt;
 | eval raw=replace(_raw,"\\n","&lt;BR /&gt;
  ") &lt;BR /&gt;
 | makemv delim="&lt;BR /&gt;
  " raw &lt;BR /&gt;
 | streamstats count as session &lt;BR /&gt;
 | mvexpand raw &lt;BR /&gt;
 | rename raw as _raw&lt;BR /&gt;
 | rex "^\s+(?\d+.\d+.\d{4}\s\d+:\d+)"&lt;BR /&gt;
 | rex "(?:\d+ )(?[\w ]+)\s+(?\d+.\d{2})"&lt;BR /&gt;
 | rex "GRAND TOTAL\s+(?\d+.\d{2})" &lt;BR /&gt;
 | rex "\s+(?\d{8})\s+(?\w+), (?\w+)" &lt;BR /&gt;
 | rex "Check No.:\s+(?\d{8})" &lt;BR /&gt;
 | eval time=strptime(mvdedup(time),"%m/%d/%Y %H:%M")&lt;BR /&gt;
 | rex "(?\d+.\d+.\d{4}\s\d+:\d+)"&lt;BR /&gt;
 | stats list(*) as * by session &lt;BR /&gt;
 | table session time user_id first_name last_name items amounts ground_total check_no&lt;/P&gt;

&lt;P&gt;you've been amazingly helpful, thanks a lot!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:47:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction/m-p/484722#M135671</guid>
      <dc:creator>maxitroncoso</dc:creator>
      <dc:date>2020-09-30T03:47:28Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction/m-p/484723#M135672</link>
      <description>&lt;P&gt;you're welcome and happy splunking.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2020 20:43:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction/m-p/484723#M135672</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-22T20:43:43Z</dc:date>
    </item>
  </channel>
</rss>

