<?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: append command- more efficient query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/append-command-more-efficient-query/m-p/236792#M70345</link>
    <description>&lt;P&gt;This is really good but logic in my query is a bit different. Every block of query count backlog for specific month range + furter month if condtions are met  (so duplicate data can be there). &lt;/P&gt;

&lt;P&gt;e.g. &lt;BR /&gt;
June block Created= &amp;lt;2015-Jun and Closed&amp;gt;2015-Jun&lt;BR /&gt;
 - June 1000&lt;BR /&gt;
 - July 200&lt;BR /&gt;
 - August 100&lt;BR /&gt;
 - total for JUNE -  1300&lt;/P&gt;

&lt;P&gt;July block Created= &amp;lt;2015-Jul and Closed&amp;gt;2015-Jul&lt;BR /&gt;
 - July 1500&lt;BR /&gt;
 - August 100&lt;BR /&gt;
 - total for JULY 1600&lt;/P&gt;

&lt;P&gt;August block Created= &amp;lt;2015-AUG and Closed&amp;gt;2015-AUG&lt;BR /&gt;
- August 1800&lt;BR /&gt;
 - total 1800&lt;/P&gt;

&lt;P&gt;Hope this make sense&lt;/P&gt;</description>
    <pubDate>Wed, 23 Sep 2015 08:49:52 GMT</pubDate>
    <dc:creator>akawacz</dc:creator>
    <dc:date>2015-09-23T08:49:52Z</dc:date>
    <item>
      <title>append command- more efficient query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/append-command-more-efficient-query/m-p/236790#M70343</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;could you help me to write more efficient query? My is really time consuming.&lt;/P&gt;

&lt;P&gt;Example. &lt;/P&gt;

&lt;H2&gt;--First part cacluate backlog for June, second for July  and third for August&lt;/H2&gt;

&lt;P&gt;index=A&lt;BR /&gt;
| eval MONTH = relative_time(now(),"-7d@mon-3mon") &lt;BR /&gt;
| eval BACKLOG = if(CREATE_INCIDENT&amp;lt;REPORT_MONTH AND CLOSED_INCIDENT&amp;gt;MONTH ,1,0) &lt;BR /&gt;
| where BACKLOG =1&lt;/P&gt;

&lt;P&gt;| append [search index=A&lt;BR /&gt;
| eval MONTH = relative_time(now(),"-7d@mon-2mon") &lt;BR /&gt;
| eval BACKLOG = if(CREATE_INCIDENT&amp;lt;REPORT_MONTH AND CLOSED_INCIDENT&amp;gt;MONTH ,1,0) &lt;BR /&gt;
| where BACKLOG =1]&lt;/P&gt;

&lt;P&gt;| append [search index=A&lt;BR /&gt;
| eval MONTH = relative_time(now(),"-7d@mon-1mon") &lt;BR /&gt;
| eval BACKLOG = if(CREATE_INCIDENT&amp;lt;REPORT_MONTH AND CLOSED_INCIDENT&amp;gt;MONTH ,1,0) &lt;BR /&gt;
| where BACKLOG =1]&lt;/P&gt;

&lt;TABLE&gt;&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH&gt;stats dc(Ticket) as BACKLOG_COUNT by MONTH&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;&lt;TBODY&gt;
&lt;/TBODY&gt;&lt;/TABLE&gt;

&lt;P&gt;in A index we have filed Ticket.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:21:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/append-command-more-efficient-query/m-p/236790#M70343</guid>
      <dc:creator>akawacz</dc:creator>
      <dc:date>2020-09-29T07:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: append command- more efficient query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/append-command-more-efficient-query/m-p/236791#M70344</link>
      <description>&lt;P&gt;I'm sure you missed the specific earliest and latest for each query, So I will include them in my answer. Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=A earliest=-7d@mon latest=-7d@mon-3mon
| bucket span=1mon _time 
| eval BACKLOG = if(CREATE_INCIDENT&amp;lt;REPORT_MONTH AND CLOSED_INCIDENT&amp;gt;MONTH ,1,0) 
| stats sum(BACKLOG) as BACKLOG_COUNT by _time | eval Month=strftime(_time,"%Y-%m") | table Month BACKLOG_COUNT
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Update&lt;/STRONG&gt;&lt;BR /&gt;
Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=A earliest=-7d@mon latest=-7d@mon-3mon CREATE_INCIDENT&amp;lt;REPORT_MONTH
| eval MONTH= if(CLOSED_INCIDENT&amp;gt;relative_time(now(),"-7d@mon-3mon"),strftime(relative_time(now(),"-7d@mon-3mon"),"%Y-%m"),"") 
| eval MONTH= if(CLOSED_INCIDENT&amp;gt;relative_time(now(),"-7d@mon-2mon"),MONTH." ".strftime(relative_time(now(),"-7d@mon-2mon"),"%Y-%m"),MONTH)
| eval MONTH= if(CLOSED_INCIDENT&amp;gt;relative_time(now(),"-7d@mon-1mon"),MONTH." ".strftime(relative_time(now(),"-7d@mon-1mon"),"%Y-%m"),MONTH)
| makemv MONTH | stats count by by MONTH
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Sep 2015 16:25:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/append-command-more-efficient-query/m-p/236791#M70344</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-09-22T16:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: append command- more efficient query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/append-command-more-efficient-query/m-p/236792#M70345</link>
      <description>&lt;P&gt;This is really good but logic in my query is a bit different. Every block of query count backlog for specific month range + furter month if condtions are met  (so duplicate data can be there). &lt;/P&gt;

&lt;P&gt;e.g. &lt;BR /&gt;
June block Created= &amp;lt;2015-Jun and Closed&amp;gt;2015-Jun&lt;BR /&gt;
 - June 1000&lt;BR /&gt;
 - July 200&lt;BR /&gt;
 - August 100&lt;BR /&gt;
 - total for JUNE -  1300&lt;/P&gt;

&lt;P&gt;July block Created= &amp;lt;2015-Jul and Closed&amp;gt;2015-Jul&lt;BR /&gt;
 - July 1500&lt;BR /&gt;
 - August 100&lt;BR /&gt;
 - total for JULY 1600&lt;/P&gt;

&lt;P&gt;August block Created= &amp;lt;2015-AUG and Closed&amp;gt;2015-AUG&lt;BR /&gt;
- August 1800&lt;BR /&gt;
 - total 1800&lt;/P&gt;

&lt;P&gt;Hope this make sense&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2015 08:49:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/append-command-more-efficient-query/m-p/236792#M70345</guid>
      <dc:creator>akawacz</dc:creator>
      <dc:date>2015-09-23T08:49:52Z</dc:date>
    </item>
  </channel>
</rss>

