Splunk Search

dbxquery inside a search

balcv
Contributor

How do I take the results of a search pass a field into a dbxquery and then display results from both the search and the dbxquery?

In this example, the search returns data about specific emails where the sender domain is found in the csv file lookup.  I then want to take the Sender email address, use it in the WHERE clause  of the dbquery to return the accoutname field from the db.  Then finally, display various fields in a table including results from the search and the field returned by the dbxquery select.

 

index=email Act IN ("Acc") Sender!="*mydomain.com"
 [ | inputlookup susDomains.csv
    | stats values(domain) AS search
    | format ]
| eval senderEmail=split(Sender,"@")
| eval senderDomain=mvindex(senderEmail,1)
| eval acctCode=if ((acc="CAU3A274"),"Admin","Manager")
| eval SQLRcpt = "'".Rcpt."'"
| map search="| dbxquery query=\"SELECT accountname
    FROM [IDM].[drip].[usr_hist_tbl] uht
    WHERE uht.mail = $SQLRcpt$ ; \" connection=\"Subscriber_History\""
| table _time,senderDomain,Sender,Rcpt,Subject,acctCode,accoutname,SQLRcpt
| sort -_time

 

This search returns no data when I know there are records that should be returned.

Can anyone see where I may have gone wrong?

Thanks
Leigh

Labels (1)
Tags (1)
0 Karma
Get Updates on the Splunk Community!

Technical Workshop Series: Splunk Data Management and SPL2 | Register here!

Hey, Splunk Community! Ready to take your data management skills to the next level? Join us for a 3-part ...

Spotting Financial Fraud in the Haystack: A Guide to Behavioral Analytics with Splunk

In today's digital financial ecosystem, security teams face an unprecedented challenge. The sheer volume of ...

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability As businesses scale ...