Knowledge Management

Return only some key from KvStore through API.

ater49
New Member

Hi Splunkers,

In order to update, delete or create entries in KvStore only when it's necessary, i'm looking to get the list of "_key" fields of a collections to compare them with the set of new "_key". And all of that with the REST API.

Is there any solution without usage of search ?

Thank's you for your awnser 😃

0 Karma

ilyaresh
Path Finder

HI,
You can use query parameter in the the GET request
for example: when you will be running
curl -X GET https://SPLUNK_SH:8089/servicesNS/nobody/SH_APP/storage/collections/data/KVSTORE_COLL?query={%20%22$and%22:%20[{%22def_id%22:{%22$gt%22:1049}},{%22def_id%22:{%22$lt%22:1060}},{%22sla_status%22:%220%22}]}
it is an URL encoded { "$and": [{"def_id":{"$gt":1049}},{"def_id":{"$lt":1060}},{"sla_status":"0"}]} query, and you will get all the items that their def_id is 1050-1060 AND sla_status = 0.
Once you have the _key of all the items you want update, just submit the new full content of the items, since it's actually overwrite, and there is no update as such, you will need to re-submit all the "data" fields with their values

For more information please refer (to the official documentation) here https://docs.splunk.com/Documentation/Splunk/latest/RESTREF/RESTkvstore#Queries or (my understanding) here http://isbyr.com/splunk-kv-store-using-rest-api/
Regards,
ILYA

chrisyounger
SplunkTrust
SplunkTrust

If you want to see _key, you will need to rename it like so:

|inputlookup kvstore_collection | eval key = _key | table *

Hope this helps!

0 Karma
Get Updates on the Splunk Community!

Splunk Observability Cloud's AI Assistant in Action Series: Auditing Compliance and ...

This is the third post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

What You Read The Most: Splunk Lantern’s Most Popular Articles!

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...