<?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 Using appendcols to get percent success in one time range vs another in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Using-appendcols-to-get-percent-success-in-one-time-range-vs/m-p/442115#M125564</link>
    <description>&lt;P&gt;I have the following search that I'd like to schedule to run after changes. The goal is to detect a change in success rate by URL in a time that I define to be "pre-change window" versus a time that I define to be "post-change window". The below search would be for a change window happened 15 mins ago, and the pre-change time to compare it to was between 46 and 31 minutes ago as a control. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=mywebservice sourcetype=access_custom earliest=-15m@m latest=now
| fillnull value=filled http_status_code
| eval post="1"
| eval success_post = case(match(http_status_code, "^(filled|2.*|3.*)$"), "1", true(), "0") 
| stats sum(post) as "txns_post_window", sum(success_post) as "pct_success_post_window" by url
| eval pct_success_post_window = round((pct_success_post_window / txns_post_window) * 100,2) 
| appendcols 
    [ search index=mywebservice sourcetype=access_custom earliest=-46m@m latest=-31m@m 
| fillnull value=filled http_status_code
| eval pre="1"
| eval success_pre = case(match(http_status_code, "^(filled|2.*|3.*)$"), "1", true(), "0") 
| stats sum(pre) as "txns_pre_window", sum(success_pre) as "pct_success_pre_window" by url 
| eval pct_success_pre_window = round((pct_success_pre_window / txns_pre_window) * 100,2)] 
| where (pct_success_post_window &amp;lt; pct_success_pre_window) AND (pct_success_post_window &amp;lt; 90) AND txns_post_window &amp;gt; 10 AND txns_pre_window &amp;gt; 10 
| sort pct_success_post_window
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem that I'm encountering here is that I'm getting incorrect data from the search within the appendcols subsearch. When I run the searches individually, they work as expected. With the appendcols, usually the "pre-window" data comes back as all ~100% success rate. The counts of transactions can be wildly off too. I have some suspicion that data that I did not intend is somehow making its way into this subsearch.&lt;/P&gt;

&lt;P&gt;How can I modify this search to produce correct data?&lt;/P&gt;</description>
    <pubDate>Fri, 15 Mar 2019 19:32:03 GMT</pubDate>
    <dc:creator>jiman7697</dc:creator>
    <dc:date>2019-03-15T19:32:03Z</dc:date>
    <item>
      <title>Using appendcols to get percent success in one time range vs another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-appendcols-to-get-percent-success-in-one-time-range-vs/m-p/442115#M125564</link>
      <description>&lt;P&gt;I have the following search that I'd like to schedule to run after changes. The goal is to detect a change in success rate by URL in a time that I define to be "pre-change window" versus a time that I define to be "post-change window". The below search would be for a change window happened 15 mins ago, and the pre-change time to compare it to was between 46 and 31 minutes ago as a control. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=mywebservice sourcetype=access_custom earliest=-15m@m latest=now
| fillnull value=filled http_status_code
| eval post="1"
| eval success_post = case(match(http_status_code, "^(filled|2.*|3.*)$"), "1", true(), "0") 
| stats sum(post) as "txns_post_window", sum(success_post) as "pct_success_post_window" by url
| eval pct_success_post_window = round((pct_success_post_window / txns_post_window) * 100,2) 
| appendcols 
    [ search index=mywebservice sourcetype=access_custom earliest=-46m@m latest=-31m@m 
| fillnull value=filled http_status_code
| eval pre="1"
| eval success_pre = case(match(http_status_code, "^(filled|2.*|3.*)$"), "1", true(), "0") 
| stats sum(pre) as "txns_pre_window", sum(success_pre) as "pct_success_pre_window" by url 
| eval pct_success_pre_window = round((pct_success_pre_window / txns_pre_window) * 100,2)] 
| where (pct_success_post_window &amp;lt; pct_success_pre_window) AND (pct_success_post_window &amp;lt; 90) AND txns_post_window &amp;gt; 10 AND txns_pre_window &amp;gt; 10 
| sort pct_success_post_window
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem that I'm encountering here is that I'm getting incorrect data from the search within the appendcols subsearch. When I run the searches individually, they work as expected. With the appendcols, usually the "pre-window" data comes back as all ~100% success rate. The counts of transactions can be wildly off too. I have some suspicion that data that I did not intend is somehow making its way into this subsearch.&lt;/P&gt;

&lt;P&gt;How can I modify this search to produce correct data?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2019 19:32:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-appendcols-to-get-percent-success-in-one-time-range-vs/m-p/442115#M125564</guid>
      <dc:creator>jiman7697</dc:creator>
      <dc:date>2019-03-15T19:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using appendcols to get percent success in one time range vs another</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-appendcols-to-get-percent-success-in-one-time-range-vs/m-p/442116#M125565</link>
      <description>&lt;P&gt;I'm still not sure why the first search doesn't work but I produced a solution:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=mywebservice sourcetype=access_custom earliest=-4h@m latest=now
 | fillnull value=filled http_status_code
| eval secondsAgo=now() - _time
| eval post=case(secondsAgo &amp;lt;= (60 * 30), 1) 
| eval prev=case(secondsAgo &amp;gt;= (60 * 120), 1)
| eval post_success = case(match(http_status_code, "^(filled|2.*|3.*)$") AND post==1, 1) 
| eval prev_success = case(match(http_status_code, "^(filled|2.*|3.*)$") AND prev==1, 1) 
 | stats sum(prev) as "txns_pre_window", sum(prev_success) as "pct_success_pre_window", sum(post) as "txns_post_window", sum(post_success) as "pct_success_post_window" by url
| eval pct_success_post_window = round((pct_success_post_window / txns_post_window) * 100,2) 
| eval pct_success_pre_window = round((pct_success_pre_window / txns_pre_window) * 100,2) 
| where (pct_success_post_window &amp;lt; (pct_success_pre_window-20)) AND (pct_success_post_window &amp;lt; 75) AND txns_post_window &amp;gt; 10 AND txns_pre_window &amp;gt; 10 
| sort pct_success_post_window
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Apr 2019 14:37:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-appendcols-to-get-percent-success-in-one-time-range-vs/m-p/442116#M125565</guid>
      <dc:creator>jiman7697</dc:creator>
      <dc:date>2019-04-02T14:37:42Z</dc:date>
    </item>
  </channel>
</rss>

