SOLVED

How to query for two events with no common fields?

%3CLINGO-SUB%20id%3D%22lingo-sub-482772%22%20slang%3D%22en-US%22%3EHow%20to%20query%20for%20two%20events%20with%20no%20common%20fields%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-482772%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20know%20one%20can%20query%20for%20two%20events%20that%20have%20a%20common%20field%20by%20the%20Join%20Operator%2C%20but%20how%20can%20I%20query%20two%20or%20more%20separate%20events%20that%20have%20no%20common%20fields%3F%3C%2FP%3E%3CP%3EI'm%20trying%20to%20track%20a%20couple%20of%20activities%20that%20have%20no%20common%20fields%20in%20one%20query.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-482772%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Log%20Analytics%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EQuery%20Language%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-486315%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20query%20for%20two%20events%20with%20no%20common%20fields%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-486315%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F326650%22%20target%3D%22_blank%22%3E%40CloudTesting%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESomething%20like%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3EAlert%0A%7C%20project%20AlertName%2C%20round_time%3Dbin(TimeGenerated%2C%201m)%0A%7C%20join%20(Perf%20%0A%20%20%20%20%20%20%20%20%7C%20project%20Computer%2C%20%0A%20%20%20%20%20%20%20%20round_time%3Dbin(TimeGenerated%2C%201m))%0A%20on%20round_time%0A%3C%2FPRE%3E%0A%3CP%3EI%20use%20a%20rounded%20down%20timegenerated%20(as%20that%20is%20in%20both%20Tables)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-489501%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20query%20for%20two%20events%20with%20no%20common%20fields%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-489501%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F239477%22%20target%3D%22_blank%22%3E%40Clive%20Watson%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20sorry%20but%20I'm%20new%20to%20this%2C%20can%20you%20please%20elaborate%20on%20that%20or%20send%20me%20a%20link%20to%20some%20docs.%20How%20can%20this%20code%20help%20me%20query%20for%20two%20or%20more%20events%20in%20one%20query%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-489702%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20query%20for%20two%20events%20with%20no%20common%20fields%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-489702%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F326650%22%20target%3D%22_blank%22%3E%40CloudTesting%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPerhaps%20I'm%20not%20fully%20understanding%20the%20question.%26nbsp%3B%20You%20asked%20to%20%3CSTRONG%3EJoin%3C%2FSTRONG%3E%20two%20%3CSTRONG%3Eactivities%3C%2FSTRONG%3E%20without%20a%20common%20field.%26nbsp%3B%20When%20you%20say%20events%20we%20would%20assume%20the%20%3CSTRONG%3EEvents%3C%2FSTRONG%3E%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fschema-entities%2Ftables%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Etable%3C%2FA%3E%20in%20Log%20Analytics%2C%20and%20by%20Join%20I%20assumed%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fjoinoperator%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ejoin%20operator%3C%2FA%3E%20.%26nbsp%3B%20%26nbsp%3BWhat%20do%20you%20mean%20my%20Events%20(do%20you%20mean%20an%20event%20in%20a%20table%20or%20row)%3F%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhich%20table%20are%20you%20referring%20to%3F%26nbsp%3B%3C%2FP%3E%0A%3CP%3EA%20single%20Table%20will%20have%20always%20have%20common%20fields.%26nbsp%3B%20My%20example%20shows%20a%20join%20across%20two%20seperate%20tables%2C%20where%20their%20isn't%20a%20common%20field.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAre%20you%20asking%20about%20two%20Event%20IDs%2C%20in%20a%20table.%26nbsp%3B%20For%20example.%26nbsp%3B%20The%20Events%20table%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%2F%2F%20count%20all%20events%20that%20are%207036%20and%20show%20their%20description%0AEvent%0A%7C%20where%20TimeGenerated%20%26gt%3B%20ago(1d)%0A%7C%20where%20EventID%20%3D%3D%207036%0A%7C%20summarize%20count()%20by%20%20EventID%2C%20%20%20RenderedDescription%20%0A%3C%2FPRE%3E%0A%3CP%3EShowing%20two%20events%2C%20would%20be%3C%2FP%3E%0A%3CPRE%3E%2F%2F%20count%20all%20events%20that%20are%207036%20or%207040%20and%20show%20their%20description%0AEvent%0A%7C%20where%20TimeGenerated%20%26gt%3B%20ago(1d)%0A%7C%20where%20EventID%20in%20(%207036%2C%207040)%0A%7C%20summarize%20count()%20by%20%20EventID%0A%3C%2FPRE%3E%0A%3CP%3EOr%20are%20you%20trying%20to%20join%20pieces%20of%20data%20in%20a%20single%20table%3F%3C%2FP%3E%0A%3CPRE%3EPerf%20%0A%7C%20where%20TimeGenerated%20%26gt%3B%20ago(10d)%0A%7C%20where%20CounterName%20%20%3D%3D%20%22%25%20Processor%20Time%22%20%0A%7C%20project%20CounterName%2C%20Computer%2C%20TimeGenerated%20%20%20%2F%2F%20added%20this%20to%20increase%20performance%20as%20%22Use%20where%20and%20project%20to%20reduce%20the%20numbers%20of%20rows%20and%20columns%20in%20the%20input%20tables%2C%20before%20the%20join.%20%22%0A%7C%20join%20kind%3D%20inner%20(%0A%20%20%20%20Perf%0A%20%20%20%20%7C%20where%20CounterName%20%3D%3D%20%22Processor%20Queue%20Length%22%0A%20%20%20%20%7C%20project%20CounterName%20%2C%20TimeGenerated%20%2C%20Computer%20%0A)%20on%20TimeGenerated%20%2C%20Computer%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPerhaps%2C%20you%20can%20send%20what%20you%20have%20so%20far%2C%20for%20us%20to%20look%20at%3F%26nbsp%3B%20If%20we%20can%20see%20a%20screenshot%20or%20pseudo%20code%2C%20with%20expected%20output%20that%20would%20help.%3C%2FP%3E%0A%3CP%3Ee.g.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%22%3CEM%3EI'm%20looking%20at%20the%20Events%20table%2C%20I%20want%20to%20show%20if%20there%20are%20entries%20from%20a%20user%20called%20%22Local%20Service%22%20or%20%22System%22.%26nbsp%3B%20I%20want%20to%20count%20how%20many%20times%20this%20happens.%3C%2FEM%3E%22%26nbsp%3B%20Where%20an%20activity%20is%20a%20value%20of%20%22nnnnn%22%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3EEvent%0A%7C%20where%20TimeGenerated%20%26gt%3B%20ago(1d)%0A%7C%20where%20UserName%20has%20%22LOCAL%20SERVICE%22%20or%20UserName%20has%20%22SYSTEM%22%0A%7C%20summarize%20count()%20by%20UserName%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20main%20docs%20page%20is%20here%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2F%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-489960%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20query%20for%20two%20events%20with%20no%20common%20fields%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-489960%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F239477%22%20target%3D%22_blank%22%3E%40Clive%20Watson%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20the%20reply%20and%20I%20apologize%20for%20my%20lack%20of%20clarity.%3C%2FP%3E%3CP%3EI%20need%20to%20query%20if%20two%20events%20accrued%20within%2024hrs.%3C%2FP%3E%3CP%3EOne%20is%20a%20FireWall%20event%20of%20a%26nbsp%3Bconnection%20being%20made%20to%20a%26nbsp%3Bcertain%20external%20IP.%3C%2FP%3E%3CP%3EThe%20second%20event%20is%20a%20SecurityEvent%20of%20a%20certain%20process%20being%20executed%20%3CSTRONG%3Eon%20any%3C%2FSTRONG%3E%20machine%20in%20the%20network%20(so%20I%20don't%20have%20common%20fields%20like%20machine%20name%20or%20IPs).%3C%2FP%3E%3CP%3EI%20can%20query%20them%20each%20individually%2C%20but%20how%20can%20I%20check%20if%20they%20both%20accrued%20in%20the%20last%2024hrs%20in%20one%20query%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-490541%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20query%20for%20two%20events%20with%20no%20common%20fields%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-490541%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F326650%22%20target%3D%22_blank%22%3E%40CloudTesting%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENot%20a%20problem%2C%20I%20think%20I%20was%20close%20with%20my%20initial%20answer%20but%20used%20some%20example%20tables%20(not%20the%20ones%20you%20wanted).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EExample%201%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EHere%2C%20in%20example%20code%201%2C%20we%20look%20at%20the%20last%2024hrs%2C%20and%20select%20%22cscript.exe%22%20as%20an%20example%20process%20name%20(change%20to%20match%20yours).%26nbsp%3B%20I%20also%20look%20for%20a%20specific%20activity%20-%20again%20change%20this%20to%20suit.%26nbsp%3B%20We%20then%20use%20a%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fprojectoperator%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Eproject%3C%2FA%3E%20operator%20to%20only%20keep%20three%20columns%20-%20you%20may%20need%20more.%26nbsp%3B%20The%20last%20column%20is%20round_time%2C%20which%20takes%20a%20data%2Ftime%20which%20we%20use%20to%20join%20on%20later%20(rounded%20to%20%3CSTRONG%3E1m%3C%2FSTRONG%3E%20intervals%20-%20as%20we%20are%20unlikely%20to%20get%20a%20match%20on%20less%20than%20that)!%3C%2FP%3E%0A%3CP%3EI%20then%20join%20the%20SecurityEvents%20table%20using%20that%20round_time%2C%20to%20WindowsFirewall%20table.%26nbsp%3B%20In%20addition%20we%20filter%20on%20a%20specific%20RemoteIP%20address%20(please%20change%20for%20one%20that%20matches%20yours).%26nbsp%3B%20You%20didn't%20mention%20which%20Firewall%2C%20so%20you%20might%20have%20that%20data%20in%20a%20table%20called%20CommonSecurityLog%20-%20in%20that%20case%20change%20WindowsFirewall%20to%20CommonSecurityLog.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3ESecurityEvent%0A%7C%20where%20TimeGenerated%20%26gt%3B%20ago(1d)%20%20%2F%2F%20filter%20in%20last%2024hrs%0A%7C%20where%20Process%20%3D%3D%22cscript.exe%22%20%20%2F%2F%20find%20a%20process%20%0A%7C%20where%20Activity%20%3D%3D%20%224688%20-%20A%20new%20process%20has%20been%20created.%22%20%20%20%2F%2F%20look%20for%20%22a%20new%20process%20has%20been%20created%22%20eventid%0A%7C%20project%20Computer%2C%20Process%2C%20round_time%3Dbin(TimeGenerated%2C%201m)%20%20%2F%2F%20set%20a%20value%20for%20time%20to%20enable%20a%20JOIN%20%20%0A%7C%20join%20%0A%20%20%20%20(WindowsFirewall%20%0A%20%20%20%20%20%20%20%20%7C%20where%20RemoteIP%20%3D%3D%20%22192.168.137.1%22%20%20%2F%2F%20find%20a%20specifc%20IP%20in%20the%20Windows%20Firewall%20logs%20%0A%20%20%20%20%20%20%20%20%7C%20project%20Computer%2C%20RemoteIP%20%2C%20%20%20%20%20%20%20%2F%2F%20only%20project%20two%20columns%0A%20%20%20%20%20%20%20%20round_time%3Dbin(TimeGenerated%2C%201m)%20%20%20%20%2F%2F%20set%20time%20to%20match%20join%20%0A%20%20%20%20)%20on%20round_time%3C%2FPRE%3E%0A%3CP%3EYou%20can%20run%20the%20above%20from%20%3CA%20href%3D%22https%3A%2F%2Fportal.loganalytics.io%2FDemo%3Fq%3DH4sIAAAAAAAAA42QzU7CQBSF9ya8w0lXkGBJkSAuMCFGDS6UqIlLM0wvdHA6l8xMqSQ%252BvFMsBWJi7HJ67vn5XkgWVvnt7YaMb519oczIEl5VTvdkyApPKa4hltxO0g7Q62GhtCcLZaCF8%252BgPMusOlzPLkpzDeBxJJ61a%252B5g%252BKaovTQqBdS05HE2kV5vQIlwhGgxHI5xjAkNlo82Ew5zIQFqqOsXBsbLUzB9YsEUk%252FtRHoGqhSqvQIFqR9LjhfF2ELd196y4sFyZ992H%252BeK5M%252B4RDF0n%252Bg8CRDzs2Qhe0C6%252F08AwyYq4p%252FHp4mj5iN3DFAVTrLLRF%252By3s59LdKUul0Lp%252Brr49iGfK2dN0tgORXPXjZDiKk4vLODkh6NYk1UIiCIO7zwi1NRpvzUt3EvB7dBPWrUUhgI3eNlJfMiTrIjfu4PQPQg2jPZdceJkdo%252BiEoCOnb19cCrqGAgAA%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E%20in%20the%20demo%20Log%20Analytics%20portal.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EOutput%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F110848i8F1D24568E8F44B6%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Annotation%202019-04-28%20142534.jpg%22%20title%3D%22Annotation%202019-04-28%20142534.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EExample%202%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESecurityEvent%2C%20WindowsFirewall%20and%20CommonSecurityLog%20-%20do%20all%20have%20common%20fields%2C%20so%20we%20could%20have%20just%20%3CSTRONG%3Ejoin%3C%2FSTRONG%3Eed%20on%20Computer.%26nbsp%3B%20I%20don't%20know%20which%20firewall%20table%20you%20are%20looking%20at%2C%20you%20are%20using%20so%20this%20second%20example%20may%20not%20work%20in%20your%20case.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3ESecurityEvent%0A%7C%20where%20TimeGenerated%20%26gt%3B%20ago(1d)%20%20%2F%2F%20filter%20in%20last%2024hrs%0A%7C%20where%20Process%20%3D%3D%22cscript.exe%22%20%20%2F%2F%20find%20a%20process%20%0A%7C%20where%20Activity%20%3D%3D%20%224688%20-%20A%20new%20process%20has%20been%20created.%22%20%20%20%2F%2F%20look%20for%20%22a%20new%20process%20has%20been%20created%22%20eventid%0A%7C%20project%20Computer%2C%20Process%2C%20Activity%20%20%2F%2F%20set%20a%20value%20for%20time%20to%20enable%20a%20JOIN%20%20%0A%7C%20join%20%0A%20%20%20%20(WindowsFirewall%20%0A%20%20%20%20%20%20%20%20%7C%20where%20RemoteIP%20%3D%3D%20%22192.168.137.1%22%20%20%2F%2F%20find%20a%20specifc%20IP%20in%20the%20Windows%20Firewall%20logs%20%0A%20%20%20%20%20%20%20%20%7C%20project%20Computer%2C%20RemoteIP%20%0A%20%20%20%20)%20on%20Computer%20%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-497131%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20query%20for%20two%20events%20with%20no%20common%20fields%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-497131%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F239477%22%20target%3D%22_blank%22%3E%40Clive%20Watson%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFirst%20of%20all%20Thank%20You%2C%20I%20really%20appreciate%20your%20time%20and%20effort%20in%20helping%20me.%3C%2FP%3E%3CP%3EI%20think%20My%20problem%20is%20that%20unlike%20the%20cscript.exe%20file%20(which%20generates%20an%20Event%20almost%20every%20minute)%20the%20file%20I'm%20looking%20for%20may%20only%20be%20generated%20once%20in%2024h%2C%20And%20will%20most%20likely%26nbsp%3Bbe%20completely%20out%20of%20sync%20with%20the%20Firewall%20event%20(So%20the%20round_time%20will%20almost%20never%20be%20the%20same%20in%20both%20events).%3C%2FP%3E%3CP%3EAs%20I%20understand%2C%20this%20is%20why%20when%20I%20run%20your%20query%20it%20works%2C%20but%20when%20I%20run%20mine%20I%20get%20nothing%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%26nbsp%3BAzureDiagnostics%3CBR%20%2F%3E%7Cwhere%20TimeGenerated%20%26gt%3B%20ago(1d)%3CBR%20%2F%3E%7Cwhere%20Category%20%3D%3D%20%22AzureFirewallNetworkRule%22%3CBR%20%2F%3E%7Cwhere%20OperationName%20%3D%3D%20%22AzureFirewallNetworkRuleLog%22%3CBR%20%2F%3E%7Cwhere%20msg_s%20contains%20%22to%20*******.%20Action%3A%20Allow%22%3CBR%20%2F%3E%7Cproject%20Category%20%2C%20OperationName%20%2C%20msg_s%20%2C%20round_time%3Dbin(TimeGenerated%2C%201m)%3CBR%20%2F%3E%7Cjoin%3CBR%20%2F%3E%26nbsp%3B(SecurityEvent%3CBR%20%2F%3E%7C%20where%20Activity%20%3D%3D%20%224688%20-%20A%20new%20process%20has%20been%20created.%22%20%3CBR%20%2F%3E%7C%20where%20Process%20%3D%3D%20%22******.exe%22%20%3CBR%20%2F%3E%7C%20project%20Activity%20%2CComputername%20%2CProcess%20%2C%20round_time%3Dbin(TimeGenerated%2C%201m)%3CBR%20%2F%3E)%20on%20round_time%3C%2FPRE%3E%3CP%3EThe%20source%20computer%5CIP%20in%20the%20Firewall%20event%20is%20irrelevant%20to%20the%20SecurityEvent%20as%20the%20SecurityEvent%20can%20occur%20on%20any%20computer%20in%20the%20network%20at%20any%20given%20time%20after%20the%20initial%20outbound%20connection.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-497794%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20query%20for%20two%20events%20with%20no%20common%20fields%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-497794%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F326650%22%20target%3D%22_blank%22%3E%40CloudTesting%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%2C%20that%20extra%20Table%20name%20and%20info%20really%20helps%2C%20I%20didn't%20have%20any%20'ALLOW'%20activities%2C%20so%20line%205%20will%20need%20changing%20to%20match%20your%20test.%26nbsp%3B%20Hopefully%20this%20change%20is%20easy%20to%20understand%2C%20essentially%20I've%20created%20a%20variable%20to%20store%20when%20we%20get%20a%20success%2Fmatch%20in%20either%20table%20and%20JOIN%20on%20that.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETip%3A%20best%20practice%20is%20to%20use%20HAS%20rather%20than%20CONTAINS%20where%20possible%2C%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-gb%2Fazure%2Fazure-monitor%2Flog-query%2Flog-query-performance%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Esource%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20AzureDiagnostics%0A%7Cwhere%20TimeGenerated%20%26gt%3B%20ago(1d)%0A%7Cwhere%20Category%20%3D%3D%20%22AzureFirewallNetworkRule%22%0A%7Cwhere%20OperationName%20%3D%3D%20%22AzureFirewallNetworkRuleLog%22%0A%7Cwhere%20msg_s%20startswith%20%22TCP%20request%20from%20%22%20and%20msg_s%20endswith%20%22Action%3A%20Deny%22%20%20%2F%2F%20change%20this%20line%20back%20-%20used%20to%20test%20%0A%7Cproject%20Category%20%2C%20OperationName%20%2C%20msg_s%20%2C%20set_flag%20%3D1%20%20%20%2F%2F%20set%20a%20flag%20when%20we%20find%20a%20match%20%0A%7Cjoin%0A%20(SecurityEvent%0A%7C%20where%20Activity%20%3D%3D%20%224688%20-%20A%20new%20process%20has%20been%20created.%22%20%0A%7C%20where%20Process%20%3D%3D%20%22diskperf.exe%22%20%0A%7C%20project%20Activity%20%2CComputer%20%2CProcess%20%2C%20set_flag%20%3D1%20%20%2F%2F%20set%20a%20flag%20when%20we%20find%20a%20match%20%0A)%20on%20set_flag%20%20%2F%2F%20join%20on%20that%20flag%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Deleted
Not applicable

Hi,

 

I know one can query for two events that have a common field by the Join Operator, but how can I query two or more separate events that have no common fields?

I'm trying to track a couple of activities that have no common fields in one query.

 

Thank you.

 

7 Replies

@Deleted 

 

Something like:

 

Alert
| project AlertName, round_time=bin(TimeGenerated, 1m)
| join (Perf 
        | project Computer, 
        round_time=bin(TimeGenerated, 1m))
 on round_time

I use a rounded down timegenerated (as that is in both Tables)

@Clive Watson 

I'm sorry but I'm new to this, can you please elaborate on that or send me a link to some docs. How can this code help me query for two or more events in one query?

 

Thank you.

@Deleted 

 

Perhaps I'm not fully understanding the question.  You asked to Join two activities without a common field.  When you say events we would assume the Events table in Log Analytics, and by Join I assumed the join operator .   What do you mean my Events (do you mean an event in a table or row)? 

 

Which table are you referring to? 

A single Table will have always have common fields.  My example shows a join across two seperate tables, where their isn't a common field. 

 

Are you asking about two Event IDs, in a table.  For example.  The Events table?

 

// count all events that are 7036 and show their description
Event
| where TimeGenerated > ago(1d)
| where EventID == 7036
| summarize count() by  EventID,   RenderedDescription 

Showing two events, would be

// count all events that are 7036 or 7040 and show their description
Event
| where TimeGenerated > ago(1d)
| where EventID in ( 7036, 7040)
| summarize count() by  EventID

Or are you trying to join pieces of data in a single table?

Perf 
| where TimeGenerated > ago(10d)
| where CounterName  == "% Processor Time" 
| project CounterName, Computer, TimeGenerated   // added this to increase performance as "Use where and project to reduce the numbers of rows and columns in the input tables, before the join. "
| join kind= inner (
    Perf
    | where CounterName == "Processor Queue Length"
    | project CounterName , TimeGenerated , Computer 
) on TimeGenerated , Computer

 

 

Perhaps, you can send what you have so far, for us to look at?  If we can see a screenshot or pseudo code, with expected output that would help.

e.g.

 

"I'm looking at the Events table, I want to show if there are entries from a user called "Local Service" or "System".  I want to count how many times this happens."  Where an activity is a value of "nnnnn" 

 

Event
| where TimeGenerated > ago(1d)
| where UserName has "LOCAL SERVICE" or UserName has "SYSTEM"
| summarize count() by UserName

 

 

The main docs page is here: https://docs.microsoft.com/en-us/azure/kusto/query/ 

 

Thanks

 

 

@Clive Watson 

Thank you for the reply and I apologize for my lack of clarity.

I need to query if two events accrued within 24hrs.

One is a FireWall event of a connection being made to a certain external IP.

The second event is a SecurityEvent of a certain process being executed on any machine in the network (so I don't have common fields like machine name or IPs).

I can query them each individually, but how can I check if they both accrued in the last 24hrs in one query?

@Deleted 

 

Not a problem, I think I was close with my initial answer but used some example tables (not the ones you wanted).

 

Example 1

Here, in example code 1, we look at the last 24hrs, and select "cscript.exe" as an example process name (change to match yours).  I also look for a specific activity - again change this to suit.  We then use a project operator to only keep three columns - you may need more.  The last column is round_time, which takes a data/time which we use to join on later (rounded to 1m intervals - as we are unlikely to get a match on less than that)!

I then join the SecurityEvents table using that round_time, to WindowsFirewall table.  In addition we filter on a specific RemoteIP address (please change for one that matches yours).  You didn't mention which Firewall, so you might have that data in a table called CommonSecurityLog - in that case change WindowsFirewall to CommonSecurityLog.

 

 

SecurityEvent
| where TimeGenerated > ago(1d)  // filter in last 24hrs
| where Process =="cscript.exe"  // find a process 
| where Activity == "4688 - A new process has been created."   // look for "a new process has been created" eventid
| project Computer, Process, round_time=bin(TimeGenerated, 1m)  // set a value for time to enable a JOIN  
| join 
    (WindowsFirewall 
        | where RemoteIP == "192.168.137.1"  // find a specifc IP in the Windows Firewall logs 
        | project Computer, RemoteIP ,       // only project two columns
        round_time=bin(TimeGenerated, 1m)    // set time to match join 
    ) on round_time

You can run the above from here in the demo Log Analytics portal. 

 

 

Output

Annotation 2019-04-28 142534.jpg

 

 

Example 2:

 

SecurityEvent, WindowsFirewall and CommonSecurityLog - do all have common fields, so we could have just joined on Computer.  I don't know which firewall table you are looking at, you are using so this second example may not work in your case.

 

 

SecurityEvent
| where TimeGenerated > ago(1d)  // filter in last 24hrs
| where Process =="cscript.exe"  // find a process 
| where Activity == "4688 - A new process has been created."   // look for "a new process has been created" eventid
| project Computer, Process, Activity  // set a value for time to enable a JOIN  
| join 
    (WindowsFirewall 
        | where RemoteIP == "192.168.137.1"  // find a specifc IP in the Windows Firewall logs 
        | project Computer, RemoteIP 
    ) on Computer 

 

 

 

 

 

 

 

@Clive Watson 

First of all Thank You, I really appreciate your time and effort in helping me.

I think My problem is that unlike the cscript.exe file (which generates an Event almost every minute) the file I'm looking for may only be generated once in 24h, And will most likely be completely out of sync with the Firewall event (So the round_time will almost never be the same in both events).

As I understand, this is why when I run your query it works, but when I run mine I get nothing,

 

 AzureDiagnostics
|where TimeGenerated > ago(1d)
|where Category == "AzureFirewallNetworkRule"
|where OperationName == "AzureFirewallNetworkRuleLog"
|where msg_s contains "to *******. Action: Allow"
|project Category , OperationName , msg_s , round_time=bin(TimeGenerated, 1m)
|join
 (SecurityEvent
| where Activity == "4688 - A new process has been created."
| where Process == "******.exe"
| project Activity ,Computername ,Process , round_time=bin(TimeGenerated, 1m)
) on round_time

The source computer\IP in the Firewall event is irrelevant to the SecurityEvent as the SecurityEvent can occur on any computer in the network at any given time after the initial outbound connection.

 

Thank you.

Best Response
Solution

@Deleted 

 

Thanks, that extra Table name and info really helps, I didn't have any 'ALLOW' activities, so line 5 will need changing to match your test.  Hopefully this change is easy to understand, essentially I've created a variable to store when we get a success/match in either table and JOIN on that.

 

Tip: best practice is to use HAS rather than CONTAINS where possible, source.

 

 AzureDiagnostics
|where TimeGenerated > ago(1d)
|where Category == "AzureFirewallNetworkRule"
|where OperationName == "AzureFirewallNetworkRuleLog"
|where msg_s startswith "TCP request from " and msg_s endswith "Action: Deny"  // change this line back - used to test 
|project Category , OperationName , msg_s , set_flag =1   // set a flag when we find a match 
|join
 (SecurityEvent
| where Activity == "4688 - A new process has been created." 
| where Process == "diskperf.exe" 
| project Activity ,Computer ,Process , set_flag =1  // set a flag when we find a match 
) on set_flag  // join on that flag