<?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 split a multi-line _raw to a multivalue with one line of text per element? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-multi-line-raw-to-a-multivalue-with-one-line-of/m-p/268332#M80719</link>
    <description>&lt;P&gt;Ciao,&lt;/P&gt;

&lt;P&gt;Thanks for the tips reported in this discussion!&lt;BR /&gt;
I was looking for a way, when you run a search, to split in new lines the _raw fields when you click on "Statistic" tab in order to have it displayed like in "Events" tab&lt;/P&gt;

&lt;P&gt;I have done in this way:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex max_match=0 "^(?&amp;lt;lines&amp;gt;.+)\n+" | eval raw2=mvindex(lines,0,-1) | table raw2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Best Regards,&lt;BR /&gt;
Edoardo&lt;/P&gt;</description>
    <pubDate>Tue, 12 Mar 2019 16:00:04 GMT</pubDate>
    <dc:creator>edoardo_vicendo</dc:creator>
    <dc:date>2019-03-12T16:00:04Z</dc:date>
    <item>
      <title>How to split a multi-line _raw to a multivalue with one line of text per element?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-multi-line-raw-to-a-multivalue-with-one-line-of/m-p/268327#M80714</link>
      <description>&lt;P&gt;I've tried inserting &lt;CODE&gt;eval first_line=mvindex(split(_raw,"\n"),0)&lt;/CODE&gt; in the pipeline, but that doesn't seem to do the trick.&lt;/P&gt;

&lt;P&gt;As far as I can tell, &lt;CODE&gt;"\n"&lt;/CODE&gt; does not actually denote a one-character string that is a newline. How can I do that?&lt;/P&gt;

&lt;P&gt;Since I'm trying to discard the remaining lines and am passing the result of the above through a &lt;CODE&gt;replace()&lt;/CODE&gt; anyway, I first tried a regex (directly on &lt;CODE&gt;_raw&lt;/CODE&gt;) ending with &lt;CODE&gt;(?:\n|.)*&lt;/CODE&gt; as recommended elsewhere, but that didn't work.&lt;/P&gt;

&lt;P&gt;At least with the above, I'm able to extract the desired field and replace the whole thing with just that field (for eval of a new variable) -- though I don't understand why, because when I change my &lt;CODE&gt;table&lt;/CODE&gt; to emit &lt;CODE&gt;first_line&lt;/CODE&gt; instead of &lt;CODE&gt;_raw&lt;/CODE&gt;, it still shows up with the subsequent, unwanted, lines.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 15:57:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-multi-line-raw-to-a-multivalue-with-one-line-of/m-p/268327#M80714</guid>
      <dc:creator>jcburley</dc:creator>
      <dc:date>2017-02-02T15:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a multi-line _raw to a multivalue with one line of text per element?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-multi-line-raw-to-a-multivalue-with-one-line-of/m-p/268328#M80715</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;P&gt;*&lt;EM&gt;Updated regex from &lt;CODE&gt;\n+&lt;/CODE&gt; to `\n&lt;/EM&gt;` **&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex max_match=0 "^(?&amp;lt;lines&amp;gt;.+)\n+" | eval first_line=mvindex(lines,0) | fields - lines
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Feb 2017 17:10:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-multi-line-raw-to-a-multivalue-with-one-line-of/m-p/268328#M80715</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-02T17:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a multi-line _raw to a multivalue with one line of text per element?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-multi-line-raw-to-a-multivalue-with-one-line-of/m-p/268329#M80716</link>
      <description>&lt;P&gt;Mostly worked, except sometimes there's only one line of trace, leading to no matches and blank lines as a result.&lt;/P&gt;

&lt;P&gt;Replacing &lt;CODE&gt;\n+&lt;/CODE&gt; with &lt;CODE&gt;\n*&lt;/CODE&gt; solved that problem.&lt;/P&gt;

&lt;P&gt;Thanks! (I'd still like to know why my other approaches didn't work, but at least I've got a working query....)&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 17:37:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-multi-line-raw-to-a-multivalue-with-one-line-of/m-p/268329#M80716</guid>
      <dc:creator>jcburley</dc:creator>
      <dc:date>2017-02-02T17:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a multi-line _raw to a multivalue with one line of text per element?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-multi-line-raw-to-a-multivalue-with-one-line-of/m-p/268330#M80717</link>
      <description>&lt;P&gt;The thing is the split function excepts string delimiter, and &lt;CODE&gt;\n&lt;/CODE&gt; is regular expression for line break (your logs will actually not contains char &lt;CODE&gt;\n&lt;/CODE&gt;), hence it fails. If you want that approach to work, you need to use a replace function to replace, regular expression way, line break with some unique string based on which you can split. Something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval first_line=mvindex(split(replace(_raw,"\n","#MyLINEBREAK#"),"#MyLINEBREAK#"),0)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Feb 2017 18:38:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-multi-line-raw-to-a-multivalue-with-one-line-of/m-p/268330#M80717</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-02T18:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a multi-line _raw to a multivalue with one line of text per element?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-multi-line-raw-to-a-multivalue-with-one-line-of/m-p/268331#M80718</link>
      <description>&lt;P&gt;Ah, so the lines in &lt;CODE&gt;_raw&lt;/CODE&gt; are not actually delimited by &lt;CODE&gt;\n&lt;/CODE&gt; (NL), but are treated that way for purposes of &lt;CODE&gt;replace()&lt;/CODE&gt; and so on? Interesting.&lt;/P&gt;

&lt;P&gt;Note that I hadn't intended the &lt;CODE&gt;"\n"&lt;/CODE&gt; to be a "regular expression for line break" but rather the C notation for a string containing NL (newline) as its sole character. I'm still not sure whether Splunk string constants are (even roughly) comparable to C string constants here; maybe that is interpreted as a two-character string consisting of Backslash followed by lower-case &lt;CODE&gt;n&lt;/CODE&gt;, which would make sense since, otherwise, we'd have to double-up backslashes in &lt;CODE&gt;replace()&lt;/CODE&gt; et al.&lt;/P&gt;

&lt;P&gt;(In languages like Fortran, there are functions that can compose strings having unprintable characters. E.g. &lt;CODE&gt;CHAR(10)&lt;/CODE&gt; would result in something quite similar to &lt;CODE&gt;'\n'&lt;/CODE&gt; in C. I couldn't find comparable functions in the Splunk reference....)&lt;/P&gt;

&lt;P&gt;Anyway, with the regex you posted updated (the old version still shows up, but your "Updated regex from..." message clarifies things), your answer works, thanks again!&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 19:19:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-multi-line-raw-to-a-multivalue-with-one-line-of/m-p/268331#M80718</guid>
      <dc:creator>jcburley</dc:creator>
      <dc:date>2017-02-02T19:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a multi-line _raw to a multivalue with one line of text per element?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-multi-line-raw-to-a-multivalue-with-one-line-of/m-p/268332#M80719</link>
      <description>&lt;P&gt;Ciao,&lt;/P&gt;

&lt;P&gt;Thanks for the tips reported in this discussion!&lt;BR /&gt;
I was looking for a way, when you run a search, to split in new lines the _raw fields when you click on "Statistic" tab in order to have it displayed like in "Events" tab&lt;/P&gt;

&lt;P&gt;I have done in this way:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex max_match=0 "^(?&amp;lt;lines&amp;gt;.+)\n+" | eval raw2=mvindex(lines,0,-1) | table raw2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Best Regards,&lt;BR /&gt;
Edoardo&lt;/P&gt;</description>
      <pubDate>Tue, 12 Mar 2019 16:00:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-multi-line-raw-to-a-multivalue-with-one-line-of/m-p/268332#M80719</guid>
      <dc:creator>edoardo_vicendo</dc:creator>
      <dc:date>2019-03-12T16:00:04Z</dc:date>
    </item>
  </channel>
</rss>

