<?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: When no events logged on the 1st of the month add log from the last day they were received in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/When-no-events-logged-on-the-1st-of-the-month-add-log-from-the/m-p/538186#M152122</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/65849"&gt;@dfraseman&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Actually that search is comparing the max linesChanged values during every month with the previous month max values, which is not your need.&lt;/P&gt;&lt;P&gt;Please try below, you may add some sorting;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=foo
| stats first(_time) as _time min(date_mday) as firstDay latest(date_mday) as lastDay earliest(lineCount) as firstlineCount latest(lineCount) as lastlineCount by date_month
| autoregress lastlineCount p=1
| eval lineCount=if(firstDay==1,firstlineCount,lastlineCount_p1)
| delta lineCount AS linesChanged
| convert timeformat="%b" ctime(_time)
| table _time  lineCount linesChanged&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 01 Feb 2021 22:11:19 GMT</pubDate>
    <dc:creator>scelikok</dc:creator>
    <dc:date>2021-02-01T22:11:19Z</dc:date>
    <item>
      <title>When no events logged on the 1st of the month add log from the last day they were received</title>
      <link>https://community.splunk.com/t5/Splunk-Search/When-no-events-logged-on-the-1st-of-the-month-add-log-from-the/m-p/537658#M152012</link>
      <description>&lt;P&gt;The following search gives me a table that contains the number of lines of code on the first of each month and calculates the number of lines changed over the month:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=foo date_mday="1" 
| dedup lineCount sortby +_time                                                                                                                                                                              
| sort -_time  
| delta lineCount AS linesChanged 
| fieldformat linesChanged=linesChanged*-1 
| table _time date_month lineCount linesChanged&lt;/LI-CODE&gt;&lt;P&gt;This works great as long as there is a log generated on the 1st.&amp;nbsp;I'm looking to add a condition that will add the log from that last day that one was generated if there was none on the 1st of the month.&lt;/P&gt;&lt;P&gt;For example, there is no data for June because nothing was generated on the 1st (see attached picture). The last day that a a log was generated was May 30th, which I would like to include.&lt;/P&gt;&lt;P&gt;I know that date_mday=1 filter will have to be dropped but don't know where to start otherwise.&lt;/P&gt;&lt;P&gt;Any help would be much appreciated!&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 16:18:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/When-no-events-logged-on-the-1st-of-the-month-add-log-from-the/m-p/537658#M152012</guid>
      <dc:creator>dfraseman</dc:creator>
      <dc:date>2021-01-28T16:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: When no events logged on the 1st of the month add log from the last day they were received</title>
      <link>https://community.splunk.com/t5/Splunk-Search/When-no-events-logged-on-the-1st-of-the-month-add-log-from-the/m-p/537685#M152020</link>
      <description>&lt;P&gt;This might be of some help. The source for these logs are text files and change every month, for example:&lt;/P&gt;&lt;P&gt;source="/.../2020-12.log" (December)&lt;/P&gt;&lt;P&gt;source="/.../2021-01.log" (January)&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I fumbled my way to a search that produces the lineCount from the earliest and latest log that was generated from each source AKA each month:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=foo 
| stats earliest(lineCount) as lineCount earliest(_time) as eventTime by source date_month
| append [ search index=foo | stats latest(lineCount) as lineCount latest(_time) as eventTime by source date_month ] 
| sort -eventTime 
| fieldformat eventTime=strftime(eventTime,"%Y-%m-%d %H:%M:%S") 
| table source date_month eventTime lineCount&lt;/LI-CODE&gt;&lt;P&gt;So now I think it is just a matter of performing a conditional delta calculation based on the eventTime.&lt;/P&gt;&lt;P&gt;See screenshot for output of query above.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 18:26:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/When-no-events-logged-on-the-1st-of-the-month-add-log-from-the/m-p/537685#M152020</guid>
      <dc:creator>dfraseman</dc:creator>
      <dc:date>2021-01-28T18:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: When no events logged on the 1st of the month add log from the last day they were received</title>
      <link>https://community.splunk.com/t5/Splunk-Search/When-no-events-logged-on-the-1st-of-the-month-add-log-from-the/m-p/537686#M152021</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/65849"&gt;@dfraseman&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Can you try below?&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=foo  
| timechart span=1mon@mon max(lineCount) as lineCount 
| delta lineCount AS linesChanged
| convert timeformat="%b" ctime(_time)
| table _time  lineCount linesChanged &lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 28 Jan 2021 18:35:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/When-no-events-logged-on-the-1st-of-the-month-add-log-from-the/m-p/537686#M152021</guid>
      <dc:creator>scelikok</dc:creator>
      <dc:date>2021-01-28T18:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: When no events logged on the 1st of the month add log from the last day they were received</title>
      <link>https://community.splunk.com/t5/Splunk-Search/When-no-events-logged-on-the-1st-of-the-month-add-log-from-the/m-p/537699#M152023</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/206061"&gt;@scelikok&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the reply. I gave it a try and it looks like exactly what ill need format wise, but after some manual checking of the linesChanged it looks like they are off.&lt;/P&gt;&lt;P&gt;The logs are generated early in the morning for the previous days activity and therefore when calculating the difference it has to be done between the 1sts of the month.&amp;nbsp; Correct me if I'm wrong but the span in your solution looks at at the timestamps from the earliest day to the last day of &lt;STRONG&gt;the same&lt;/STRONG&gt; month and therefore wouldn't account for the lines changed on the last day of the &lt;STRONG&gt;prior month&amp;nbsp;&lt;/STRONG&gt;that gets logged the next day.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 19:28:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/When-no-events-logged-on-the-1st-of-the-month-add-log-from-the/m-p/537699#M152023</guid>
      <dc:creator>dfraseman</dc:creator>
      <dc:date>2021-01-28T19:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: When no events logged on the 1st of the month add log from the last day they were received</title>
      <link>https://community.splunk.com/t5/Splunk-Search/When-no-events-logged-on-the-1st-of-the-month-add-log-from-the/m-p/538186#M152122</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/65849"&gt;@dfraseman&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Actually that search is comparing the max linesChanged values during every month with the previous month max values, which is not your need.&lt;/P&gt;&lt;P&gt;Please try below, you may add some sorting;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=foo
| stats first(_time) as _time min(date_mday) as firstDay latest(date_mday) as lastDay earliest(lineCount) as firstlineCount latest(lineCount) as lastlineCount by date_month
| autoregress lastlineCount p=1
| eval lineCount=if(firstDay==1,firstlineCount,lastlineCount_p1)
| delta lineCount AS linesChanged
| convert timeformat="%b" ctime(_time)
| table _time  lineCount linesChanged&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2021 22:11:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/When-no-events-logged-on-the-1st-of-the-month-add-log-from-the/m-p/538186#M152122</guid>
      <dc:creator>scelikok</dc:creator>
      <dc:date>2021-02-01T22:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: When no events logged on the 1st of the month add log from the last day they were received</title>
      <link>https://community.splunk.com/t5/Splunk-Search/When-no-events-logged-on-the-1st-of-the-month-add-log-from-the/m-p/538508#M152242</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/206061"&gt;@scelikok&lt;/a&gt;&amp;nbsp;Works like a charm! Just needed to add ascending sort on _time and a new field to show the month prior as that is really the month that the counts of lines changed is for:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=foo
| stats first(_time) as _time min(date_mday) as firstDay latest(date_mday) as lastDay earliest(lineCount) as firstlineCount latest(lineCount) as lastlineCount by date_month 
| sort +_time 
| autoregress lastlineCount p=1 
| eval lineCount=if(firstDay==1,firstlineCount,lastlineCount_p1) 
| eval lastmonth=strftime(relative_time(_time,"-1mon"),"%b") 
| delta lineCount AS linesChanged 
| convert timeformat="%b" ctime(_time) 
| table lastmonth lineCount linesChanged&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 19:17:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/When-no-events-logged-on-the-1st-of-the-month-add-log-from-the/m-p/538508#M152242</guid>
      <dc:creator>dfraseman</dc:creator>
      <dc:date>2021-02-03T19:17:04Z</dc:date>
    </item>
  </channel>
</rss>

