<?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: Why does the Transaction command return multiple results? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Transaction-command-return-multiple-results/m-p/355255#M105118</link>
    <description>&lt;P&gt;If you don't care about intermediate transaction events, why don't you exclude them from base search. Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="my_index" MESSAGE="Starting Message" OR MESSAGE="Ending Message"| transaction FIELD startswith=eval(MESSAGE="Starting Message") endswith=eval(MESSAGE="Ending Message") | table FIELD, eventcount
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 28 Apr 2017 18:28:46 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2017-04-28T18:28:46Z</dc:date>
    <item>
      <title>Why does the Transaction command return multiple results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Transaction-command-return-multiple-results/m-p/355254#M105117</link>
      <description>&lt;P&gt;Hello!&lt;BR /&gt;
I am working with the &lt;CODE&gt;transaction&lt;/CODE&gt; command.  I am passing a field and using &lt;CODE&gt;startswith&lt;/CODE&gt; and &lt;CODE&gt;endswith&lt;/CODE&gt; definition options.  When I run it, though, the output produces two results per transaction.  The first contains all events in the transaction while the second, the one I'm looking for, contains the events specified in the definition options.  To provide a simplified example, the events in a transaction are as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time,FIELD,MESSAGE
28/04/2017 00:00:01,FIELD1,Starting Message
28/04/2017 00:00:02,FIELD1,Intermediate Message 1
28/04/2017 00:00:03,FIELD1,Intermediate Message 2
28/04/2017 00:00:04,FIELD1,Intermediate Message 3
28/04/2017 00:00:05,FIELD1,Ending Message
28/04/2017 00:00:11,FIELD2,Starting Message
28/04/2017 00:00:12,FIELD2,Intermediate Message 1
28/04/2017 00:00:13,FIELD2,Intermediate Message 2
28/04/2017 00:00:14,FIELD2,Intermediate Message 3
28/04/2017 00:00:15,FIELD2,Ending Message
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The search is then:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="my_index" | transaction FIELD startswith=eval(MESSAGE="Starting Message") endswith=eval(MESSAGE="Ending Message") | table FIELD, eventcount
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which produces the following table:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;FIELD,eventcount
FIELD1,5
FIELD1,2
FIELD2,5
FIELD2,2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Instead, I was expecting&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;FIELD,eventcount
FIELD1,2
FIELD2,2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do I ensure that only the transaction containing the &lt;CODE&gt;startswith&lt;/CODE&gt; and &lt;CODE&gt;endswith&lt;/CODE&gt; events is returned?&lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;

&lt;P&gt;Andrew&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2017 18:15:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Transaction-command-return-multiple-results/m-p/355254#M105117</guid>
      <dc:creator>andrewtrobec</dc:creator>
      <dc:date>2017-04-28T18:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the Transaction command return multiple results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Transaction-command-return-multiple-results/m-p/355255#M105118</link>
      <description>&lt;P&gt;If you don't care about intermediate transaction events, why don't you exclude them from base search. Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="my_index" MESSAGE="Starting Message" OR MESSAGE="Ending Message"| transaction FIELD startswith=eval(MESSAGE="Starting Message") endswith=eval(MESSAGE="Ending Message") | table FIELD, eventcount
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Apr 2017 18:28:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Transaction-command-return-multiple-results/m-p/355255#M105118</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-04-28T18:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the Transaction command return multiple results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Transaction-command-return-multiple-results/m-p/355256#M105119</link>
      <description>&lt;P&gt;Thanks for the response.  This does work, and is a good solution.  Maybe I'm not understanding the &lt;CODE&gt;transaction&lt;/CODE&gt; function properly, but I thought that it would filter out the events automatically using the &lt;CODE&gt;startswith&lt;/CODE&gt; and &lt;CODE&gt;endswith&lt;/CODE&gt; definition options.&lt;/P&gt;

&lt;P&gt;EDIT: Now that I've run the solution I get the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;FIELD,eventcount
FIELD1,2
FIELD1,2
FIELD2,2
FIELD2,2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So it still produces a double transaction for each FIELD value...&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2017 19:00:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Transaction-command-return-multiple-results/m-p/355256#M105119</guid>
      <dc:creator>andrewtrobec</dc:creator>
      <dc:date>2017-04-28T19:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the Transaction command return multiple results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Transaction-command-return-multiple-results/m-p/355257#M105120</link>
      <description>&lt;P&gt;Remember, in splunk, unless you specify otherwise, events naturally come out with the MOST RECENT FIRST.&lt;/P&gt;

&lt;P&gt;So, splunk is finding the end of a transaction with a value of FIELD1, then it's finding the beginning of what it thinks is ANOTHER transaction with value FIELD1.   &lt;/P&gt;

&lt;P&gt;add &lt;CODE&gt;|reverse&lt;/CODE&gt; or &lt;CODE&gt;|sort 0 _time&lt;/CODE&gt; immediately before the transaction command.  Bonus points for &lt;CODE&gt;|sort 0 _time FIELD&lt;/CODE&gt;, since it's effectively going to have to do that anyway.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2017 20:59:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Transaction-command-return-multiple-results/m-p/355257#M105120</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-04-28T20:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the Transaction command return multiple results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Transaction-command-return-multiple-results/m-p/355258#M105121</link>
      <description>&lt;P&gt;If you just run your base search, how many events you get? &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="my_index" MESSAGE="Starting Message" OR MESSAGE="Ending Message"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Apr 2017 21:04:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Transaction-command-return-multiple-results/m-p/355258#M105121</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-04-28T21:04:42Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the Transaction command return multiple results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Transaction-command-return-multiple-results/m-p/355259#M105122</link>
      <description>&lt;P&gt;Thanks for your input.  Just like to add: if I run the command as &lt;CODE&gt;index="my_index" | transaction FIELD&lt;/CODE&gt;  then it creates the transactions and puts them in chronological order.  I figured that using &lt;CODE&gt;startswith&lt;/CODE&gt; and &lt;CODE&gt;endswith&lt;/CODE&gt; would do the same thing, but exclude all evens in between.  Is this the wrong understanding of the command?&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2017 21:48:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Transaction-command-return-multiple-results/m-p/355259#M105122</guid>
      <dc:creator>andrewtrobec</dc:creator>
      <dc:date>2017-04-28T21:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the Transaction command return multiple results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Transaction-command-return-multiple-results/m-p/355260#M105123</link>
      <description>&lt;P&gt;I believe on faith that there may be someone who &lt;STRONG&gt;fully&lt;/STRONG&gt; understands the &lt;CODE&gt;transaction&lt;/CODE&gt; command, but I haven't met him or her yet.  My experience here tells me that it is reckless to post any "solution" code containing the verb &lt;CODE&gt;transaction&lt;/CODE&gt; unless you have mocked up test data, because the verb is terribly finnicky and people's real data is even more squirrelly than you can mock up in a reasonable amount of time.&lt;/P&gt;

&lt;P&gt;Key points i do know... &lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;P&gt;&lt;CODE&gt;startswith&lt;/CODE&gt; does not mean the earliest &lt;CODE&gt;_time&lt;/CODE&gt;, it means the first transaction encountered by splunk.  Apply the reverse logic for &lt;CODE&gt;endswith&lt;/CODE&gt;.&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;&lt;CODE&gt;maxspan&lt;/CODE&gt; and &lt;CODE&gt;maxpause&lt;/CODE&gt; do not work the way I would expect.  When I attempt to use them both, &lt;CODE&gt;maxspan&lt;/CODE&gt; appears to be limited to the length of &lt;CODE&gt;maxpause&lt;/CODE&gt;  Or I may be hallucinating that, but I can't get it to act with, say, transactions that last 2 hours but can't pause more than 10 minutes between events.  &lt;/P&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Fri, 28 Apr 2017 23:12:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Transaction-command-return-multiple-results/m-p/355260#M105123</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-04-28T23:12:45Z</dc:date>
    </item>
  </channel>
</rss>

