<?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: Monthly distribution of query results in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321752#M96135</link>
    <description>&lt;P&gt;Sorry for the confusion. Thanks, @DalJeanis. Your solution works!&lt;/P&gt;</description>
    <pubDate>Tue, 25 Jul 2017 15:15:09 GMT</pubDate>
    <dc:creator>jbrenner</dc:creator>
    <dc:date>2017-07-25T15:15:09Z</dc:date>
    <item>
      <title>Monthly distribution of query results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321742#M96125</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have the following query which gives me the percentage of successful orders for the time period selected in the drop-down:&lt;/P&gt;

&lt;P&gt;index=abc "search string 1" | STATS COUNT AS ATTEMPTED_ORDERS |   appendcols [search index=abc  "search string 2" | STATS COUNT AS SUCCESSFUL_ORDERS] | eval PERCENT_SUCCESSFUL =  (SUCCESSFUL_ORDERS/ATTEMPTED_ORDERS) * 100 |  TABLE PERCENT_SUCCESSFUL&lt;/P&gt;

&lt;P&gt;I would like to use the timechart keyword to obtain this value (PERCENT_SUCCESSFUL) for each day over the last month, so I can display it as a chart.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;BR /&gt;
Jonathan&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:59:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321742#M96125</guid>
      <dc:creator>jbrenner</dc:creator>
      <dc:date>2020-09-29T14:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: Monthly distribution of query results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321743#M96126</link>
      <description>&lt;P&gt;try below&lt;/P&gt;

&lt;P&gt;index=abc  earliest=-30d@d latest=now "search string 1" | STATS COUNT AS ATTEMPTED_ORDERS | appendcols [search index=abc  earliest=-30d@d latest=now "search string 2" | STATS COUNT AS SUCCESSFUL_ORDERS] | eval PERCENT_SUCCESSFUL = (SUCCESSFUL_ORDERS/ATTEMPTED_ORDERS) * 100 | timechart span=1d count by PERCENT_SUCCESSFUL&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:59:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321743#M96126</guid>
      <dc:creator>sbbadri</dc:creator>
      <dc:date>2020-09-29T14:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: Monthly distribution of query results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321744#M96127</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abc "search string 1"
| timechart span=1d count AS ATTEMPTED_ORDERS
| appendcols [search
   index=abc "search string 2" 
   | timechart span=1d count AS SUCCESSFUL_ORDERS]
| stats values(*) AS * BY _time
| eval PERCENT_SUCCESSFUL = (coalesce(SUCCESSFUL_ORDERS, 0)/coalesce(ATTEMPTED_ORDERS, SUCCESSFUL_ORDERS)) * 100
| table _time PERCENT_SUCCESSFUL
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Jul 2017 20:30:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321744#M96127</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-07-20T20:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: Monthly distribution of query results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321745#M96128</link>
      <description>&lt;P&gt;Try this - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| multisearch 
    [search index=abc "search string 1"
     | eval  Attempts = 1
     | fields Attempts 
    ] 
    [search index=abc "search string 2"
     | eval Successes = 1
     | fields Successes 
    ]
| bin _time span=1d
| stats sum(*) as * by _time
| eval Attempts=if(Successes&amp;gt;Attempts, Successes, Attempts)
| eval Percent_Successful = round(100*Successes/Attempts,0)
| timechart span=1d max(Percent_Successful) 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Jul 2017 20:41:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321745#M96128</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-07-20T20:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: Monthly distribution of query results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321746#M96129</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/55793"&gt;@sbbadri&lt;/a&gt; - Not a bad try, but that's not going to work because the initial &lt;CODE&gt;stats&lt;/CODE&gt; command has a single result, not one result per day, so there is no field &lt;CODE&gt;_time&lt;/CODE&gt; remaining to go into the &lt;CODE&gt;timechart&lt;/CODE&gt; command.    &lt;/P&gt;

&lt;P&gt;Go ahead and try again, you're on the right track.  (no peeking at my version or &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/1406"&gt;@woodcock&lt;/a&gt;'s version, they are not perfect so there's plenty of room for you to do better than us.&lt;/P&gt;

&lt;P&gt;Also, when you change your strategy to fix the _time issue, I would suggest avoiding &lt;CODE&gt;appendcols&lt;/CODE&gt; since it will match up the records based on their order rather than based on their dates.  You'll need to &lt;CODE&gt;bin&lt;/CODE&gt; the &lt;CODE&gt;_time&lt;/CODE&gt; to days match them up by &lt;CODE&gt;_time&lt;/CODE&gt; either with a &lt;CODE&gt;stats&lt;/CODE&gt; command or a &lt;CODE&gt;join&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;I said "don't peek at woodcock's."&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:01:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321746#M96129</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2020-09-29T15:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: Monthly distribution of query results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321747#M96130</link>
      <description>&lt;P&gt;Hey, under what circumstances is &lt;CODE&gt;timechart&lt;/CODE&gt; ensured of coming up with the same start date for those two (sub) searches?  I'm thinking that if there are no "search string 2" on the first day that there is a "search string 1", that the records will be matched up wrong.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 20:51:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321747#M96130</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-07-20T20:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: Monthly distribution of query results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321748#M96131</link>
      <description>&lt;P&gt;Good point, I have updated my answer.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 21:02:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321748#M96131</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-07-20T21:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: Monthly distribution of query results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321749#M96132</link>
      <description>&lt;P&gt;Hi Woodcock,&lt;/P&gt;

&lt;P&gt;Thanks for the answer.&lt;BR /&gt;
When I run your query, I get the following error:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Error in 'bin' command: Invalid argument: 'span'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks!&lt;BR /&gt;
Jonathan&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 17:16:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321749#M96132</guid>
      <dc:creator>jbrenner</dc:creator>
      <dc:date>2017-07-24T17:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: Monthly distribution of query results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321750#M96133</link>
      <description>&lt;P&gt;Formatting error; get rid of the spaces around the equals-sign &lt;CODE&gt;span=1d&lt;/CODE&gt;.  If updated my answer to fix this.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 15:04:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321750#M96133</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-07-25T15:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: Monthly distribution of query results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321751#M96134</link>
      <description>&lt;P&gt;Sorry @DalJeanis; I didn't check to see if OP was right about his attribution to me (he wasn't) until after I edited your answer.  I also pulled the &lt;CODE&gt;bin&lt;/CODE&gt; out of each search.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 15:06:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321751#M96134</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-07-25T15:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: Monthly distribution of query results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321752#M96135</link>
      <description>&lt;P&gt;Sorry for the confusion. Thanks, @DalJeanis. Your solution works!&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 15:15:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321752#M96135</guid>
      <dc:creator>jbrenner</dc:creator>
      <dc:date>2017-07-25T15:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: Monthly distribution of query results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321753#M96136</link>
      <description>&lt;P&gt;A more efficient answer (all in 1 search) is this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abc "search string 1" OR "search string 2"
| bin _time span=1d
| stats count(eval(searchmatch("search string 1"))) AS ATTEMPTED_ORDERS
        count(eval(searchmatch("search string 2"))) AS SUCCESSFUL_ORDERS BY _time
| eval PERCENT_SUCCESSFUL = (coalesce(SUCCESSFUL_ORDERS, 0)/coalesce(ATTEMPTED_ORDERS, SUCCESSFUL_ORDERS)) * 100
| table _time PERCENT_SUCCESSFUL
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Jul 2017 15:26:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321753#M96136</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-07-25T15:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: Monthly distribution of query results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321754#M96137</link>
      <description>&lt;P&gt;@woodcock - How DARE you fix my sloppy code?&lt;/P&gt;

&lt;P&gt;The NERVE of some people.&lt;/P&gt;

&lt;P&gt;Heh.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 17:32:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Monthly-distribution-of-query-results/m-p/321754#M96137</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-07-25T17:32:12Z</dc:date>
    </item>
  </channel>
</rss>

