<?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: Finding mismatched events in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54218#M13236</link>
    <description>&lt;P&gt;No matter what approach you use, you have a fundamental issue that is not easy to resolve.  When you are trying to match up a "begin event" and an "end event", one or the other could be outside of your search range.  And Splunk doesn't "see" what is outside of your search range.&lt;/P&gt;

&lt;P&gt;One option is to make your search range longer than the longest interval you can possibly have.  Possibly as much as double.  If you don't know how long your longest thing can be, then this can be difficult.&lt;/P&gt;

&lt;P&gt;Another option might be to maintain state via a lookup.  If your &lt;CODE&gt;api_transaction&lt;/CODE&gt; is unique over a long term, then this is viable.  See the Splunk blog post &lt;A href="http://blogs.splunk.com/2011/01/11/maintaining-state-of-the-union/"&gt;http://blogs.splunk.com/2011/01/11/maintaining-state-of-the-union/&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Sep 2012 16:36:47 GMT</pubDate>
    <dc:creator>dwaddle</dc:creator>
    <dc:date>2012-09-07T16:36:47Z</dc:date>
    <item>
      <title>Finding mismatched events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54209#M13227</link>
      <description>&lt;P&gt;We have distinct events for each phase of an incoming API call,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2012-09-07 01:12:59.691
category=api_request
api_transaction=303312599
...

2012-09-07 01:12:59.867
category=api_response
api_transaction=303312599
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I've been struggling to come up with a way of finding all "&lt;CODE&gt;api_request&lt;/CODE&gt;" events for which there is no matching "&lt;CODE&gt;api_response&lt;/CODE&gt;" event. The biggest issue I have is that in any specific date/time search range, things at the very start and the very end will not have a matching pair because it falls outside of those search boundaries (i.e. with &lt;CODE&gt;| transaction api_transaction&lt;/CODE&gt;). Any ideas would be much appreciated.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;[updated with clarification below]&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;To simplify this, assuming each transaction takes 2 seconds,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2012-09-07 01:02:59 api_request O
--- search start 2012-09-07 01:03:00
2012-09-07 01:03:01 api_response O
2012-09-07 01:03:30 api_request P
2012-09-07 01:03:32 api_response P
2012-09-07 01:03:45 api_request Q
2012-09-07 01:03:59 api_request R
--- search end 2012-09-07 01:04:00
2012-09-07 01:04:01 api_response R
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The search shouldn't return &lt;CODE&gt;api_response O&lt;/CODE&gt; and &lt;CODE&gt;api_request R&lt;/CODE&gt; as false positives, because their matching &lt;CODE&gt;api_request&lt;/CODE&gt; and &lt;CODE&gt;api_response&lt;/CODE&gt; lay outside of the boundaries of the search. What I'm looking for is that &lt;CODE&gt;api_request Q&lt;/CODE&gt; for which there is no matching &lt;CODE&gt;api_response&lt;/CODE&gt; event within the following X seconds.&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2012 13:09:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54209#M13227</guid>
      <dc:creator>bpopov</dc:creator>
      <dc:date>2012-09-07T13:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: Finding mismatched events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54210#M13228</link>
      <description>&lt;P&gt;Hm, I'm not sure that I follow you. If you just want to find them (and have sufficiently unique api_transaction IDs);&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your_sourcetype category=api_request OR category=api_response | stats c values(category) AS category by api_transaction | search c=1 api_request
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;should do.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;EDIT: there was an error before. Added &lt;CODE&gt;values(category)&lt;/CODE&gt; to the stats function so that it can be filtered on further down the line.&lt;/P&gt;

&lt;P&gt;Hope this helps,&lt;/P&gt;

&lt;P&gt;Kristian&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2012 13:32:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54210#M13228</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-09-07T13:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: Finding mismatched events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54211#M13229</link>
      <description>&lt;P&gt;see update above. /k&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2012 14:01:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54211#M13229</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-09-07T14:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: Finding mismatched events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54212#M13230</link>
      <description>&lt;P&gt;Kristian,&lt;/P&gt;

&lt;P&gt;Thanks for this, I'm getting somewhere, I think.&lt;/P&gt;

&lt;P&gt;Searching within one minute's span (2012-09-07 01:03),&lt;/P&gt;

&lt;P&gt;category=api_request OR category=api_response | stats c by api_transaction | search c=1 category=api_request&lt;/P&gt;

&lt;P&gt;696 matching events, 0 results&lt;/P&gt;

&lt;P&gt;category=api_request OR category=api_response | stats c by api_transaction | search c=1&lt;/P&gt;

&lt;P&gt;696 matching events, 5 results&lt;/P&gt;

&lt;P&gt;I guess the trick is that category qualifer in your example weeds out api_response entries at the beginning of 01:03 for which api_request entries came in earlier at 01:02?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:24:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54212#M13230</guid>
      <dc:creator>bpopov</dc:creator>
      <dc:date>2020-09-28T12:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: Finding mismatched events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54213#M13231</link>
      <description>&lt;P&gt;Yes, that is precisely why. Group the events by the ID, discard the ones that have request AND response, and then just output the requests without responses.&lt;/P&gt;

&lt;P&gt;Feel free to mark the question a answered a/o upvote if this solved your problem&lt;/P&gt;

&lt;P&gt;/k&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2012 14:19:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54213#M13231</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-09-07T14:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: Finding mismatched events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54214#M13232</link>
      <description>&lt;P&gt;Hm, the updated query shows false positives, for example it includes one api_response (api_transaction=303287874) where the api_request was actually logged in the minute prior to the start of the search range (limited to 01:03 minute).&lt;/P&gt;

&lt;P&gt;category=api_request OR category=api_response | stats c values(category) AS category by api_transaction | search c=1 api_request&lt;/P&gt;

&lt;P&gt;696 matching events, 6 results (2 api_response and 4 api_request)&lt;/P&gt;

&lt;P&gt;2012-09-07 01:03:00.390&lt;BR /&gt;
   category=api_response&lt;BR /&gt;
   api_transaction=303287874&lt;/P&gt;

&lt;P&gt;2012-09-07 01:02:59.619&lt;BR /&gt;
   category=api_request&lt;BR /&gt;
   api_transaction=303287874&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:24:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54214#M13232</guid>
      <dc:creator>bpopov</dc:creator>
      <dc:date>2020-09-28T12:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: Finding mismatched events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54215#M13233</link>
      <description>&lt;P&gt;seems weird. if you just remove the "api_request" from the very last part of the search, does it make a difference?&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2012 14:30:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54215#M13233</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-09-07T14:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Finding mismatched events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54216#M13234</link>
      <description>&lt;P&gt;That returns exactly the same results still...&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2012 14:39:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54216#M13234</guid>
      <dc:creator>bpopov</dc:creator>
      <dc:date>2012-09-07T14:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: Finding mismatched events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54217#M13235</link>
      <description>&lt;P&gt;Please see updated section in the original Q. Thanks for your help so far. I wonder if I'm expecting to be able to do something that simply isn't possible.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2012 14:46:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54217#M13235</guid>
      <dc:creator>bpopov</dc:creator>
      <dc:date>2012-09-07T14:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: Finding mismatched events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54218#M13236</link>
      <description>&lt;P&gt;No matter what approach you use, you have a fundamental issue that is not easy to resolve.  When you are trying to match up a "begin event" and an "end event", one or the other could be outside of your search range.  And Splunk doesn't "see" what is outside of your search range.&lt;/P&gt;

&lt;P&gt;One option is to make your search range longer than the longest interval you can possibly have.  Possibly as much as double.  If you don't know how long your longest thing can be, then this can be difficult.&lt;/P&gt;

&lt;P&gt;Another option might be to maintain state via a lookup.  If your &lt;CODE&gt;api_transaction&lt;/CODE&gt; is unique over a long term, then this is viable.  See the Splunk blog post &lt;A href="http://blogs.splunk.com/2011/01/11/maintaining-state-of-the-union/"&gt;http://blogs.splunk.com/2011/01/11/maintaining-state-of-the-union/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2012 16:36:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54218#M13236</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2012-09-07T16:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: Finding mismatched events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54219#M13237</link>
      <description>&lt;P&gt;Not sure if this is resolved, but posting my answer&lt;/P&gt;

&lt;P&gt;ur basesearch | transaction api_transaction startswith="api_request" endswith="api_response" unifyends=true &lt;/P&gt;

&lt;P&gt;this transaction will make sure, it MUST contain both startwith and endswith and ignores the events if either request or response is not present in any any transaction even it is present during the specified time span. &lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:29:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54219#M13237</guid>
      <dc:creator>sgundeti</dc:creator>
      <dc:date>2020-09-28T18:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: Finding mismatched events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54220#M13238</link>
      <description>&lt;P&gt;You could do the transaction route or add in a dc(category) to whatever else you need in your stats command. In your next pipe just limit your search to where that field = 2 assuming each event will have 2 categories; request/response. This should run pretty quickly as well.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 01:59:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-mismatched-events/m-p/54220#M13238</guid>
      <dc:creator>Runals</dc:creator>
      <dc:date>2014-12-23T01:59:27Z</dc:date>
    </item>
  </channel>
</rss>

