<?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: kvstore query via Python SDK on Windows is slow in Knowledge Management</title>
    <link>https://community.splunk.com/t5/Knowledge-Management/kvstore-query-via-Python-SDK-on-Windows-is-slow/m-p/490425#M4389</link>
    <description>&lt;P&gt;Answer — at least as tested on Windows 2019 in AWS, with the current Python SDK (updated ~ 1 mon ago), you have to pass the host and port or it will timeout on every single query. This is different from OSX and Linux where it just works. &lt;/P&gt;

&lt;P&gt;Notably, the only other issue I've had with the kvstore SDK not working was on a OSX host where localhost wasn't configured in etc hosts. This configuration would have also solved that issue (as everything I did was based on 127.0.0.1 -- dev host).&lt;/P&gt;

&lt;P&gt;Workaround:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    try:
        # Getting configurations
        mgmtHostname, mgmtHostPort = getConfKeyValue('web', 'settings', 'mgmtHostPort').split(":")
        base_url = "https://" + mgmtHostname + ":" + mgmtHostPort
    except Exception as e:
        debug.append(json.dumps({"status": "ERROR", "description": "Error getting the base_url configuration!", "message": str(e)}))

    try: 
        service = client.connect(host=mgmtHostname, port=mgmtHostPort, token=sessionKey)
        service.namespace['owner'] = 'nobody'
        service.namespace['app'] = 'Splunk_Security_Essentials'
    except Exception as e:
        debug.append(json.dumps({"status": "ERROR", "description": "Error grabbing a service object", "message": str(e)}))

    def getKVStoreById(store, id):
        try:
            kvstore_output = service.kvstore[store].data.query_by_id(id)
            debug.append({"message": "I got a kvstorebyid request", "store": store, "id": id, "returningkey": kvstore_output["_key"]})
        except Exception as e:
            debug.append({"status": "Failed to do primary method": str(e)})
            kvstore_output = []
        return kvstore_output
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 26 Sep 2019 17:51:03 GMT</pubDate>
    <dc:creator>David</dc:creator>
    <dc:date>2019-09-26T17:51:03Z</dc:date>
    <item>
      <title>kvstore query via Python SDK on Windows is slow</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/kvstore-query-via-Python-SDK-on-Windows-is-slow/m-p/490424#M4388</link>
      <description>&lt;P&gt;It seems like the python SDK for Windows is timing out when trying to connect to the host. I have a rest endpoint that makes 7 kvstore calls, and each one adds 2 seconds to the execution time. On linux, all seven complete in less than half a second. How do I work around this?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2019 17:48:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/kvstore-query-via-Python-SDK-on-Windows-is-slow/m-p/490424#M4388</guid>
      <dc:creator>David</dc:creator>
      <dc:date>2019-09-26T17:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: kvstore query via Python SDK on Windows is slow</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/kvstore-query-via-Python-SDK-on-Windows-is-slow/m-p/490425#M4389</link>
      <description>&lt;P&gt;Answer — at least as tested on Windows 2019 in AWS, with the current Python SDK (updated ~ 1 mon ago), you have to pass the host and port or it will timeout on every single query. This is different from OSX and Linux where it just works. &lt;/P&gt;

&lt;P&gt;Notably, the only other issue I've had with the kvstore SDK not working was on a OSX host where localhost wasn't configured in etc hosts. This configuration would have also solved that issue (as everything I did was based on 127.0.0.1 -- dev host).&lt;/P&gt;

&lt;P&gt;Workaround:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    try:
        # Getting configurations
        mgmtHostname, mgmtHostPort = getConfKeyValue('web', 'settings', 'mgmtHostPort').split(":")
        base_url = "https://" + mgmtHostname + ":" + mgmtHostPort
    except Exception as e:
        debug.append(json.dumps({"status": "ERROR", "description": "Error getting the base_url configuration!", "message": str(e)}))

    try: 
        service = client.connect(host=mgmtHostname, port=mgmtHostPort, token=sessionKey)
        service.namespace['owner'] = 'nobody'
        service.namespace['app'] = 'Splunk_Security_Essentials'
    except Exception as e:
        debug.append(json.dumps({"status": "ERROR", "description": "Error grabbing a service object", "message": str(e)}))

    def getKVStoreById(store, id):
        try:
            kvstore_output = service.kvstore[store].data.query_by_id(id)
            debug.append({"message": "I got a kvstorebyid request", "store": store, "id": id, "returningkey": kvstore_output["_key"]})
        except Exception as e:
            debug.append({"status": "Failed to do primary method": str(e)})
            kvstore_output = []
        return kvstore_output
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Sep 2019 17:51:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/kvstore-query-via-Python-SDK-on-Windows-is-slow/m-p/490425#M4389</guid>
      <dc:creator>David</dc:creator>
      <dc:date>2019-09-26T17:51:03Z</dc:date>
    </item>
  </channel>
</rss>

