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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...