<?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: Save Output from Scripted Input in KV Store in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Save-Output-from-Scripted-Input-in-KV-Store/m-p/741664#M117898</link>
    <description>&lt;P&gt;Hi Giuseppe,&lt;/P&gt;&lt;P&gt;yep, I currently empty the index for the events using a very short retention time. I think it will stay that way.&lt;BR /&gt;Other solutions like the KV Store don't really make much sense.&lt;/P&gt;&lt;P&gt;Thanks for the nice exchange.&lt;/P&gt;&lt;P&gt;Bye.&lt;/P&gt;</description>
    <pubDate>Thu, 13 Mar 2025 08:01:44 GMT</pubDate>
    <dc:creator>MrLR_02</dc:creator>
    <dc:date>2025-03-13T08:01:44Z</dc:date>
    <item>
      <title>Save Output from Scripted Input in KV Store</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Save-Output-from-Scripted-Input-in-KV-Store/m-p/741505#M117879</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have written a Python script that performs an API query from a system. This script is to be executed as scripted input at regular intervals (hourly).&lt;BR /&gt;Is there a possibility that the output of the script is stored in a Splunk KV store?&lt;BR /&gt;So far I have only managed to save the output of the scripted input in an index. However, since this is data from a database that is updated daily, I think it would make sense to use the Splunk KV Store.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 08:55:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Save-Output-from-Scripted-Input-in-KV-Store/m-p/741505#M117879</guid>
      <dc:creator>MrLR_02</dc:creator>
      <dc:date>2025-03-12T08:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: Save Output from Scripted Input in KV Store</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Save-Output-from-Scripted-Input-in-KV-Store/m-p/741508#M117880</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/248317"&gt;@MrLR_02&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I use kv-Store only if I have to manage records (e.g. case management), for the other situations I prefer using indexes.&lt;/P&gt;&lt;P&gt;Anyway, you can store data in kv-store running a scheduled search with outputlookup command at the end.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 08:43:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Save-Output-from-Scripted-Input-in-KV-Store/m-p/741508#M117880</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2025-03-12T08:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: Save Output from Scripted Input in KV Store</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Save-Output-from-Scripted-Input-in-KV-Store/m-p/741514#M117882</link>
      <description>&lt;P&gt;Thanks for the answer.&lt;/P&gt;&lt;P&gt;Currently I also store the output in an index, but since the scripted input is executed every hour and I don't want to have the same data stored in the index several times, I empty the index completely after every hour.&lt;BR /&gt;But now I have the problem that it can happen that the API query does not work, which would mean that no data from the system queried via API is available in Splunk.&lt;BR /&gt;What solution can you recommend for this problem?&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advance.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 08:55:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Save-Output-from-Scripted-Input-in-KV-Store/m-p/741514#M117882</guid>
      <dc:creator>MrLR_02</dc:creator>
      <dc:date>2025-03-12T08:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: Save Output from Scripted Input in KV Store</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Save-Output-from-Scripted-Input-in-KV-Store/m-p/741515#M117883</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/248317"&gt;@MrLR_02&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp; said - you'd normally put daily data like this in an index, however if you really want to write to KV store then please see below &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Are you currently using the smi.eventWriter to send data to you index with a streamEvents method?&lt;/P&gt;&lt;P&gt;If you have the session_key within your writer function then you should be able to use the inbuilt Splunk Python SDK to communicate with the KV Store. You'll need to initiate a new client using the session_key if you havent already got one within your method.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I havent got an example to hand but I will see if i can find one however this pseudo code may help you towards a working code&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;import splunklib.client as client
import splunklib.modularinput as smi

# Define your modular input class
class MyModularInput(smi.Script):

    def get_scheme(self):
        scheme = smi.Scheme("My Modular Input")
        scheme.description = "Streams data to a Splunk KV Store"
        scheme.use_external_validation = False
        scheme.streaming_mode = smi.Scheme.streaming_mode_simple
        return scheme

    def stream_events(self, inputs, ew):
        # Iterate over each input stanza
        for input_name, input_item in inputs.inputs.items():
            # Retrieve the session key
            session_key = inputs.metadata["session_key"]

            # Connect to Splunk using the session key
            service = client.connect(token=session_key)

            # Define the KV Store collection name
            collection_name = "your_kv_collection"

            # Data to be written to the KV Store
            data = {
                "key1": "value1",
                "key2": "value2"
            }

            # Access the KV Store collection
            collection = service.kvstore[collection_name]

            # Insert data into the KV Store
            try:
                collection.data.insert(data)
                ew.log("INFO", "Data successfully written to the KV Store.")
            except Exception as e:
                ew.log("ERROR", f"Failed to write data to the KV Store: {e}")

# Run the modular input script
if __name__ == "__main__":
    sys.exit(MyModularInput().run(sys.argv))&lt;/LI-CODE&gt;&lt;P&gt;Please let me know how you get on and consider adding karma to this or any other answer if it has helped.&lt;BR /&gt;Regards&lt;/P&gt;&lt;P&gt;Will&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 08:59:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Save-Output-from-Scripted-Input-in-KV-Store/m-p/741515#M117883</guid>
      <dc:creator>livehybrid</dc:creator>
      <dc:date>2025-03-12T08:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: Save Output from Scripted Input in KV Store</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Save-Output-from-Scripted-Input-in-KV-Store/m-p/741516#M117884</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/248317"&gt;@MrLR_02&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;what's the issue to have the same data stored in the index with different timestamps?&lt;/P&gt;&lt;P&gt;Forget your database approach Splunk isn't a database,&lt;/P&gt;&lt;P&gt;An index isn't a database table where you store only the data you're using; you can read only the last hour data from your index having the last situation, the same of your appproach deleting events.&lt;/P&gt;&lt;P&gt;then, in addition, if you need you can have the situation at a defined time changing the timepicker of your your search.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 09:04:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Save-Output-from-Scripted-Input-in-KV-Store/m-p/741516#M117884</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2025-03-12T09:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: Save Output from Scripted Input in KV Store</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Save-Output-from-Scripted-Input-in-KV-Store/m-p/741519#M117886</link>
      <description>&lt;P&gt;Hi Giuseppe,&lt;/P&gt;&lt;P&gt;yes I understand how Splunk stores its data in the indexes.&lt;/P&gt;&lt;P&gt;But when I run the scripted input every hour, it creates 24 entries for one device entry from the target system. But with Scripted Input I'm not just getting one entry back, I could be getting 200 entries back from the target system.&lt;/P&gt;&lt;P&gt;And then 24 entries a day for 200 device entries is a lot, over a long period of time it takes a lot of space on the indexer.&lt;/P&gt;&lt;P&gt;So I want to find a way to store the data from the scripted input on the indexer, but not store too many duplicates of the same device entries.&lt;/P&gt;&lt;P&gt;FYI: With the Script for the Scripted Input I ask the API of an i-doit System, which is a Software for IT-Documentation to give me all of its stored device-entries.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 09:20:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Save-Output-from-Scripted-Input-in-KV-Store/m-p/741519#M117886</guid>
      <dc:creator>MrLR_02</dc:creator>
      <dc:date>2025-03-12T09:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: Save Output from Scripted Input in KV Store</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Save-Output-from-Scripted-Input-in-KV-Store/m-p/741662#M117897</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/248317"&gt;@MrLR_02&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;if your problem is the disk space, you cannot use the delete command because it only logically deletes&amp;nbsp; events not physically.&lt;/P&gt;&lt;P&gt;you should use the clean command that deletes all events from the index and deletes also physically.&lt;/P&gt;&lt;P&gt;You can solve the space issue, applying a very short retention policy on that index (e.g. 12 hours or less), in this way you physically delete buckets.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2025 07:56:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Save-Output-from-Scripted-Input-in-KV-Store/m-p/741662#M117897</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2025-03-13T07:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: Save Output from Scripted Input in KV Store</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Save-Output-from-Scripted-Input-in-KV-Store/m-p/741664#M117898</link>
      <description>&lt;P&gt;Hi Giuseppe,&lt;/P&gt;&lt;P&gt;yep, I currently empty the index for the events using a very short retention time. I think it will stay that way.&lt;BR /&gt;Other solutions like the KV Store don't really make much sense.&lt;/P&gt;&lt;P&gt;Thanks for the nice exchange.&lt;/P&gt;&lt;P&gt;Bye.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2025 08:01:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Save-Output-from-Scripted-Input-in-KV-Store/m-p/741664#M117898</guid>
      <dc:creator>MrLR_02</dc:creator>
      <dc:date>2025-03-13T08:01:44Z</dc:date>
    </item>
    <item>
      <title>Re: Save Output from Scripted Input in KV Store</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Save-Output-from-Scripted-Input-in-KV-Store/m-p/741665#M117899</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/248317"&gt;@MrLR_02&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;good for you, see next time!&lt;/P&gt;&lt;P&gt;Ciao and happy splunking&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;P.S.: Karma Points are appreciated by all the contributors &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2025 08:04:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Save-Output-from-Scripted-Input-in-KV-Store/m-p/741665#M117899</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2025-03-13T08:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: Save Output from Scripted Input in KV Store</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Save-Output-from-Scripted-Input-in-KV-Store/m-p/741666#M117900</link>
      <description>&lt;P&gt;It can be done (half of ES works this way) but it's ugly. An input is what should work as... well, an input. Not as a vessel to run something that does something completely different.&lt;/P&gt;&lt;P&gt;So you have two options (apart from ingesting data into an index) - run a completely external tool - for example with cron - which will fiddle with splunk by API or indeed run a modular input. Both solutions are not very pretty.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2025 08:22:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Save-Output-from-Scripted-Input-in-KV-Store/m-p/741666#M117900</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-03-13T08:22:05Z</dc:date>
    </item>
  </channel>
</rss>

