<?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: Problem with data retention policy in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Problem-with-data-retention-policy/m-p/453240#M78522</link>
    <description>&lt;P&gt;@satyaallaparthi - where is this nice view? - I can't find it ; - )&lt;/P&gt;

&lt;P&gt;It seems that &lt;CODE&gt;coldToFrozenScript = "$SPLUNK_HOME/bin/python" "$SPLUNK_HOME/bin/coldToFrozenExample.py" "$DIR"&lt;/CODE&gt; fails. &lt;/P&gt;</description>
    <pubDate>Sun, 12 May 2019 20:53:55 GMT</pubDate>
    <dc:creator>ddrillic</dc:creator>
    <dc:date>2019-05-12T20:53:55Z</dc:date>
    <item>
      <title>Problem with data retention policy</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Problem-with-data-retention-policy/m-p/453239#M78521</link>
      <description>&lt;P&gt;Hello, &lt;/P&gt;

&lt;P&gt;I have 2 IDX and one CM which is acting as a deployment server and License master as well, and 2 SH in cluster. &lt;/P&gt;

&lt;P&gt;I did the data retention for 180 days period. That means, whatever is older than 180 days should move to NAS location by using coldToFrozenScript. But data is not moving properly to NAS and not archiving. Latest event is showing before 8 months. i.e on july, 2018. &lt;/P&gt;

&lt;P&gt;Indexes.conf :&lt;/P&gt;

&lt;P&gt;[windows_server_security]&lt;BR /&gt;
coldPath = $SPLUNK_DB\windows_server_security\colddb&lt;BR /&gt;
enableDataIntegrityControl = 0&lt;BR /&gt;
enableTsidxReduction = 0&lt;BR /&gt;
homePath = $SPLUNK_DB\windows_server_security\db&lt;BR /&gt;
maxTotalDataSizeMB = 512000&lt;BR /&gt;
thawedPath = $SPLUNK_DB\windows_server_security\thaweddb&lt;BR /&gt;
repFactor = auto&lt;BR /&gt;
maxWarmDBCount = 150&lt;BR /&gt;
frozenTimePeriodInSecs = 15552000&lt;BR /&gt;
rotatePeriodInSecs = 60&lt;BR /&gt;
coldToFrozenScript = "$SPLUNK_HOME/bin/python" "$SPLUNK_HOME/bin/coldToFrozenExample.py" "$DIR"&lt;/P&gt;

&lt;P&gt;I did attached images from CM dashboard and indexes.conf what I mentioned. &lt;/P&gt;

&lt;P&gt;Can anyone help me with that? Thanks in advance. any help would be appreciated.  &lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://community.splunk.com/storage/temp/272695-dataarchieve.png" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:29:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Problem-with-data-retention-policy/m-p/453239#M78521</guid>
      <dc:creator>satyaallaparthi</dc:creator>
      <dc:date>2020-09-30T00:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with data retention policy</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Problem-with-data-retention-policy/m-p/453240#M78522</link>
      <description>&lt;P&gt;@satyaallaparthi - where is this nice view? - I can't find it ; - )&lt;/P&gt;

&lt;P&gt;It seems that &lt;CODE&gt;coldToFrozenScript = "$SPLUNK_HOME/bin/python" "$SPLUNK_HOME/bin/coldToFrozenExample.py" "$DIR"&lt;/CODE&gt; fails. &lt;/P&gt;</description>
      <pubDate>Sun, 12 May 2019 20:53:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Problem-with-data-retention-policy/m-p/453240#M78522</guid>
      <dc:creator>ddrillic</dc:creator>
      <dc:date>2019-05-12T20:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with data retention policy</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Problem-with-data-retention-policy/m-p/453241#M78523</link>
      <description>&lt;P&gt;Hello ddrillic, &lt;/P&gt;

&lt;P&gt;below one is the code that, i a using for coldToFrozenScript. Please help me with the problem that I have.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;# This is an example script for archiving cold buckets. It must be modified
# to suit your individual needs, and we highly recommend testing this on a
# non-production instance before deploying it.

import sys, os, gzip, shutil, subprocess, random, datetime

### CHANGE THIS TO YOUR ACTUAL ARCHIVE DIRECTORY!!!
ARCHIVE_DIR = '\\\\nv1001.net\\LOGS_PROD'



# For new style buckets (v4.2+), we can remove all files except for the rawdata.
# We can later rebuild all metadata and tsidx files with "splunk rebuild"
def handleNewBucket(base, files):
    print 'Archiving bucket: ' + base
    for f in files:
        full = os.path.join(base, f)
        if os.path.isfile(full):
            os.remove(full)

# For buckets created before 4.2, simply gzip the tsidx files
# To thaw these buckets, be sure to first unzip the tsidx files
def handleOldBucket(base, files):
    print 'Archiving old-style bucket: ' + base
    for f in files:
        full = os.path.join(base, f)
        if os.path.isfile(full) and (f.endswith('.tsidx') or f.endswith('.data')):
            fin = open(full, 'rb')
            fout = gzip.open(full + '.gz', 'wb')
            fout.writelines(fin)
            fout.close()
            fin.close()
            os.remove(full)

# This function is not called, but serves as an example of how to do
# the previous "flatfile" style export. This method is still not
# recommended as it is resource intensive
def handleOldFlatfileExport(base, files):
    command = ['exporttool', base, os.path.join(base, 'index.export'), 'meta::all']
    retcode = subprocess.call(command)
    if retcode != 0:
        sys.exit('exporttool failed with return code: ' + str(retcode))

    for f in files:
        full = os.path.join(base, f)
        if os.path.isfile(full):
            os.remove(full)
        elif os.path.isdir(full):
            shutil.rmtree(full)
        else:
            print 'Warning: found irregular bucket file: ' + full

if __name__ == "__main__":
    if len(sys.argv) != 2:
        sys.exit('usage: python bmw_coldToFrozenExample.py &amp;lt;bucket_dir_to_archive&amp;gt;')

    if not os.path.isdir(ARCHIVE_DIR):
        try:
            os.mkdir(ARCHIVE_DIR)
        except OSError:
            # Ignore already exists errors, another concurrent invokation may have already created this dir
            sys.stderr.write("mkdir warning: Directory '" + ARCHIVE_DIR + "' already exists\n")

    bucket = sys.argv[1]
    if not os.path.isdir(bucket):
        sys.exit('Given bucket is not a valid directory: ' + bucket)

    rawdatadir = os.path.join(bucket, 'rawdata')
    if not os.path.isdir(rawdatadir):
        sys.exit('No rawdata directory, given bucket is likely invalid: ' + bucket)

    files = os.listdir(bucket)
    journal = os.path.join(rawdatadir, 'journal.gz')
    if os.path.isfile(journal):
        handleNewBucket(bucket, files)
    else:
        handleOldBucket(bucket, files)

    if bucket.endswith('/'):
        bucket = bucket[:-1]

    indexname = os.path.basename(os.path.dirname(os.path.dirname(bucket)))
    ##destdir = os.path.join(ARCHIVE_DIR, indexname, os.path.basename(bucket))
    destdir = os.path.join(ARCHIVE_DIR, indexname + datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S'))


    while os.path.isdir(destdir):
        print 'Warning: This bucket already exists in the archive directory'
        print 'Adding a random extension to this directory...'
        destdir += '.' + str(random.randrange(10))

    ##shutil.copytree(bucket, destdir)
    shutil.make_archive(destdir,'zip', bucket)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 12 May 2019 22:28:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Problem-with-data-retention-policy/m-p/453241#M78523</guid>
      <dc:creator>satyaallaparthi</dc:creator>
      <dc:date>2019-05-12T22:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with data retention policy</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Problem-with-data-retention-policy/m-p/453242#M78524</link>
      <description>&lt;P&gt;The buckets will age out once the &lt;CODE&gt;latest&lt;/CODE&gt; event in the buckets is older than &lt;CODE&gt;frozenTimePeriodInSecs&lt;/CODE&gt;, that said you will always have events that are actually older than &lt;CODE&gt;frozenTimePeriodInSecs&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2019 03:34:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Problem-with-data-retention-policy/m-p/453242#M78524</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2019-05-13T03:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with data retention policy</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Problem-with-data-retention-policy/m-p/453243#M78525</link>
      <description>&lt;P&gt;getting &lt;/P&gt;

&lt;P&gt;C:\Program Files\Splunk\bin&amp;gt;splunk cmd python &lt;BR /&gt;
bmw_coldToFrozenExample.py&lt;BR /&gt;
usage: python bmw_coldToFrozenExample.py     Error&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:31:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Problem-with-data-retention-policy/m-p/453243#M78525</guid>
      <dc:creator>satyaallaparthi</dc:creator>
      <dc:date>2020-09-30T00:31:16Z</dc:date>
    </item>
  </channel>
</rss>

