Splunk Search

How to return data based on search of one Source and lookup to a second

El_Franco
Explorer

Hopefully this will set the issue out clearly. 

I have two sources, Transaction and Request.

The Transaction holds the transaction id, date and time and user details of a user transaction.

The Request holds the request id, transaction id and an XML string with details of a users search.   

I have a query that searches the Request and returns those searches which contain specific strings. However i need to show the user details on the results  table. 

index="PreProdIndex" source="Request"
"<stringCriterion fieldName=\"Product\" operator=\"equals\" value=\"Soup\"/>"
OR "<stringCriterion fieldName=\"Product\" operator=\"equals\" value=\"Biscuits\"/>"

| table REQUEST_DATE_TIME REQUEST

So I need to add onto the table USER_DETAILS from the Source "Transaction" to the above query based on the common key of the Transaction ID. 

In SQL I would simply put in a join on Transaction.ID=Request.Transaction_ID and all would be good but I have failed to find anything that gives a SPLUNK solution yet. 

 

Labels (2)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Splunk has a join command that may do the job, but it's inefficient.  The typical solution is to fetch both sources and then group them together by a common field using the stats command.

index="PreProdIndex" (source="Request"
"<stringCriterion fieldName=\"Product\" operator=\"equals\" value=\"Soup\"/>"
OR "<stringCriterion fieldName=\"Product\" operator=\"equals\" value=\"Biscuits\"/>") OR source="Transaction")
| stats values(*) as * by transaction_id
| table REQUEST_DATE_TIME REQUEST *

 

---
If this reply helps you, Karma would be appreciated.
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 ...