Knowledge Management

How to prevent duplicates in KV Store?

dteo827
Explorer

Greetings,
I regularly update a KV Store with new IP addresses/websites to monitor for in my network traffic.

Sometimes I get redundant information, and put in the same IP's/website multiple times.

How can I prevent duplicates in the KV Store?

0 Karma

VatsalJagani
SplunkTrust
SplunkTrust

Hi @dteo827,

Do use dedup command while updating the lookup. To make sure that your lookup don't have duplicate values at any point of time set key (primary key, which can not be duplicated) in kvstore (Reference).

0 Karma

christoffertoft
Communicator

This might work, but to play the devil's advocate here:

Ponder that the list has an IP and host of example.comwith ip 192.168.0.1
At some point, that key-value expires (i.e is old), perhaps because the IP has changed. At a later point in time, the ip 192.168.0.2 resolves to example.com, which then should be put in the KV store. At this point, without using timestamps and additional logic, you cant be certain the dedupped hostname (for example) removes the correct entry in the KV-store.

I've had huge problems with the KV-store functionalities, where inputlookup is great in terms of providing data on a row by row basis, making it easy to discern duplicates etc, but has the requirement of being the first command in the pipe. lookup on the other hand can be anywhere in a search, but does not provide a way to separate colliding entries (i.e. the output will be similar to that of doing a | stats values(*) by x

0 Karma

renjith_nair
Legend

If you are populating kv store with a search, then you can check the existence of IP's and store only those which are not inside, something like

<your search terms>|inputlookup lookup_name where NOT [|inputlookup lookup_name where IP="*"|fields IP]
---
What goes around comes around. If it helps, hit it with Karma 🙂

christoffertoft
Communicator

Inputlookup has to be the first command of a search

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...