<?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 How does splunk handle *nix logrotate based log rotation? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-does-splunk-handle-nix-logrotate-based-log-rotation/m-p/136754#M28162</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;what will happen if I use splunk to index files apache or syslog which gets rotated to *.gz?&lt;/P&gt;

&lt;P&gt;will the data be reprocessed? &lt;/P&gt;

&lt;P&gt;What is the default behaviour on 5?&lt;/P&gt;

&lt;P&gt;I've found a couple of old answers &lt;/P&gt;

&lt;P&gt;&lt;A href="http://answers.splunk.com/answers/10309/log-file-rotation"&gt;http://answers.splunk.com/answers/10309/log-file-rotation&lt;/A&gt; &lt;BR /&gt;
&lt;A href="http://answers.splunk.com/answers/12729/will-splunk-re-index-a-log-file-if-i-compress-it-after-its-been-indexed"&gt;http://answers.splunk.com/answers/12729/will-splunk-re-index-a-log-file-if-i-compress-it-after-its-been-indexed&lt;/A&gt; &lt;/P&gt;

&lt;P&gt;but I'm not entirely sure about actual behaviour on Splunk 5:&lt;/P&gt;</description>
    <pubDate>Tue, 04 Feb 2014 18:09:47 GMT</pubDate>
    <dc:creator>abonuccelli_spl</dc:creator>
    <dc:date>2014-02-04T18:09:47Z</dc:date>
    <item>
      <title>How does splunk handle *nix logrotate based log rotation?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-does-splunk-handle-nix-logrotate-based-log-rotation/m-p/136754#M28162</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;what will happen if I use splunk to index files apache or syslog which gets rotated to *.gz?&lt;/P&gt;

&lt;P&gt;will the data be reprocessed? &lt;/P&gt;

&lt;P&gt;What is the default behaviour on 5?&lt;/P&gt;

&lt;P&gt;I've found a couple of old answers &lt;/P&gt;

&lt;P&gt;&lt;A href="http://answers.splunk.com/answers/10309/log-file-rotation"&gt;http://answers.splunk.com/answers/10309/log-file-rotation&lt;/A&gt; &lt;BR /&gt;
&lt;A href="http://answers.splunk.com/answers/12729/will-splunk-re-index-a-log-file-if-i-compress-it-after-its-been-indexed"&gt;http://answers.splunk.com/answers/12729/will-splunk-re-index-a-log-file-if-i-compress-it-after-its-been-indexed&lt;/A&gt; &lt;/P&gt;

&lt;P&gt;but I'm not entirely sure about actual behaviour on Splunk 5:&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2014 18:09:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-does-splunk-handle-nix-logrotate-based-log-rotation/m-p/136754#M28162</guid>
      <dc:creator>abonuccelli_spl</dc:creator>
      <dc:date>2014-02-04T18:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: How does splunk handle *nix logrotate based log rotation?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-does-splunk-handle-nix-logrotate-based-log-rotation/m-p/136755#M28163</link>
      <description>&lt;P&gt;Splunk will not re-index already processed files after they get gzipped.&lt;/P&gt;

&lt;P&gt;example using a default monitor stanza like this:&lt;BR /&gt;
&lt;CODE&gt;&lt;BR /&gt;
user@linux-test-host /opt/SPLUNK/5.0.5/splunk $ pwd&lt;BR /&gt;
/opt/SPLUNK/5.0.5/splunk&lt;BR /&gt;
user@linux-test-host /opt/SPLUNK/5.0.5/splunk $ ./bin/splunk btool inputs list monitor:///var/log/apache2&lt;BR /&gt;
[monitor:///var/log/apache2]&lt;BR /&gt;
_rcvbuf = 1572864&lt;BR /&gt;
disabled = false&lt;BR /&gt;
followTail = 0&lt;BR /&gt;
host = linux-test-host&lt;BR /&gt;
index = default&lt;BR /&gt;
sourcetype = access_combined&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;for a folder like this:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;
user@linux-test-host /opt/SPLUNK/5.0.5/splunk $ ls -alrth /var/log/apache2&lt;BR /&gt;
total 9.9M&lt;BR /&gt;
drwxr-xr-x 18 root root 4.0K Feb  4 16:42 ..&lt;BR /&gt;
-rw-r--r--  1 root root  355 Feb  4 16:42 error.log.5.gz&lt;BR /&gt;
-rw-r--r--  1 root root  33K Feb  4 16:58 other_vhosts_access.log.5.gz&lt;BR /&gt;
-rw-rw-rw-  1 root adm   353 Feb  4 16:58 error.log.4.gz&lt;BR /&gt;
-rw-rw-rw-  1 root adm  1.7K Feb  4 16:59 other_vhosts_access.log.4.gz&lt;BR /&gt;
-rw-rw-rw-  1 root adm   355 Feb  4 16:59 error.log.3.gz&lt;BR /&gt;
-rw-rw-rw-  1 root adm  2.3K Feb  4 17:00 other_vhosts_access.log.3.gz&lt;BR /&gt;
-rw-rw-rw-  1 root adm   353 Feb  4 17:00 error.log.2.gz&lt;BR /&gt;
-rw-rw-rw-  1 root adm   11K Feb  4 17:02 other_vhosts_access.log.2.gz&lt;BR /&gt;
-rw-rw-rw-  1 root adm   354 Feb  4 17:02 error.log.1.gz&lt;BR /&gt;
-rw-rw-rw-  1 root adm   11K Feb  4 17:04 other_vhosts_access.log.1.gz&lt;BR /&gt;
-rw-rw-rw-  1 root adm   280 Feb  4 17:04 error.log&lt;BR /&gt;
drwxr-x---  2 root adm  4.0K Feb  4 17:04 .&lt;BR /&gt;
-rw-rw-rw-  1 root adm  9.8M Feb  4 17:09 other_vhosts_access.log&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;user@linux-test-host /opt/SPLUNK/5.0.5/splunk $ cp var/log/apache2/other_vhosts_access.log.1.gz /tmp/&lt;BR /&gt;
user@linux-test-host /opt/SPLUNK/5.0.5/splunk $ gunzip -d /tmp/other_vhosts_access.log.1.gz&lt;BR /&gt;
user@linux-test-host /opt/SPLUNK/5.0.5/splunk $ wc -l /tmp/other_vhosts_access.log.1&lt;BR /&gt;
28644 /tmp/other_vhosts_access.log.1&lt;/P&gt;

&lt;P&gt;user@linux-test-host ./bin/splunk search "source=/var/log/apache2* | stats count by source"&lt;/P&gt;

&lt;H2&gt;source                    count&lt;/H2&gt;

&lt;P&gt;/var/log/apache2/error.log                        2&lt;BR /&gt;
/var/log/apache2/error.log.1.gz                   4&lt;BR /&gt;
/var/log/apache2/error.log.2.gz                   4&lt;BR /&gt;
/var/log/apache2/error.log.3.gz                   4&lt;BR /&gt;
/var/log/apache2/error.log.4.gz                   4&lt;BR /&gt;
/var/log/apache2/error.log.5.gz                   4&lt;BR /&gt;
/var/log/apache2/other_vhosts_access.log      90875&lt;BR /&gt;
/var/log/apache2/other_vhosts_access.log.1.gz 28644&lt;BR /&gt;
/var/log/apache2/other_vhosts_access.log.2.gz 28517&lt;BR /&gt;
/var/log/apache2/other_vhosts_access.log.3.gz  5341&lt;BR /&gt;
/var/log/apache2/other_vhosts_access.log.4.gz  3732&lt;BR /&gt;
/var/log/apache2/other_vhosts_access.log.5.gz 84227&lt;BR /&gt;
&lt;/P&gt;

&lt;P&gt;The above tests were done starting a condition where there 0 files in the folder with several logrotation cycle run manually -&amp;gt; logrotate --force /etc/logrotate.d/apache2 &lt;/P&gt;

&lt;P&gt;When rotation happens,Splunk will find a compressed file which was already processed as non-compressed ( or compressed if starting from folder empty) and will behave like below, from splunkd.log&lt;/P&gt;

&lt;P&gt;02-04-2014 17:28:39.513 +0000 INFO  ArchiveProcessor - Archive with path="/var/log/apache2/other_vhosts_access.log.1.gz" was already indexed as a non-archive, skipping.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:48:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-does-splunk-handle-nix-logrotate-based-log-rotation/m-p/136755#M28163</guid>
      <dc:creator>abonuccelli_spl</dc:creator>
      <dc:date>2020-09-28T15:48:10Z</dc:date>
    </item>
  </channel>
</rss>

