<?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: Carriage return newline (\r\n) not working as delimiter for makemv in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Carriage-return-newline-r-n-not-working-as-delimiter-for-makemv/m-p/469151#M80715</link>
    <description>&lt;P&gt;Also, I would still like to know why "\r\n" is not a valid delimiter in this case.&lt;/P&gt;

&lt;P&gt;I have documented (from using Splunk years ago) a nearly identical search string that worked just fine using "\r\n" as the delimiter for makemv.&lt;/P&gt;

&lt;P&gt;Perhaps it has something to do with the fact that it is a JSON format log????&lt;/P&gt;</description>
    <pubDate>Thu, 29 Aug 2019 19:33:13 GMT</pubDate>
    <dc:creator>jmartinf5</dc:creator>
    <dc:date>2019-08-29T19:33:13Z</dc:date>
    <item>
      <title>Carriage return newline (\r\n) not working as delimiter for makemv</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Carriage-return-newline-r-n-not-working-as-delimiter-for-makemv/m-p/469147#M80711</link>
      <description>&lt;P&gt;I am trying to break a field (httpRequest), into a multivalue field and then extract the value of one of the values.&lt;/P&gt;

&lt;P&gt;My search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;* | makemv delim="\r\n" httpRequest | eval userAgent=mvindex(httpRequest,1)  | table  clientIp  userAgent
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Nothing shows up in the table for the userAgent field.  But if I change the index number to 0 instead of 1, the entire httpRequest field value shows up as the value of userAgent.&lt;/P&gt;

&lt;P&gt;It does not appear that &lt;CODE&gt;makemv&lt;/CODE&gt; is honoring the "\r\n" as the delimiter.  I have tried escaping the backslashes with "\r\n" but the result is the same.&lt;/P&gt;

&lt;P&gt;Further info...&lt;/P&gt;

&lt;P&gt;The raw field looks like this:&lt;BR /&gt;
&lt;STRONG&gt;"httpRequest":"GET / HTTP/1.1\r\nHost: somehost\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36\r\nContent-Length: 0\r\n\r\n"&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;And this field in the parsed json-formatted log looks like this:&lt;BR /&gt;
   &lt;STRONG&gt;httpRequest: GET / HTTP/1.1&lt;BR /&gt;
Host: somehost&lt;BR /&gt;
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36&lt;BR /&gt;
Content-Length: 0&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;When I show the httpRequest field in a table it shows up like this:&lt;BR /&gt;
&lt;STRONG&gt;GET / HTTP/1.1&lt;BR /&gt;
Host: somehost&lt;BR /&gt;
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36&lt;BR /&gt;
Content-Length: 0&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2019 18:42:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Carriage-return-newline-r-n-not-working-as-delimiter-for-makemv/m-p/469147#M80711</guid>
      <dc:creator>jmartinf5</dc:creator>
      <dc:date>2019-08-29T18:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: Carriage return newline (\r\n) not working as delimiter for makemv</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Carriage-return-newline-r-n-not-working-as-delimiter-for-makemv/m-p/469148#M80712</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;* | rex field=_raw mode=sed "s/([\r\n]+)/#LINEBREAK##/g" | makemv delim="#LINEBREAK##" httpRequest | eval userAgent=mvindex(httpRequest,1) | table clientIp userAgent
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Aug 2019 18:56:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Carriage-return-newline-r-n-not-working-as-delimiter-for-makemv/m-p/469148#M80712</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2019-08-29T18:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: Carriage return newline (\r\n) not working as delimiter for makemv</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Carriage-return-newline-r-n-not-working-as-delimiter-for-makemv/m-p/469149#M80713</link>
      <description>&lt;P&gt;try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|  rex mode=sed field=_raw "s/\\\r\\\n/*/g"
| makemv delim="*",_raw
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Aug 2019 19:12:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Carriage-return-newline-r-n-not-working-as-delimiter-for-makemv/m-p/469149#M80713</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-29T19:12:53Z</dc:date>
    </item>
    <item>
      <title>Re: Carriage return newline (\r\n) not working as delimiter for makemv</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Carriage-return-newline-r-n-not-working-as-delimiter-for-makemv/m-p/469150#M80714</link>
      <description>&lt;P&gt;That didn't work.  Still ended up with the same result.  I think this is because the &lt;CODE&gt;rex&lt;/CODE&gt; was on the _raw log and the &lt;CODE&gt;makemv&lt;/CODE&gt; was on the parsed field.  So I changed it a bit and got it to work.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;* | rex field=httpRequest mode=sed "s/([\r\n]+)/#LINEBREAK##/g" | makemv delim="#LINEBREAK##" httpRequest  | eval userAgent=mvindex(httpRequest,1) | table clientIp userAgent&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;However, the results then showed me that the User-Agent header isn't always the "1" index header.  So I used &lt;CODE&gt;mvfind&lt;/CODE&gt; to get the index of the UA header.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;* | rex field=httpRequest mode=sed "s/([\r\n]+)/#LINEBREAK##/g" | makemv delim="#LINEBREAK##" httpRequest | eval n=mvfind(httpRequest,"[Uu]ser-[Aa]gent") | eval userAgent=mvindex(httpRequest,n) | table clientIp userAgent&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2019 19:25:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Carriage-return-newline-r-n-not-working-as-delimiter-for-makemv/m-p/469150#M80714</guid>
      <dc:creator>jmartinf5</dc:creator>
      <dc:date>2019-08-29T19:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: Carriage return newline (\r\n) not working as delimiter for makemv</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Carriage-return-newline-r-n-not-working-as-delimiter-for-makemv/m-p/469151#M80715</link>
      <description>&lt;P&gt;Also, I would still like to know why "\r\n" is not a valid delimiter in this case.&lt;/P&gt;

&lt;P&gt;I have documented (from using Splunk years ago) a nearly identical search string that worked just fine using "\r\n" as the delimiter for makemv.&lt;/P&gt;

&lt;P&gt;Perhaps it has something to do with the fact that it is a JSON format log????&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2019 19:33:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Carriage-return-newline-r-n-not-working-as-delimiter-for-makemv/m-p/469151#M80715</guid>
      <dc:creator>jmartinf5</dc:creator>
      <dc:date>2019-08-29T19:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: Carriage return newline (\r\n) not working as delimiter for makemv</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Carriage-return-newline-r-n-not-working-as-delimiter-for-makemv/m-p/469152#M80716</link>
      <description>&lt;P&gt;Lets take a different direction and see if this works for you.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;* |  rex field=httpRequest "(?&amp;lt;userAgent&amp;gt;[Uu]ser-[Aa]gent:[^\r\n]*)Content-Length:" | table clientIp userAgent
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Aug 2019 19:51:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Carriage-return-newline-r-n-not-working-as-delimiter-for-makemv/m-p/469152#M80716</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2019-08-29T19:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: Carriage return newline (\r\n) not working as delimiter for makemv</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Carriage-return-newline-r-n-not-working-as-delimiter-for-makemv/m-p/469153#M80717</link>
      <description>&lt;P&gt;hi @jmartinf5 &lt;BR /&gt;
I believe that's the way splunk works as of now.  Say, for example someone wants to split by the text  (or extract something) that involves r and n , most people would write something like this rex field=whatever...\r\n&lt;BR /&gt;
This will return an extract before r and n is reached in a string like this blah blah blah2233 r n. &lt;BR /&gt;
To out another perspective , to escape backslash in splunk regex you have to use 3 backslashes&lt;BR /&gt;
 \\ , why?&lt;BR /&gt;
if we use just \ then there is no way to differentiate between this and the backslashes in  \d+.+\w&lt;BR /&gt;
so, we just put \ and it works right? wrong, some special chars like this needs to be 'escaped' so we need another additional backslash&lt;BR /&gt;
\\ is interpreted thus - first one - pattern separator, common to all rexes. second one to 'escape' and eventually the third one is for the literal char .&lt;BR /&gt;
Another example is to escape quotes for example I can not do &lt;BR /&gt;
| makeresults &lt;BR /&gt;
| eval x=""some text""&lt;BR /&gt;
this will give an error. i need to 'escape' the quotes so this works:&lt;BR /&gt;
| makeresults &lt;BR /&gt;
| eval x="\"some text\""&lt;BR /&gt;
and the output keeps the quotes , the output will be "Some text"&lt;BR /&gt;
It is a bit confusing, I agree but just takes some getting-used-to&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 11:25:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Carriage-return-newline-r-n-not-working-as-delimiter-for-makemv/m-p/469153#M80717</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-30T11:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: Carriage return newline (\r\n) not working as delimiter for makemv</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Carriage-return-newline-r-n-not-working-as-delimiter-for-makemv/m-p/469154#M80718</link>
      <description>&lt;P&gt;I know this is a fairly old thread but you can also just use an actual linebreak in the search...&lt;/P&gt;

&lt;P&gt;| makemv field=field delim="&lt;BR /&gt;
"&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 20:03:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Carriage-return-newline-r-n-not-working-as-delimiter-for-makemv/m-p/469154#M80718</guid>
      <dc:creator>jwilk</dc:creator>
      <dc:date>2020-02-28T20:03:45Z</dc:date>
    </item>
  </channel>
</rss>

