Splunk Search

Left Outer join

msrama5
Explorer

Hi, I am trying to do search based on field cardid between 2 queries and 2 different time durations, following query does not seem to work, what I need is cardid present only in first query results and not in second query results , tried NOT cause and left join and both are returning incorrect results-
Query 1 based on NOT clause -
earliest=-5m index=iis_openapi /internal/loyalty/v1/ cs_uri_stem="registrations" cs_method = "POST" cardid="" NOT [ search earliest=-5m index=log-cdx-test source=kubernetes sourcetype=_json "PROCESSOR_E2E_TRACKING" "cardRegistered" "cardId" cardNumber="" | rename cardNumber as cardid ] | table cardid

Query 2 based on Left join
index=iis_openapi /internal/loyalty/v1/ cs_uri_stem="registrations" cs_method = "POST" cardid="*" | table cardid | join type=left [ search index=log-cdx-test source=kubernetes sourcetype=_json "PROCESSOR_E2E_TRACKING" "cardRegistered" "cardId" | rename cardNumber as cardid | table cardid] | where id=cardid | dedup cardid | table cardid

Do you see any issue with this query ? can this query be simplified ?

Tags (2)
0 Karma

FrankVl
Ultra Champion

Don't think the join approach will work like that, but I think your first approach should work with a few adjustments.

One thing you might want to do is is add the following in the subsearch: | fields cardid | format

earliest=-5m index=iis_openapi /internal/loyalty/v1/ cs_uri_stem="registrations" cs_method = "POST" cardid="*" NOT [ search earliest=-5m index=log-cdx-test source=kubernetes sourcetype=_json "PROCESSOR_E2E_TRACKING" "cardRegistered" "cardId" cardNumber="" | rename cardNumber as cardid  | fields cardid | format] | table cardid

Do note that there are limits to the number of results subsearches can handle. Not sure what number of cardids you would expect to be involved in this. If that is low (since you only look over past 5min) I think this approach should work.

An alternative approach (not using any subsearches and hence not restricted by subsearch restrictions) could be something along these lines:

(earliest=-5m index=iis_openapi /internal/loyalty/v1/ cs_uri_stem="registrations" cs_method = "POST" cardid="*")
OR
(earliest=-5m index=log-cdx-test source=kubernetes sourcetype=_json "PROCESSOR_E2E_TRACKING" "cardRegistered" "cardId" cardNumber="")
| rename cardNumber as cardid
| stats values(index) by cardid
| where index!="log-cdx-test"
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Kubernetes Alerts That Work Out of the Box with AutoDetect detectors in Splunk ...

A deployment rolls out slowly, one pod sits not ready for a few minutes, and whoever is on call gets an alert ...

Observability at Your Fingertips Directly From Splunk Platform—for Free

At .conf, we announced our roadmap to bring observability foundations to Splunk Platform. Bringing metrics and ...