<?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: Deleting Data from KV Store in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Deleting-Data-from-KV-Store/m-p/483038#M8615</link>
    <description>&lt;P&gt;Hi newbie2tech, &lt;/P&gt;

&lt;P&gt;You need to create a mongo formatted query (since kvstore is a mongodb at its core, albeit a modified mongodb, so you can't just point a mongodb tool at it to manage it.)&lt;/P&gt;

&lt;P&gt;Like so, if you have a query to look at your kvstore like so: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; |inputlookup my_kv_store where LastUpdateTime&amp;lt;1551139200
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;in Mongodb query format that would look like so: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; {"LastUpdateTime": {"$lt": 1551139200}}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Next, you need to take that and url encode it, using a tool like: &lt;A href="http://meyerweb.com/eric/tools/dencoder/"&gt;http://meyerweb.com/eric/tools/dencoder/&lt;/A&gt;   which turns this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"LastUpdateTime": {"$lt": 1551139200}}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Into this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;%7B%22LastUpdateTime%22%3A%20%7B%22%24lt%22%3A%201551139200%7D%7D
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Lastly, run the following from a command line that supports curl, and can access your Splunk search head: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k -u admin:changeme -X DELETE &lt;A href="https://splunkhost:8089/servicesNS/nobody/&amp;lt;appname_where_kvstore_is_defined&amp;gt;/storage/collections/data/&amp;lt;kv_store_name&amp;gt;?query=%7B%22LastUpdateTime%22%3A%20%7B%22%24lt%22%3A%201551139200%7D%7D" target="test_blank"&gt;https://splunkhost:8089/servicesNS/nobody/&amp;lt;appname_where_kvstore_is_defined&amp;gt;/storage/collections/data/&amp;lt;kv_store_name&amp;gt;?query=%7B%22LastUpdateTime%22%3A%20%7B%22%24lt%22%3A%201551139200%7D%7D&lt;/A&gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Making sure you replace the  and  placeholders with the actual values relevant to your environment and pasting your mongo query after the query= point in the command.   &lt;/P&gt;

&lt;P&gt;Last point, measure twice, cut once..     Maybe create a test kvstore, put some dummy data in it and test this before you run it against your 3 years kvstore data and accidentally blow it all away.     A backup of the kvstore might also be in order before this.   (Call me paranoid). &lt;/P&gt;

&lt;P&gt;Good luck. &lt;BR /&gt;
Darren &lt;/P&gt;</description>
    <pubDate>Wed, 26 Feb 2020 18:52:28 GMT</pubDate>
    <dc:creator>darrenfuller</dc:creator>
    <dc:date>2020-02-26T18:52:28Z</dc:date>
    <item>
      <title>Deleting Data from KV Store</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Deleting-Data-from-KV-Store/m-p/483037#M8614</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;

&lt;P&gt;We have a kvstore with about ~95 million events dating back to 3 years.&lt;/P&gt;

&lt;P&gt;Key of the kvstore is unique numeric field. We also have timestamp among other fields.&lt;/P&gt;

&lt;P&gt;We have requirement to only retain only 1 year worth of data. &lt;/P&gt;

&lt;P&gt;I would like to know what would be the best way to get rid of old data.&lt;/P&gt;

&lt;P&gt;Also is there a way to specify to drop any data which is older than 1 year going forward like index retention time.&lt;/P&gt;

&lt;P&gt;We have clustered sh and indexer environment.&lt;/P&gt;

&lt;P&gt;We are at Splunk version 6.11&lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 10:34:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Deleting-Data-from-KV-Store/m-p/483037#M8614</guid>
      <dc:creator>newbie2tech</dc:creator>
      <dc:date>2020-02-26T10:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Data from KV Store</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Deleting-Data-from-KV-Store/m-p/483038#M8615</link>
      <description>&lt;P&gt;Hi newbie2tech, &lt;/P&gt;

&lt;P&gt;You need to create a mongo formatted query (since kvstore is a mongodb at its core, albeit a modified mongodb, so you can't just point a mongodb tool at it to manage it.)&lt;/P&gt;

&lt;P&gt;Like so, if you have a query to look at your kvstore like so: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; |inputlookup my_kv_store where LastUpdateTime&amp;lt;1551139200
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;in Mongodb query format that would look like so: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; {"LastUpdateTime": {"$lt": 1551139200}}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Next, you need to take that and url encode it, using a tool like: &lt;A href="http://meyerweb.com/eric/tools/dencoder/"&gt;http://meyerweb.com/eric/tools/dencoder/&lt;/A&gt;   which turns this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"LastUpdateTime": {"$lt": 1551139200}}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Into this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;%7B%22LastUpdateTime%22%3A%20%7B%22%24lt%22%3A%201551139200%7D%7D
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Lastly, run the following from a command line that supports curl, and can access your Splunk search head: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k -u admin:changeme -X DELETE &lt;A href="https://splunkhost:8089/servicesNS/nobody/&amp;lt;appname_where_kvstore_is_defined&amp;gt;/storage/collections/data/&amp;lt;kv_store_name&amp;gt;?query=%7B%22LastUpdateTime%22%3A%20%7B%22%24lt%22%3A%201551139200%7D%7D" target="test_blank"&gt;https://splunkhost:8089/servicesNS/nobody/&amp;lt;appname_where_kvstore_is_defined&amp;gt;/storage/collections/data/&amp;lt;kv_store_name&amp;gt;?query=%7B%22LastUpdateTime%22%3A%20%7B%22%24lt%22%3A%201551139200%7D%7D&lt;/A&gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Making sure you replace the  and  placeholders with the actual values relevant to your environment and pasting your mongo query after the query= point in the command.   &lt;/P&gt;

&lt;P&gt;Last point, measure twice, cut once..     Maybe create a test kvstore, put some dummy data in it and test this before you run it against your 3 years kvstore data and accidentally blow it all away.     A backup of the kvstore might also be in order before this.   (Call me paranoid). &lt;/P&gt;

&lt;P&gt;Good luck. &lt;BR /&gt;
Darren &lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 18:52:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Deleting-Data-from-KV-Store/m-p/483038#M8615</guid>
      <dc:creator>darrenfuller</dc:creator>
      <dc:date>2020-02-26T18:52:28Z</dc:date>
    </item>
  </channel>
</rss>

