<?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 How to split a transaction? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-transaction/m-p/65160#M16138</link>
    <description>&lt;P&gt;I'm using&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;transaction ... | search duration&amp;gt;x
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;to eliminate some noise, but then I want to break the events back out of the transaction and use stats against what is left.  I was thinking mvexpand would help me, but I'm not having any luck.&lt;/P&gt;</description>
    <pubDate>Wed, 23 Mar 2011 00:55:37 GMT</pubDate>
    <dc:creator>vbumgarner</dc:creator>
    <dc:date>2011-03-23T00:55:37Z</dc:date>
    <item>
      <title>How to split a transaction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-transaction/m-p/65160#M16138</link>
      <description>&lt;P&gt;I'm using&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;transaction ... | search duration&amp;gt;x
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;to eliminate some noise, but then I want to break the events back out of the transaction and use stats against what is left.  I was thinking mvexpand would help me, but I'm not having any luck.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2011 00:55:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-transaction/m-p/65160#M16138</guid>
      <dc:creator>vbumgarner</dc:creator>
      <dc:date>2011-03-23T00:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a transaction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-transaction/m-p/65161#M16139</link>
      <description>&lt;P&gt;mvexpand wont do it because mvexpand only works on multivalued fields. &lt;/P&gt;

&lt;P&gt;&lt;A href="http://www.splunk.com/base/Documentation/latest/SearchReference/Mvexpand" rel="nofollow"&gt;http://www.splunk.com/base/Documentation/latest/SearchReference/Mvexpand&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;you can however turn the event text (technically the field is called _raw)  into a multivalued field with &lt;CODE&gt;eval split(_raw, "\n")&lt;/CODE&gt; though. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; | eval _raw = split(_raw, "\n") | mvexpand _raw
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Mar 2011 08:08:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-transaction/m-p/65161#M16139</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2011-03-23T08:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a transaction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-transaction/m-p/65162#M16140</link>
      <description>&lt;P&gt;Here's an alternative method using &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/rex" target="_blank"&gt;rex&lt;/A&gt;.&lt;/P&gt;

&lt;P&gt;For testing purposes let's associate events from metrics.log in clumps of 4 with :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal source=*metrics.log | transaction maxevents=4 source&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This yields transaction meta-events that look like this :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;
12-29-2011 08:51:52.940 -0800 INFO  Metrics - group=queue, name=tcpin_queue, max_size_kb=500, current_size_kb=0, current_size=0, largest_size=0, smallest_size=0
12-29-2011 08:51:52.940 -0800 INFO  Metrics - group=queue, name=typingqueue, max_size_kb=500, current_size_kb=0, current_size=0, largest_size=58, smallest_size=0
12-29-2011 08:51:52.940 -0800 INFO  Metrics - group=realtime_search_data, system total, drop_count=0
12-29-2011 08:51:52.940 -0800 INFO  Metrics - group=search_concurrency, system total, active_hist_searches=0, active_realtime_searches=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;To get the original &lt;CODE&gt;_raw&lt;/CODE&gt; field back (and therefore, display the original events) I use rex with a "delimiter" regex matching the date at the beginning of my event, and then all characters until a CLRF. This creates one multi-value field per transaction containing the pre-transaction values of &lt;CODE&gt;_raw&lt;/CODE&gt;, which we can then expand back to a single-value field with &lt;CODE&gt;mvexpand&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal source=*metrics.log | transaction maxevents=4 source | eval transaction_raw=_raw | rex max_match=1000 "(?msi)^(?&lt;RAW&gt;[01]\d-[0-3]\d-2011\s[^\r\n]*?)$" | mvexpand raw | eval _raw=raw&lt;/RAW&gt;&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Remarks :&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;For the delimiter regex to work, you need to specify &lt;CODE&gt;max_match&lt;/CODE&gt; with a value equal to or higher than the maximum number of events you expect in your transaction.&lt;/LI&gt;
&lt;LI&gt;The regex will need to be reworked if your original events span multiple lines.&lt;/LI&gt;
&lt;LI&gt;A transition field (here &lt;CODE&gt;raw&lt;/CODE&gt;) is necessary. You cannot restore &lt;CODE&gt;_raw&lt;/CODE&gt; directly unto itself.&lt;/LI&gt;
&lt;LI&gt;We conserved the transaction's own &lt;CODE&gt;_raw&lt;/CODE&gt; in &lt;CODE&gt;transaction_raw&lt;/CODE&gt; which allows to still report on the transaction results. The transaction special fields are also conserved.&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Mon, 28 Sep 2020 10:15:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-transaction/m-p/65162#M16140</guid>
      <dc:creator>hexx</dc:creator>
      <dc:date>2020-09-28T10:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to split a transaction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-transaction/m-p/65163#M16141</link>
      <description>&lt;P&gt;The other answers here seemed to have focused on raw.  I'm not sure why, because the question said he wants to do stats.  Regardless, the other answers are now unnecessarily convoluted.  In 4.3 we added the "&lt;STRONG&gt;mvraw=true&lt;/STRONG&gt;" option to transaction, so _raw can be a true multivalued field.  &lt;/P&gt;

&lt;P&gt;Regarding stats, mvexpand should work fine.  It's unclear what probably the questioner had with it.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2012 16:35:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-a-transaction/m-p/65163#M16141</guid>
      <dc:creator>carasso</dc:creator>
      <dc:date>2012-04-10T16:35:21Z</dc:date>
    </item>
  </channel>
</rss>

