<?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 can I incorporate the transaction command along with startswith and endswith? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-incorporate-the-transaction-command-along-with/m-p/351499#M104046</link>
    <description>&lt;P&gt;Adding the transaction command at the end of the search doesn't produce any results for me.  It's only when I add it after index=blah sourcetype=linux_secure process=sshd  so I see any results.&lt;/P&gt;</description>
    <pubDate>Mon, 06 Nov 2017 19:36:27 GMT</pubDate>
    <dc:creator>SplunkLunk</dc:creator>
    <dc:date>2017-11-06T19:36:27Z</dc:date>
    <item>
      <title>How can I incorporate the transaction command along with startswith and endswith?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-incorporate-the-transaction-command-along-with/m-p/351495#M104042</link>
      <description>&lt;P&gt;So I saw someone did a query for Linux systems on failed sshd logins followed by a successful sshd login using the transaction command.  This would potentially help discover passwords that have been compromised via brute force, guessing, etc.  If I have the following search:&lt;/P&gt;

&lt;P&gt;index=blah sourcetype=linux_secure process=sshd "tag::action"=success&lt;BR /&gt;
|rename _time AS Time src AS Source, dest AS Destination, user AS User&lt;BR /&gt;
|iplocation Source&lt;BR /&gt;
|table Time, Source, Destination, User, City, Region, Country&lt;BR /&gt;
|convert timeformat="%a %b %d, %Y %I:%M:%S %p" ctime(Time) As Time &lt;/P&gt;

&lt;P&gt;Can anyone tell me how I would incorporate the transaction command along with startswith (failure I'm guessing) and endswith (success)?  I've been testing with what I think is the correct syntax and haven't been successful.  Thanks for any help.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2017 19:02:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-incorporate-the-transaction-command-along-with/m-p/351495#M104042</guid>
      <dc:creator>SplunkLunk</dc:creator>
      <dc:date>2017-11-03T19:02:07Z</dc:date>
    </item>
    <item>
      <title>Re: How can I incorporate the transaction command along with startswith and endswith?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-incorporate-the-transaction-command-along-with/m-p/351496#M104043</link>
      <description>&lt;P&gt;So in your main search, you should NOT put success filter, but rather it should be broad search. Please note, the field names I'm not sure for your data, so I've put as arbitary names&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=blah sourcetype=linux_secure process=sshd 
|rename _time AS Time src AS Source, dest AS Destination, user AS User
|iplocation Source
|table Time, Source, Destination, User, City, Region, Country
| transaction process maxspan=30s maxpause=5s startswith="failure" endswith="success"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Below is an example. Assume that two events&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;11-03-2017 22:49:01.642 +0000 INFO  Metrics - group=queue, name=typingqueue, max_size_kb=500, current_size_kb=0, current_size=0, largest_size=31, smallest_size=0
11-03-2017 22:49:01.642 +0000 INFO  Metrics - group=queue, name=tcpin_queue, max_size_kb=500, current_size_kb=0, current_size=0, largest_size=0, smallest_size=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Say that we need to identify both of them and then stitch together if the &lt;CODE&gt;group&lt;/CODE&gt; are the same and which starts with &lt;CODE&gt;tcpin_queue&lt;/CODE&gt; and ends with &lt;CODE&gt;typingqueue&lt;/CODE&gt;. The search would be something like.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal sourcetype=splunkd
| transaction group maxspan=30s maxpause=5s startswith="tcpin_queue" endswith="typingqueue"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can put &lt;CODE&gt;maxspan&lt;/CODE&gt; and &lt;CODE&gt;maxpause&lt;/CODE&gt; to make it more accurate. Reference: &lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/Transaction"&gt;https://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/Transaction&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2017 23:00:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-incorporate-the-transaction-command-along-with/m-p/351496#M104043</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2017-11-03T23:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: How can I incorporate the transaction command along with startswith and endswith?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-incorporate-the-transaction-command-along-with/m-p/351497#M104044</link>
      <description>&lt;P&gt;@SplunkLunk, please provide some sample data for both events you want to correlate. Do you have &lt;CODE&gt;"tag::action"="failure"&lt;/CODE&gt; as well in your data?&lt;/P&gt;

&lt;P&gt;Ideally formatting/enrichment of data should happen towards the end of your query. While transaction is ideal for startswith and endswith scenario, similar query with stats might actually perform better based on how far apart are the events within transaction and what is the total search duration&lt;/P&gt;

&lt;P&gt;You would also need to define what is the key for creating a transaction, is it a combination or &lt;CODE&gt;src, dest and user&lt;/CODE&gt;?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=blah sourcetype=linux_secure process=sshd ("tag::action"="success" OR "tag::action"="success")
| stats count as eventcount min(_time) as _time max(_time) as EndTime list("tag::action") as action by src dest user
| search eventcount&amp;gt;1  action="success" and action="failure"
| eval firstAction=mvindex(action,eventcount-1)
| eval lastAction=mvindex(action,0)
| search firstAction="success" AND lastAction="failure"
| eval duration=EndTime-_time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 05 Nov 2017 15:24:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-incorporate-the-transaction-command-along-with/m-p/351497#M104044</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-11-05T15:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: How can I incorporate the transaction command along with startswith and endswith?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-incorporate-the-transaction-command-along-with/m-p/351498#M104045</link>
      <description>&lt;P&gt;Thanks.  I did not have "tag::action"="failure" in there as I wasn't sure of the syntax.  I originally just wanted to know about successful logins.  Then I thought about failed followed by success to possibly identify password guessing.  So I came here to ask the best way to do that.  I'm assuming you mean to add "tag::action"="failure" and not have two "tag::action"="success" in your above search?&lt;/P&gt;

&lt;P&gt;My key for creating a transaction I suppose would be user.  I'm interested in a user whose account has login failures followed by a successful login.  Also, is it possible to query for five+ unsuccessful logins followed by a success?  I'm assuming I'd have to use a timespan or run the search every "X" minutes for the last "X" minutes.  My span would depend on what I consider an acceptable window to looks at failures?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 19:20:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-incorporate-the-transaction-command-along-with/m-p/351498#M104045</guid>
      <dc:creator>SplunkLunk</dc:creator>
      <dc:date>2017-11-06T19:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: How can I incorporate the transaction command along with startswith and endswith?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-incorporate-the-transaction-command-along-with/m-p/351499#M104046</link>
      <description>&lt;P&gt;Adding the transaction command at the end of the search doesn't produce any results for me.  It's only when I add it after index=blah sourcetype=linux_secure process=sshd  so I see any results.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 19:36:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-incorporate-the-transaction-command-along-with/m-p/351499#M104046</guid>
      <dc:creator>SplunkLunk</dc:creator>
      <dc:date>2017-11-06T19:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: How can I incorporate the transaction command along with startswith and endswith?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-incorporate-the-transaction-command-along-with/m-p/351500#M104047</link>
      <description>&lt;P&gt;Thanks @SplunkLunk, I did a typo and meant filter in the base search for actions which are either "success" or "failure"&lt;BR /&gt;
The reason for key was, if you do not also split by src and dest fields per user you may have multiple src and destination which you should capture based on either &lt;CODE&gt;list()&lt;/CODE&gt; or &lt;CODE&gt;values()&lt;/CODE&gt; (whichever is applicable).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=blah sourcetype=linux_secure process=sshd ("tag::action"="success" OR "tag::action"="failure")
 | stats count as eventcount min(_time) as _time max(_time) as EndTime list("tag::action") as action list(src) as Source list(dest) as destination user 
 | search eventcount&amp;gt;1  action="success" and action="failure"
 | eval firstAction=mvindex(action,eventcount-1)
 | eval lastAction=mvindex(action,0)
 | search firstAction="success" AND lastAction="failure"
 | eval duration=EndTime-_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If your use case is five success followed by a failure then your scenario would be quite different. &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Option 1:&lt;/STRONG&gt; Ideally you would need to use &lt;CODE&gt;streamstats&lt;/CODE&gt; which requires you to first ensure that your results are sorted ascending or descending order of time.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Option 2:&lt;/STRONG&gt; With the approach provided with stats for transaction you can check first action is &lt;CODE&gt;failure&lt;/CODE&gt; and last action is &lt;CODE&gt;success&lt;/CODE&gt; and in total there are five or more &lt;CODE&gt;failure&lt;/CODE&gt;/s and only one &lt;CODE&gt;success&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 19:38:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-incorporate-the-transaction-command-along-with/m-p/351500#M104047</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-11-06T19:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: How can I incorporate the transaction command along with startswith and endswith?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-incorporate-the-transaction-command-along-with/m-p/351501#M104048</link>
      <description>&lt;P&gt;Option 2 sounds like that's what I would want.  What would that search look like?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 20:35:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-incorporate-the-transaction-command-along-with/m-p/351501#M104048</guid>
      <dc:creator>SplunkLunk</dc:creator>
      <dc:date>2017-11-06T20:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: How can I incorporate the transaction command along with startswith and endswith?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-incorporate-the-transaction-command-along-with/m-p/351502#M104049</link>
      <description>&lt;P&gt;Okay, so this search sort of gets at what I'm looking for I think:&lt;/P&gt;

&lt;P&gt;index=blah  sourcetype=linux_secure process=sshd ("tag::action"="success" OR "tag::action"="failure")&lt;BR /&gt;
|transaction user, src maxspan=30s maxpause=5s startswith=action="failure" endswith=action="success"&lt;BR /&gt;
|table _time,user, src, dest, action&lt;/P&gt;

&lt;P&gt;However, that shows me one failure followed by a success during that timespan.  How would I check for five failed logins followed by success within that timespan (or longer as I would likely push it out)?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 20:46:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-incorporate-the-transaction-command-along-with/m-p/351502#M104049</guid>
      <dc:creator>SplunkLunk</dc:creator>
      <dc:date>2017-11-06T20:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: How can I incorporate the transaction command along with startswith and endswith?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-incorporate-the-transaction-command-along-with/m-p/351503#M104050</link>
      <description>&lt;P&gt;Would this work?&lt;/P&gt;

&lt;P&gt;index=blah sourcetype=linux_secure process=sshd ("tag::action"="success" OR "tag::action"="failure")&lt;BR /&gt;
|transaction user, src, dest maxspan=60s maxpause=5s startswith=action="failure" endswith=action="success"&lt;BR /&gt;
|where eventcount&amp;gt;=6&lt;BR /&gt;
|table _time,user, src, dest, action&lt;/P&gt;

&lt;P&gt;It may generate some false positives if there is a success mixed in the 60s span, but if I scope the span low enough (but still reasonable), there probably wouldn't be too many false positives if someone was trying to brute force.  Thoughts?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 21:15:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-incorporate-the-transaction-command-along-with/m-p/351503#M104050</guid>
      <dc:creator>SplunkLunk</dc:creator>
      <dc:date>2017-11-06T21:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: How can I incorporate the transaction command along with startswith and endswith?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-incorporate-the-transaction-command-along-with/m-p/351504#M104051</link>
      <description>&lt;P&gt;When I run the above search, results appear briefly in that stats tab and then disappear.  Any idea why?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 21:25:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-incorporate-the-transaction-command-along-with/m-p/351504#M104051</guid>
      <dc:creator>SplunkLunk</dc:creator>
      <dc:date>2017-11-06T21:25:00Z</dc:date>
    </item>
  </channel>
</rss>

