Splunk Search

How do I show only field values that are missing from one of the 2 splunk searches?

shruthibm
New Member

I have 2 events

Event1: Document uploaded <documentId>

Event2: Document viewed <documentId>

 

I have generated a common "docId" field for both events. I want to create a table that lists document Ids that have been uploaded but not viewed. 

Ex: If I have the following events,

Document uploaded: 34423434
Document uploaded: 56676886
Document viewed: 56676886


I want a table that shows the below output

DocumentIdsNotViewed
34423434



Thanks in advance!


Labels (3)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @shruthibm,

you should try something like this:

<your-search> ("Document uploaded" OR "Document viewed"
| eval type=if(searchmatch("Document uploaded"),"Document uploaded","Document viewed")
| stats dc(type) AS type_count values(type) AS type BY documentId
| where type_count=1 AND type="Document uploaded"

Ciao.

Giuseppe

inventsekar
SplunkTrust
SplunkTrust

sure I understand this request, lets give this a try:

... | stats count(docId) as docIdCount | where docIdCount = 1

 

edit... oops, after few hrs, i understood that the logic is missing its idea. some trial and error on SPL creation is needed.

lets try this:

... | stats count(docId) as docIdCount by docId | where docIdCount = 1

 

thanks and best regards,
Sekar

PS - If this or any post helped you in any way, pls consider upvoting, thanks for reading !
0 Karma
Get Updates on the Splunk Community!

Observability Unlocked: Kubernetes Monitoring with Splunk Observability Cloud

 Ready to master Kubernetes and cloud monitoring like the pros? Join Splunk’s Growth Engineering team for an ...

Update Your SOAR Apps for Python 3.13: What Community Developers Need to Know

To Community SOAR App Developers - we're reaching out with an important update regarding Python 3.9's ...

October Community Champions: A Shoutout to Our Contributors!

As October comes to a close, we want to take a moment to celebrate the people who make the Splunk Community ...