Splunk Search

How to exclude writing existing result to Splunk lookup table.

Vicky84
Explorer

I want to keep updating new records to Splunk lookup table and not writing records again for existing users, even if they come in search results.

Lookup table structure : apiCallerID, ticketId

My base search query is having mvexpand, mvindex & rex commands and then table so when I do "NOT" it does not allow me to any other way or corrections.

index=test sourcetype=stats earliest=-5m@m latest=-0m@m| eval temp=ltrim(Response,"[") | eval temp1=rtrim(temp, "]") | eval temp2=split(temp1,"}")| mvexpand temp2| eval temp3=ltrim(temp2,",")  | eval testData=mvindex(temp3,-1) | rex field= testData "userID:\s(?<apiCallerID>\d+)" | table apiCallerID 

NOT [|inputlookup LookuptableGeneratorForDSIDByTestID.csv| fields apiCallerID]

Basically if the user is not there I want to add a ticket id along with user in lookup table and in future system will use this to raise any new tickets and prevent duplicate tickets for the existing user.

 

Labels (5)
0 Karma
1 Solution

to4kawa
Ultra Champion

...

| fields - count response
| search NOT
[|inputlookup LookuptableGeneratorForDSIDByTestID.csv| fields apiCallerID]

View solution in original post

0 Karma

to4kawa
Ultra Champion

If your log is JSON format, try spath and make table. it's easy.

0 Karma

Vicky84
Explorer

@to4kawa with or without path, how do you use "NOT" to exclude records from lookuptable. Only after massaging the result data with rex ors path, I will get the userID and post that NOT is not working or I am missing something. please correct

0 Karma

to4kawa
Ultra Champion

index=yours something NOT [ | inputlookup yourlookup | table your_field]

 

|inputlookup your_lookup where NOT your_field="value"

 

Which do you want?

0 Karma

Vicky84
Explorer

@to4kawa It is first one, as NOT is put after doing spath or rex. Need to exclude apiCallerID that are already in lookup table

 

index=test sourcetype=stats earliest=-5m@m latest=-0m@m| kv
| spath input=Response {} output=response
| stats count by response
| spath input=response
| fields - count response
 NOT
[|inputlookup LookuptableGeneratorForDSIDByTestID.csv| fields apiCallerID]

 

0 Karma

to4kawa
Ultra Champion

...

| fields - count response
| search NOT
[|inputlookup LookuptableGeneratorForDSIDByTestID.csv| fields apiCallerID]

0 Karma

Vicky84
Explorer

Oh I was missing "|search" thanks !

0 Karma
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

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