Splunk Search

How to join the same sourcetype - Basically inner join with same sourcetype with different type of search string and compare the value (IN) condition. )

shanaiyappan
New Member

I am using the below query to achieve IN condition in same source. Basically I am achieving how many Order has been confirmed from hold. I got what I need but is there a better way of doing in.

In simple words SQL IN query from same table.

sourcetype="sourcetype1*" "called with OrderId : * and OperationType : confirm*" | rex field=message "OrderId : (?.?) and" | table OrderId | join type=inner OrderId
[| search sourcetype="sourcetype1
" "called with OrderId :, Type : mobile and OperationType : hold" | rex field=message "OrderId : (?.*?,)" | table OrderId] |stats count by OrderId.

0 Karma

shanaiyappan
New Member

Thank you for the answer let me check that

0 Karma

arjunpkishore5
Motivator

In your case, just use a subsearch

sourcetype="sourcetype1*" "called with OrderId : and OperationType : confirm" 
    [| search sourcetype="sourcetype1" "called with OrderId :, Type : mobile and OperationType : hold" 
    | rex field=message "query: (?.*?,)" 
    | table query] 
| rex field=message "OrderId : (?.?) and" 
| stats count by OrderId.

In the above sample, the inner search returns order id's which have hold. - https://docs.splunk.com/Documentation/SplunkCloud/latest/SearchTutorial/Useasubsearch

Why I changed the name to query instead of OrderId in the inner search - https://docs.splunk.com/Documentation/Splunk/latest/Search/Changetheformatofsubsearchresults

0 Karma
Get Updates on the Splunk Community!

Automatic Discovery Part 1: What is Automatic Discovery in Splunk Observability Cloud ...

If you’ve ever deployed a new database cluster, spun up a caching layer, or added a load balancer, you know it ...

Real-Time Fraud Detection: How Splunk Dashboards Protect Financial Institutions

Financial fraud isn't slowing down. If anything, it's getting more sophisticated. Account takeovers, credit ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...