<?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: Using Splunk query with transaction in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Using-Splunk-query-with-transaction/m-p/365491#M107786</link>
    <description>&lt;P&gt;Assuming they were individual events before the &lt;CODE&gt;transaction&lt;/CODE&gt;, get rid of the &lt;CODE&gt;transaction&lt;/CODE&gt; and do it this way...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo  ("Status Code is" OR "HTTP")

| rename COMMENT as "extract thread, url and status, frop all other fields but _time"
| rex  "INFO\s+\((?&amp;lt;myThread&amp;gt;[^:\)]*:)\)\s*(HTTP url : (?&amp;lt;myURL&amp;gt;.*?)\s+?|:Status Code is:(?&amp;lt;myStatus&amp;gt;\d{3})\s+?)"
| fields _time myThread myURL myStatus

| rename COMMENT as "sort into thread /time order then roll URL and start time foreward onto response record"
| sort 0 myThread _time
| streamstats current=f last(_time) as lasttime last(myURL) as lastURL by myThread

| rename COMMENT as "Drop all records but the response, calculate response time"
| where isnotnull(myStatus) 
| eval resptime = _time - lasttime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should give records that look like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| fields _time myThread lastURL myStatus resptime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And then you can run them into this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats avg(resptime) as avgresp p95(resptime) as p95resp by lastURL
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 10 Nov 2017 17:58:28 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2017-11-10T17:58:28Z</dc:date>
    <item>
      <title>Using Splunk query with transaction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-Splunk-query-with-transaction/m-p/365489#M107784</link>
      <description>&lt;P&gt;1) I want to count the number of occurences of the HTTP URL with p(95) response time for url invocation:&lt;BR /&gt;
&lt;A href="https://example.net/v1/abc/xyz" target="_blank"&gt;https://example.net/v1/abc/xyz&lt;/A&gt; with the response code as 200 or 500&lt;BR /&gt;
2) The response time is the difference of time-stamp b/w line 6 &amp;amp; 3.&lt;BR /&gt;
3) Both the URL invocation &amp;amp; Status code occurs for the same thread which is Thread-30_Server_1 and always should be the next occurences&lt;BR /&gt;
If you see both event 1 &amp;amp; event 2 occur with the same thread but the response status code should always be sequential.&lt;BR /&gt;
So the splunk search should return event 1 with Status as 200 where-as event 2 with Status as 350&lt;/P&gt;

&lt;P&gt;Event 1:&lt;/P&gt;

&lt;P&gt;Line1) 2017-11-10 03:05:38,826 10606295 INFO  (Thread-30_Server_1:) :Url in else part is:&lt;A href="https://example.net/v1/abc/xyz" target="_blank"&gt;https://example.net/v1/abc/xyz&lt;/A&gt;&lt;BR /&gt;
Line2) 2017-11-10 03:05:38,826 10606295 INFO  (Thread-30_Server_1:) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;BR /&gt;
Line3) 2017-11-10 03:05:38,826 10606295 INFO  (Thread-30_Server_1:) HTTP url : &lt;A href="https://example.net/v1/abc/xyz" target="_blank"&gt;https://example.net/v1/abc/xyz&lt;/A&gt;&lt;BR /&gt;
Line4) 2017-11-10 03:05:38,826 10606295 INFO  (Thread-30_Server_1:) Body: [{"itemID":"42650750083","uom":"EACH","toZipCode":"112173111","qty":1,"channel":"dotcom"}]&lt;BR /&gt;
Line5) 2017-11-10 03:05:38,826 10606295 INFO  (Thread-30_Server_1:) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;BR /&gt;
Line6) 2017-11-10 03:05:39,012 10606481 INFO  (Thread-30_Server_1:) :Status Code is:200&lt;BR /&gt;
Line7) 2017-11-10 03:05:39,012 10606481 INFO  (Thread-30_Server_1:) :Status message is:"Success"&lt;BR /&gt;
Line8) 2017-11-10 03:05:39,012 10606481 INFO  (Thread-30_Server_1:) Exit call and 3&lt;/P&gt;

&lt;P&gt;Event 2:&lt;/P&gt;

&lt;P&gt;Line101) 2017-11-10 03:05:39,364 10606833 INFO  (Thread-30_Server_1:) Enter call with 5 attributes&lt;BR /&gt;
Line102) 2017-11-10 03:05:39,364 10606833 INFO  (Thread-30_Server_1:) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;BR /&gt;
Line103) 2017-11-10 03:05:39,364 10606833 INFO  (Thread-30_Server_1:) HTTP url : &lt;A href="https://example.net/v2/mmm/nnn" target="_blank"&gt;https://example.net/v2/mmm/nnn&lt;/A&gt;&lt;BR /&gt;
Line104) 2017-11-10 03:05:39,364 10606833 INFO  (Thread-30_Server_1:) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;BR /&gt;
Line105) 2017-11-10 03:05:39,442 10606911 INFO  (Thread-30_Server_1:) ####################################################################&lt;BR /&gt;
Line106) 2017-11-10 03:05:39,442 10606911 INFO  (Thread-30_Server_1:) Output from Server&lt;BR /&gt;
Line107) 2017-11-10 03:05:39,442 10606911 INFO  (Thread-30_Server_1:) {"status":350,"message":"Success","body":[{"shortageQty":0,"reservedQty":1,"partiallyReservedQty":0,"problemType":"SUCCESS"}}]}&lt;BR /&gt;
Line108) 2017-11-10 03:05:39,442 10606911 INFO  (Thread-30_Server_1:) ####################################################################&lt;BR /&gt;
Line109) 2017-11-10 03:05:39,442 10606911 INFO  (Thread-30_Server_1:) :Status Code is:350&lt;BR /&gt;
Line110) 2017-11-10 03:05:39,442 10606911 INFO  (Thread-30_Server_1:) :Status message is:"Success"&lt;BR /&gt;
Line111) 2017-11-10 03:05:39,442 10606911 INFO  (Thread-30_Server_1:) Exit call&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:45:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-Splunk-query-with-transaction/m-p/365489#M107784</guid>
      <dc:creator>gvanjre</dc:creator>
      <dc:date>2020-09-29T16:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using Splunk query with transaction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-Splunk-query-with-transaction/m-p/365490#M107785</link>
      <description>&lt;P&gt;Is that one event with 8 lines, or is that 8 events that have been rolled together using &lt;CODE&gt;transaction&lt;/CODE&gt;?&lt;/P&gt;

&lt;P&gt;The code is simpler in the first case.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 17:09:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-Splunk-query-with-transaction/m-p/365490#M107785</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-11-10T17:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using Splunk query with transaction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-Splunk-query-with-transaction/m-p/365491#M107786</link>
      <description>&lt;P&gt;Assuming they were individual events before the &lt;CODE&gt;transaction&lt;/CODE&gt;, get rid of the &lt;CODE&gt;transaction&lt;/CODE&gt; and do it this way...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo  ("Status Code is" OR "HTTP")

| rename COMMENT as "extract thread, url and status, frop all other fields but _time"
| rex  "INFO\s+\((?&amp;lt;myThread&amp;gt;[^:\)]*:)\)\s*(HTTP url : (?&amp;lt;myURL&amp;gt;.*?)\s+?|:Status Code is:(?&amp;lt;myStatus&amp;gt;\d{3})\s+?)"
| fields _time myThread myURL myStatus

| rename COMMENT as "sort into thread /time order then roll URL and start time foreward onto response record"
| sort 0 myThread _time
| streamstats current=f last(_time) as lasttime last(myURL) as lastURL by myThread

| rename COMMENT as "Drop all records but the response, calculate response time"
| where isnotnull(myStatus) 
| eval resptime = _time - lasttime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should give records that look like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| fields _time myThread lastURL myStatus resptime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And then you can run them into this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats avg(resptime) as avgresp p95(resptime) as p95resp by lastURL
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Nov 2017 17:58:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-Splunk-query-with-transaction/m-p/365491#M107786</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-11-10T17:58:28Z</dc:date>
    </item>
  </channel>
</rss>

