Splunk Search

How to use join using stats by count on two different searches?

msrama5
Explorer

Hello, I am trying to use the join by userid on 2 different sub queries using join feature, both the queries are returning the data when individually ran, but is not returning the data when used with join, what is missing in query below to join by userid ?

earliest=-1h sourcetype=GATEWAY | stats count by UserId , cc.Type, Error.Code 
| table first_table | join UserId   [ | search earliest=-1h sourcetype=GATEWAY  ReasonCode="Authorized"| stats count by UserId , cc.Type|  table second_table]
Tags (3)
0 Karma

woodcock
Esteemed Legend

Start with this:

earliest=-1h sourcetype=GATEWAY
| stats count count(eval(ReasonCode="Authorized")) BY UserId , cc.Type, Error.Code
0 Karma

somesoni2
Revered Legend

Get rid of those | table first_table and | table second_table. The table command is to selectively show the fields from result of the search, so your current searches are trying to return fields 'first_table' and 'second_table' which do not exist and join fails.

0 Karma
Get Updates on the Splunk Community!

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...

Cloud Monitoring Console - Unlocking Greater Visibility in SVC Usage Reporting

For Splunk Cloud customers, understanding and optimizing Splunk Virtual Compute (SVC) usage and resource ...

Automatic Discovery Part 3: Practical Use Cases

If you’ve enabled Automatic Discovery in your install of the Splunk Distribution of the OpenTelemetry ...