<?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: Help with transaction ! in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Help-with-transaction/m-p/311634#M161506</link>
    <description>&lt;P&gt;@dmenon84... few things to take care&lt;/P&gt;

&lt;P&gt;1) Stats is more suitable for your use case compared to transaction&lt;BR /&gt;
2) Filter results upfront so add subject=*, action and score criteria for discard and continue in your base search&lt;BR /&gt;
3) Subject should also be part of your aggregation clause&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex  subject=* (action=discard AND scores&amp;gt;80) OR (action=continue AND score&amp;lt;80)
| stats count as eventcount list(action) as action list(score) as score dc(action) as actioncount by x, s,subject
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Try this and let us know how it goes.&lt;/P&gt;</description>
    <pubDate>Wed, 05 Apr 2017 20:12:20 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-04-05T20:12:20Z</dc:date>
    <item>
      <title>Help with transaction !</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-transaction/m-p/311632#M161504</link>
      <description>&lt;P&gt;Hi , &lt;/P&gt;

&lt;P&gt;I have following query written but it is not giving me correct output. So my logs would look like this &lt;/P&gt;

&lt;P&gt;subject action  score   x   s&lt;BR /&gt;
Hello   continue    40  234 585&lt;BR /&gt;
Hello   discard 80  234 585&lt;/P&gt;

&lt;P&gt;My query &lt;BR /&gt;
    index=myindex (action=discard OR action=continue )  | transaction x s  keepevicted=true startswith=eval(action="continue") endswith=eval(action="discard") | search subject=*  | stats values(action) AS action,dc(action) AS actioncount by subject | where actioncount=2&lt;/P&gt;

&lt;P&gt;It gives me info but its usually the once that are discarded first and continued later. I am trying to get info for other way round. &lt;/P&gt;

&lt;P&gt;So anything that scores above 80 have action=discard so I want to get alerted on all subjects that had score below 80 and had action=continue but later score went above 80 and now action=discard.  The logs are split in several line hence a transaction of 'x' and 's' is required to combine the logs. &lt;/P&gt;

&lt;P&gt;Thanks in advance for any help !&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 19:44:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-transaction/m-p/311632#M161504</guid>
      <dc:creator>dmenon84</dc:creator>
      <dc:date>2017-04-05T19:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: Help with transaction !</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-transaction/m-p/311633#M161505</link>
      <description>&lt;P&gt;try editing the startswith/endswith and add an mvlist to keep the events in stats in the right order.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex (action=discard OR action=continue ) | transaction x s keepevicted=true startswith=eval(match(action,"continue")) endswith=eval(match(action,"discard")) mvlist=t | search subject=* | stats list(action) AS action, dc(action) AS actioncount by subject | where actioncount=2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex (action=discard OR action=continue )|sort 0 x s + _time |streamstats window=1 current=f values(action) as previousAction by x s| stats values(action) as action values(previousAction) as previousAction values(x) as x values(s) as s by subject |search action="discard" previousAction="continue"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Apr 2017 19:59:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-transaction/m-p/311633#M161505</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-04-05T19:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: Help with transaction !</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-transaction/m-p/311634#M161506</link>
      <description>&lt;P&gt;@dmenon84... few things to take care&lt;/P&gt;

&lt;P&gt;1) Stats is more suitable for your use case compared to transaction&lt;BR /&gt;
2) Filter results upfront so add subject=*, action and score criteria for discard and continue in your base search&lt;BR /&gt;
3) Subject should also be part of your aggregation clause&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex  subject=* (action=discard AND scores&amp;gt;80) OR (action=continue AND score&amp;lt;80)
| stats count as eventcount list(action) as action list(score) as score dc(action) as actioncount by x, s,subject
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Try this and let us know how it goes.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 20:12:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-transaction/m-p/311634#M161506</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-04-05T20:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: Help with transaction !</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-transaction/m-p/311635#M161507</link>
      <description>&lt;P&gt;Thanks for helping . Sorry for delay in response, I got caught up in other projects. So this query works some what but I am not getting the scores. This is actually due to the info I provided. Here is how logs look.  The action and score are not in same log event so will it still work without transaction. &lt;/P&gt;

&lt;P&gt;May 10 08:39:40  s=200 m=1 x=200-1 mod=mail cmd=env_from from=emailaddress to=emailaddressto host=hostname ip=externalsenderip &lt;BR /&gt;
May 10 08:39:41  s=200 m=1 x=200-1 mod=spam cmd=run score=74 &lt;BR /&gt;
May 10 08:39:41 s=200 m=1 x=200-1 mod=mail cmd=msg rule=pass action=continue attachments=0 rcpts=1 hops-ip=ipaddress subject="My email subject" &lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 14:58:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-transaction/m-p/311635#M161507</guid>
      <dc:creator>dmenon84</dc:creator>
      <dc:date>2017-05-10T14:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: Help with transaction !</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-transaction/m-p/311636#M161508</link>
      <description>&lt;P&gt;Yes, aggregate clauses in splunk (like &lt;CODE&gt;stats values(x)&lt;/CODE&gt;)  do not require every event to have field &lt;CODE&gt;x&lt;/CODE&gt;, it just counts, aggregates, averages, or lists the values that are there, for all records that have the same values in the fields in the &lt;CODE&gt;by&lt;/CODE&gt; clause. &lt;/P&gt;

&lt;P&gt;Since subject is only in one record, you'll want to move it out of the &lt;CODE&gt;by&lt;/CODE&gt; clause in with the aggregate clauses.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count as eventcount, list(action) as action, list(subject) as subject, list(score) as score dc(action) as actioncount by x, s
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 May 2017 15:33:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-transaction/m-p/311636#M161508</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-05-10T15:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: Help with transaction !</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-transaction/m-p/311637#M161509</link>
      <description>&lt;P&gt;Thanks that worked well. I just added a where clause at end to see only the ones that were continued &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | stats count as eventcount, list(action) as action, list(subject) as subject, list(score) as score dc(action) as actioncount by x, s | where action="continue"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now I am trying to group by subject , can you please guide on that as well. I want to group by subject and want to see only columns &lt;BR /&gt;
subject action score &lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 19:18:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-transaction/m-p/311637#M161509</guid>
      <dc:creator>dmenon84</dc:creator>
      <dc:date>2017-05-10T19:18:38Z</dc:date>
    </item>
    <item>
      <title>Re: Help with transaction !</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-transaction/m-p/311638#M161510</link>
      <description>&lt;P&gt;Once correlated you should have only one value for action, subject and score for each combination of x and s (which are composite key in this case)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   | stats count as eventcount, values(action) as action, values(subject) as subject, values(score) as score dc(action) as actioncount by x, s 
   | search action="continue"
   | table subject action score
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 May 2017 10:25:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-transaction/m-p/311638#M161510</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-05-11T10:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: Help with transaction !</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-transaction/m-p/311639#M161511</link>
      <description>&lt;P&gt;I have some cases where subject is same but x,s and score are different. It would be nice to be able to group by subject , sender etc . I have done this using transaction but with stats I am not having much luck. &lt;/P&gt;

&lt;P&gt;2a9a93527r  2a9a93527r-1    4   continue    RE: more space  43  1&lt;BR /&gt;
2a9a9352m4  2a9a9352m4-1    4   continue    RE: more space     45    1&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 14:36:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-transaction/m-p/311639#M161511</guid>
      <dc:creator>dmenon84</dc:creator>
      <dc:date>2017-05-11T14:36:53Z</dc:date>
    </item>
  </channel>
</rss>

