Home
%3CLINGO-SUB%20id%3D%22lingo-sub-1092194%22%20slang%3D%22en-US%22%3ERe%3A%20Implementing%20Lookups%20in%20Azure%20Sentinel%20part%20%231%3A%20reference%20files%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1092194%22%20slang%3D%22en-US%22%3E%3CP%3ELooks%20like%20a%20word%20or%20two%20may%20have%20been%20left%20out%20this%20this%20sentence(s)%3C%2FP%3E%3CP%3E%22%3CSPAN%3ENext%2C%20we%20provided%20the%20URL.%20in%20front%20of%20the%20string%3A%20this%20ensures%20that%20we%20don%E2%80%99t%20log%20the%20string%22%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1091306%22%20slang%3D%22en-US%22%3EImplementing%20Lookups%20in%20Azure%20Sentinel%20part%20%231%3A%20reference%20files%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1091306%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20this%20blog%20post%20%E2%80%9C%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Sentinel%2FAzure-Sentinel-correlation-rules-Active-Lists-out-make-list-in%2Fba-p%2F1029225%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3EActive%20Lists%20out%3B%20make_list()%20in%3C%2FA%3E%E2%80%9D%2C%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F293879%22%20target%3D%22_blank%22%3E%40Ofer_Shezaf%3C%2FA%3E%26nbsp%3Breferred%20to%20one%20of%20the%20uses%20of%20Active%20Lists%20(ArcSight)%20or%20reference%20sets%20(QRadar)%2C%20namely%20implementing%20correlation.%20But%20Active%20Lists%2C%20reference%20sets%2C%20and%20the%20appropriately%20named%20Lookups%20in%20Splunk%20have%20another%20important%20use%3A%20lookups.%20In%20this%20blog%20post%2C%20I%20take%20an%20initial%20stub%20at%20doing%20lookups%20in%20Azure%20Sentinel.%3C%2FP%3E%0A%3CP%3EAzure%20Sentinel%20has%20a%20variety%20of%20methods%20to%20perform%20lookups%2C%20enabling%20diverse%20sources%20for%20the%20lookup%20data%20and%20different%20ways%20to%20process%20it.%20Overall%2C%20I%20think%20you%20will%20find%20that%20Azure%20Sentinel%20capabilities%20offer%20unparallel%20lookup%20prowess.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId-360205155%22%20id%3D%22toc-hId-360205155%22%20id%3D%22toc-hId-360205155%22%20id%3D%22toc-hId-360205155%22%20id%3D%22toc-hId-360205155%22%20id%3D%22toc-hId-360205155%22%20id%3D%22toc-hId-360205155%22%3EWhy%20lookups%3F%3C%2FH1%3E%0A%3CP%3EWhy%20do%20you%20need%20to%20look%20up%20information%20in%20a%20SIEM%20query%2C%20whether%20hunting%20queries%20or%20detection%20rules%3F%20The%20top%20reasons%20are%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EWhitelisting%20-%20making%20sure%20a%20query%20ignores%20known%20outliers%20that%20do%20not%20justify%20alerting%20on.%20For%20example%2C%20excluding%20a%20backup%20process%20from%20a%20query%20identifying%20access%20to%20large%20amounts%20of%20data.%3C%2FLI%3E%0A%3CLI%3EWatch%20lists%20-%20in%20reverse%2C%20making%20sure%20that%20alerts%20with%20the%20listed%20entities%20are%20promoted%2C%20whether%20by%20assigning%20a%20higher%20severity%20or%20by%20alerting%20only%20on%20those.%20For%20example%2C%20flagging%20access%20to%20sensitive%20finance%20files.%3C%2FLI%3E%0A%3CLI%3EEnrichment%20%E2%80%93%20extending%20events%20or%20alerts%20with%20additional%20information%20needed%20for%20detection%20or%20investigation.%20Common%20enrichment%20sources%20include%20user%20information%2C%20asset%20or%20resource%20information%2C%20geoinformation%2C%20and%20threat%20intelligence.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThose%20are%20critical%20capabilities%20of%20a%20SIEM.%20While%20each%20specialized%20security%20tool%20has%20a%20partial%20view%20of%20the%20world%2C%20a%20SIEM%20can%20utilize%20its%20broader%20outreach%20to%20enrich%20event%20and%20alert%20data%20and%20centrally%20manage%20white%20lists%20and%20watch%20lists.%3C%2FP%3E%0A%3CP%3EIn%20this%20blog%20post%2C%20I%20examine%20implementing%20all%20those%20use%20cases%20in%20Azure%20Sentinel.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId--1447249308%22%20id%3D%22toc-hId--1447249308%22%20id%3D%22toc-hId--1447249308%22%20id%3D%22toc-hId--1447249308%22%20id%3D%22toc-hId--1447249308%22%20id%3D%22toc-hId--1447249308%22%20id%3D%22toc-hId--1447249308%22%3ELookup%20files%3C%2FH1%3E%0A%3CP%3ETo%20reference%20the%20data%2C%20we%20first%20need%20to%20locate%20it.%20The%20variety%20of%20use%20cases%20above%20implies%20that%20the%20data%20may%20exist%20in%20many%20places%20and%20accessible%20by%20different%20means.%20I%20will%20discuss%20referencing%20lookup%20data%20in%20databases%20or%20applications%20accessible%20using%20an%20API%20in%20later%20blog%20posts%20but%20start%20with%20the%20most%20common%20lookup%20source%3A%20files.%20Being%20the%20least%20common%20denominator%2C%20files%20are%20ubiquitous%20for%20lookups%20and%20can%20be%20used%20in%20nearly%20every%20circumstance%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EAnyone%20can%20manually%20create%20or%20edit%20them%3C%2FLI%3E%0A%3CLI%3EIt%20is%20easy%20to%20fetch%20data%20from%20any%20other%20source%20and%20keep%20it%20as%20a%20file%20for%20lookups%3C%2FLI%3E%0A%3CLI%3ELike%20Azure%20Sentinel%2C%20they%20are%20flexible%20concerning%20format%2C%20allowing%20less%20upfront%20hassle%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId-1040263525%22%20id%3D%22toc-hId-1040263525%22%20id%3D%22toc-hId-1040263525%22%20id%3D%22toc-hId-1040263525%22%20id%3D%22toc-hId-1040263525%22%20id%3D%22toc-hId-1040263525%22%20id%3D%22toc-hId-1040263525%22%3EThe%20KQL%20externaldata%20operator%3C%2FH1%3E%0A%3CP%3ETo%20support%20a%20lookup%20from%20an%20external%20file%2C%20KQL%20offers%20the%20%22%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fexternaldata-operator%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eexernaldata%3C%2FA%3E%22%20operator.%20Unlike%20lookup%20implementation%20in%20other%20SIEM%20products%2C%20Externaldata%20is%20not%20a%20lookup%20operator.%20Instead%2C%20externaldata%20enable%20using%20files%20as%20if%20they%20were%20Azure%20Sentinel%20tables%2C%20which%20allows%20preprocessing%20of%20the%20file%20before%20actually%20performing%20the%20lookup%2C%20for%20example%20filtering%2C%20parsing.%20I%20will%20demonstrate%20each%20in%20the%20examples%20below.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId--767190938%22%20id%3D%22toc-hId--767190938%22%20id%3D%22toc-hId--767190938%22%20id%3D%22toc-hId--767190938%22%20id%3D%22toc-hId--767190938%22%20id%3D%22toc-hId--767190938%22%20id%3D%22toc-hId--767190938%22%3EStep%20by%20step%3A%20whitelisting%3C%2FH1%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--76629464%22%20id%3D%22toc-hId--76629464%22%20id%3D%22toc-hId--76629464%22%20id%3D%22toc-hId--76629464%22%20id%3D%22toc-hId--76629464%22%20id%3D%22toc-hId--76629464%22%20id%3D%22toc-hId--76629464%22%3ECreating%20the%20file%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ECreate%20an%20Azure%20storage%20account%3C%2FLI%3E%0A%3CLI%3ECreate%20a%20blob%20container%3C%2FLI%3E%0A%3CLI%3EUpload%20to%20it%20your%20lookup%20file%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EIn%20the%20following%20sections%20I%20will%20use%20the%20following%20CSV%20file%2C%20conveniently%20created%20in%20Excel%3A%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%221%202%203%204%205%206%207%22%3E%3CEM%3EUserName%2CDisplayName%2CRisk%2CLocation%3C%2FEM%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%221%202%203%204%205%206%207%22%3E%3CEM%3Echris%40contoso.com%2CChris%20Green%2C70%2C%22%7B%20%22%22City%22%22%3A%20%22%22Redmond%22%22%2C%20%22%22State%22%22%3A%20%22%22Washintgon%22%22%2C%20%22%22Country%22%22%3A%20%22%22US%22%22%20%7D%22%3C%2FEM%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%221%202%203%204%205%206%207%22%3E%3CEM%3Eben%40contoso.com%2CBen%20Andrews%2C100%2C%22%7B%20%22%22City%22%22%3A%20%22%22Oxford%22%22%2C%20%22%22State%22%22%3A%20%22%22Oxfordshare%22%22%2C%20%22%22Country%22%22%3A%20%22%22UK%22%22%20%7D%22%3C%2FEM%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%221%202%203%204%205%206%207%22%3E%3CEM%3Enir%40contoso.com%2CNir%20Cohen%2C50%2C%22%7B%20%22%22City%22%22%3A%20%22%22Tel-Aviv%22%22%2C%20%22%22State%22%22%3A%20%22%22%22%22%2C%20%22%22Country%22%22%3A%20%22%22IL%22%22%20%7D%22%3C%2FEM%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%221%202%203%204%205%206%207%22%3E%3CEM%3EGabriela%40contoso.com%2CCynthia%20Silva%2C20%2C%22%7B%20%22%22City%22%22%3A%20%22%22Rio%20de%20Janeiro%22%22%2C%20%22%22State%22%22%3A%20%22%22Rio%20de%20Janeiro%22%22%2C%20%22%22Country%22%22%3A%20%22%22BR%22%22%20%7D%22%3C%2FEM%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%221%202%203%204%205%206%207%22%3E%3CEM%3Emelissa%40contoso.com%2CChandana%26nbsp%3B%20Agarwals%26nbsp%3B%2C100%2C%22%7B%20%22%22City%22%22%3A%20%22%22Mumbai%22%22%2C%20%22%22State%22%22%3A%20%22%22Maharashtra%22%22%2C%20%22%22Country%22%22%3A%20%22%22IN%22%22%20%7D%22%3C%2FEM%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20get%20a%20secure%20access%20URL%2C%20use%20the%20%E2%80%9CGet%20Shared%20Access%20Signature%E2%80%A6%E2%80%9D%20feature%2C%20which%20generates%20for%20you%20a%20URL%20similar%20to%20this%20one%3A%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23993300%22%3Ehttps%3A%2F%2F***.blob.core.windows.net%2Fexternaldata%2Fusers.csv%3Fsp%3Drl%26amp%3Bst%3D2019-12-23T12%3A49%3A20Z%26amp%3Bse%3D2019-12-24T12%3A49%3A20Z%26amp%3Bsv%3D2019-02-02%26amp%3Bsr%3Db%26amp%3Bsig%3D***...***%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20688px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F163799iEF464DF20BF8954B%2Fimage-dimensions%2F688x432%3Fv%3D1.0%22%20width%3D%22688%22%20height%3D%22432%22%20alt%3D%22clipboard_image_0.png%22%20title%3D%22clipboard_image_0.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1884083927%22%20id%3D%22toc-hId--1884083927%22%20id%3D%22toc-hId--1884083927%22%20id%3D%22toc-hId--1884083927%22%20id%3D%22toc-hId--1884083927%22%20id%3D%22toc-hId--1884083927%22%20id%3D%22toc-hId--1884083927%22%3EUsing%20the%20reference%20file%20in%20KQL%3C%2FH2%3E%0A%3CP%3ESince%20we%20start%20with%20a%20whitelist%20example%2C%20we%20need%20only%20the%20first%20column%20from%20the%20lookup%20file%20and%20can%20use%20the%20following%20KQL%20command%20to%20reference%20the%20file%3A%3C%2FP%3E%0A%3CPRE%3Eexternaldata%20(UserPrincipalName%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000FF%22%3Estring%3C%2FFONT%3E)%20%5Bh%3CFONT%20color%3D%22%23993300%22%3E%22https%3A%2F%2F...%22%3C%2FFONT%3E%5D%20with%20(ignoreFirstRecord%3D%3CFONT%20color%3D%22%230000FF%22%3Etrue%3C%2FFONT%3E)%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELet%E2%80%99s%20examine%20the%20query.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EFirst%2C%20we%20defined%20the%20type%20for%20the%20first%20column%20in%20the%20CSV%20file.%20String%20in%20this%20case.%3C%2FLI%3E%0A%3CLI%3ENext%2C%20we%20provided%20the%20URL.%20Note%20the%20%E2%80%9Ch%E2%80%9D%20added%20in%20front%20of%20the%20string%3A%20this%20ensures%20that%20we%20don%E2%80%99t%20log%20the%20string%2C%20which%20includes%20sensitive%20information%2C%20to%20our%20internal%20audit%20logs.%20For%20more%20information%20on%20query%20obfuscation%20read%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fscalar-data-types%2Fstring%23obfuscated-string-literals%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FLI%3E%0A%3CLI%3ELast%2C%20we%20use%20the%20attribute%20ignoreFirstRecord%3D%3CFONT%20color%3D%22%230000FF%22%3Etrue%3C%2FFONT%3E%2C%20since%20the%20first%20line%20includes%20column%20names%20and%20is%20not%20relevant.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EWhen%20you%20run%20this%20query%2C%20you%20get%20this%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20225px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F163797i31119FF3581B09D2%2Fimage-dimensions%2F225x196%3Fv%3D1.0%22%20width%3D%22225%22%20height%3D%22196%22%20alt%3D%22clipboard_image_1.png%22%20title%3D%22clipboard_image_1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EOnly%20the%20first%20column%20of%20the%20file%20is%20used%20since%20we%20defined%20a%20type%20only%20for%20it.%3C%2FP%3E%0A%3CP%3EThe%20filename%20extension%20identifies%20the%20file%20as%20CSV%3B%20however%2C%20we%20could%20have%20overridden%20the%20type.%20For%20example%2C%20if%20we%20force%20%E2%80%9Ctxt%E2%80%9D%20as%20the%20file%20type%2C%20each%20file%20line%20is%20considered%20a%20single%20field%2C%20and%20the%20query%20returns%20in%20the%20UserName%20field%20the%20entire%20line.%20Other%20supported%20formats%20include%20JSON%20and%20AVRO%2C%20as%20well%20as%20compressed%20files.%3C%2FP%3E%0A%3CPRE%3Eexternaldata%20(UserPrincipalName%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000FF%22%3Estring%3C%2FFONT%3E)%20%5Bh%3CFONT%20color%3D%22%23993300%22%3E%22https%3A%2F%2F...%22%3C%2FFONT%3E%5D%20with%20(ignoreFirstRecord%3D%3CFONT%20color%3D%22%230000FF%22%3Etrue%3CFONT%20color%3D%22%23000000%22%3E%2C%20format%3D%3C%2FFONT%3E%22txt%22%3C%2FFONT%3E)%3C%2FPRE%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20722px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F163798iBDB4B80853D47ABE%2Fimage-dimensions%2F722x186%3Fv%3D1.0%22%20width%3D%22722%22%20height%3D%22186%22%20alt%3D%22clipboard_image_2.png%22%20title%3D%22clipboard_image_2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EFor%20a%20full%20list%20of%20supported%20file%20types%20and%20other%20attributes%2C%20refer%20to%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fmanagement%2Fdata-ingestion%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ethis%3C%2FA%3E%20page.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-603428906%22%20id%3D%22toc-hId-603428906%22%20id%3D%22toc-hId-603428906%22%20id%3D%22toc-hId-603428906%22%20id%3D%22toc-hId-603428906%22%20id%3D%22toc-hId-603428906%22%20id%3D%22toc-hId-603428906%22%3EUsing%20the%20reference%20table%20to%20white%20list%20users%3C%2FH2%3E%0A%3CP%3ETo%20implement%20while%20listing%2C%20let%E2%80%99s%20take%20Azure%20Sentinel%E2%80%99s%20rules%20to%20detect%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FDetections%2FSigninLogs%2FFailedLogonToAzurePortal.yaml%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EFailed%20login%20attempts%20to%20Azure%20Portal%3C%2FA%3E.%20The%20modified%20(and%20abbreviated)%20query%20is%20below%2C%20with%20the%20modifications%20marked%20in%20yellow%3A%3C%2FP%3E%0A%3CPRE%3Elet%20timeRange%20%3D%201d%3B%3CBR%20%2F%3E%3CSTRONG%3E%3CSPAN%20style%3D%22background-color%3A%20yellow%3B%22%3Elet%20whitelist%20%3D%20externaldata%20(UserPrincipalName%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000FF%22%3Estring%3C%2FFONT%3E)%20%5Bh%3CFONT%20color%3D%22%23993300%22%3E%22https%3A%2F%2F...%22%3C%2FFONT%3E%5D%20with%20(ignoreFirstRecord%3D%3CFONT%20color%3D%22%230000FF%22%3Etrue%3C%2FFONT%3E)%3B%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CBR%20%2F%3ESigninLogs%3CBR%20%2F%3E%7C%20%3CFONT%20color%3D%22%230000FF%22%3Ewhere%3C%2FFONT%3E%20TimeGenerated%20%26gt%3B%3D%20ago(timeRange)%3CBR%20%2F%3E%E2%80%A6%3CBR%20%2F%3E%3CFONT%20color%3D%22%23339966%22%3E%2F%2F%20Exclude%20non-failure%20types%3C%2FFONT%3E%3CBR%20%2F%3E%7C%20%3CFONT%20color%3D%22%230000FF%22%3Ewhere%3C%2FFONT%3E%20ResultType%20!in%20(%3CFONT%20color%3D%22%23993300%22%3E%220%22%3C%2FFONT%3E%2C%20%3CFONT%20color%3D%22%23993300%22%3E%2250125%22%3C%2FFONT%3E%2C%20%3CFONT%20color%3D%22%23993300%22%3E%2250140%22%3C%2FFONT%3E)%3CBR%20%2F%3E%3CSTRONG%3E%3CSPAN%20style%3D%22background-color%3A%20yellow%3B%22%3E%3CFONT%20color%3D%22%23339966%22%3E%2F%2F%20Exclude%20whitelisted%20users%3C%2FFONT%3E%3CBR%20%2F%3E%7C%20%3CFONT%20color%3D%22%230000FF%22%3Ewhere%3C%2FFONT%3E%20UserPrincipalName%20!in~%20(whitelist)%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CBR%20%2F%3E%E2%80%A6%3C%2FPRE%3E%0A%3CP%3EThe%20first%20modification%20defined%20the%20whitelist%20table%20using%20the%20externaldata%20command.%20Strictly%20speaking%2C%20you%20don%E2%80%99t%20have%20to%20define%20in%20advance%20the%20whitelist%20table%2C%20but%20it%20adds%20a%20lot%20to%20readability.%20The%20second%20modification%20checked%20that%20the%20UPN%20is%20not%20in%20the%20white%20list%20table.%20That%E2%80%99s%20all.%3C%2FP%3E%0A%3CP%3EWonder%20why%20the%20%E2%80%9C~%E2%80%9D%3B%20in%20the%20%E2%80%9Cnot%20in%E2%80%9D%20operator%3F%20It%20means%20that%20the%20comparison%20is%20case%20insensitive.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId-592925802%22%20id%3D%22toc-hId-592925802%22%20id%3D%22toc-hId-592925802%22%20id%3D%22toc-hId-592925802%22%20id%3D%22toc-hId-592925802%22%20id%3D%22toc-hId-592925802%22%20id%3D%22toc-hId-592925802%22%3EWatch%20lists%3C%2FH1%3E%0A%3CP%3ELet%E2%80%99s%20use%20the%20same%20alert%20rule%20to%20demonstrate%20a%20watch%20list.%20Login%20failures%20are%20not%20particularly%20interesting%3B%20however%2C%20there%20might%20be%20a%20few%20users%20for%20which%20we%20want%20to%20check%20each%20failure.%20Assume%20that%20those%20are%20the%20users%20for%20which%20the%20risk%20is%20higher%20in%20our%20lookup%20table.%3C%2FP%3E%0A%3CP%3ENow%20we%20need%20additional%20fields%20in%20the%20reference%20table%2C%20so%20let%E2%80%99s%20extend%20the%20mapping%20of%20the%20fields.%20By%20specifying%20the%20other%20columns%20in%20the%20source%20file%2C%20we%20make%20them%20all%20available%20for%20our%20queries%3A%3C%2FP%3E%0A%3CPRE%3Eexternaldata%20(UserPrincipalName%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000FF%22%3Estring%3CFONT%20color%3D%22%23000000%22%3E%2C%20DisplayName%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000FF%22%3Estring%3C%2FFONT%3E%2C%20Risk%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000FF%22%3Eint%3C%2FFONT%3E%2C%20Location%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000FF%22%3Edynamic%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FFONT%3E)%20%5Bh%3CFONT%20color%3D%22%23993300%22%3E%22https%3A%2F%2F...%22%3C%2FFONT%3E%5D%20with%20(ignoreFirstRecord%3D%3CFONT%20color%3D%22%230000FF%22%3Etrue%3C%2FFONT%3E)%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F163800i44D3D6A39801B62E%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22clipboard_image_3.png%22%20title%3D%22clipboard_image_3.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%2C%20by%20slightly%20modifying%20the%20alert%20rule%20query%20we%20implement%20our%20watch%20list%3A%3C%2FP%3E%0A%3CPRE%3Elet%20timeRange%20%3D%201d%3B%3CBR%20%2F%3E%3CSTRONG%3E%3CSPAN%20style%3D%22background-color%3A%20yellow%3B%22%3Elet%20%3CSPAN%20style%3D%22background-color%3A%20%2300fefe%3B%22%3Ewatchlist%3C%2FSPAN%3E%20%3D%20externaldata%20(UserPrincipalName%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000FF%22%3Estring%3CFONT%20color%3D%22%23000000%22%3E%20%3CSPAN%20style%3D%22background-color%3A%20%2300ff00%3B%22%3E%2C%20DisplayName%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000FF%22%3Estring%3C%2FFONT%3E%2C%20Risk%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000FF%22%3Eint%3C%2FFONT%3E%2C%20Location%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000FF%22%3Estring%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FFONT%3E)%20%5Bh%3CFONT%20color%3D%22%23993300%22%3E%22https%3A%2F%2F...%22%3C%2FFONT%3E%5D%20with%20(ignoreFirstRecord%3D%3CFONT%20color%3D%22%230000FF%22%3Etrue%3C%2FFONT%3E)%3CBR%20%2F%3E%3C%2FSPAN%3E%3CSPAN%20style%3D%22background-color%3A%20%23ff00ff%3B%22%3E%7C%20where%20Risk%20%26gt%3B%20%3CFONT%20color%3D%22%23339966%22%3E90%3C%2FFONT%3E%3B%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CBR%20%2F%3ESigninLogs%3CBR%20%2F%3E%7C%20%3CFONT%20color%3D%22%230000FF%22%3Ewhere%3C%2FFONT%3E%20TimeGenerated%20%26gt%3B%3D%20ago(timeRange)%3CBR%20%2F%3E%E2%80%A6%3CBR%20%2F%3E%3CFONT%20color%3D%22%23339966%22%3E%2F%2F%20Exclude%20non-failure%20types%3C%2FFONT%3E%3CBR%20%2F%3E%7C%20%3CFONT%20color%3D%22%230000FF%22%3Ewhere%3C%2FFONT%3E%20ResultType%20!in%20(%3CFONT%20color%3D%22%23993300%22%3E%220%22%3C%2FFONT%3E%2C%20%3CFONT%20color%3D%22%23993300%22%3E%2250125%22%3C%2FFONT%3E%2C%20%3CFONT%20color%3D%22%23993300%22%3E%2250140%22%3C%2FFONT%3E)%3CBR%20%2F%3E%3CSTRONG%3E%3CSPAN%20style%3D%22background-color%3A%20yellow%3B%22%3E%3CFONT%20color%3D%22%23339966%22%3E%2F%2F%20%3CSPAN%20style%3D%22background-color%3A%20%2300fefe%3B%22%3EInclude%20only%20watched%3C%2FSPAN%3E%20users%3C%2FFONT%3E%3CBR%20%2F%3E%7C%20%3CFONT%20color%3D%22%230000FF%22%3Ewhere%3C%2FFONT%3E%20UserPrincipalName%20%3CSPAN%20style%3D%22background-color%3A%20%23ff00ff%3B%22%3Ein~%3C%2FSPAN%3E%20(%3CSPAN%20style%3D%22background-color%3A%20%2300fefe%3B%22%3Ewatchlist%3C%2FSPAN%3E)%3C%2FSPAN%3E%3C%2FSTRONG%3E%3CBR%20%2F%3E%E2%80%A6%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20changes%20are%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EIn%20%3CSPAN%20style%3D%22background-color%3A%20%2300ff00%3B%22%3Egreen%3C%2FSPAN%3E%2C%20As%20discussed%2C%20we%20now%20map%20all%20the%20fields%20in%20the%20reference%20file.%20Though%20we%20still%20don%E2%80%99t%20need%20the%20location%20field%2C%20it%20will%20be%20handy%20in%20the%20next%20exercise.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CUL%3E%0A%3CLI%3EIn%20%3CSPAN%20style%3D%22background-color%3A%20%23ff00ff%3B%22%3Epink%3C%2FSPAN%3E%2C%20%26nbsp%3Bthe%20logic%20changes%3A%20first%20filtering%20the%20lookup%20table%20only%20for%20users%20with%20a%20risk%20higher%20than%2090%2C%20and%20then%20changing%20the%20selection%20criteria%20in%20the%20query%20itself%20from%20%E2%80%9C!in%E2%80%9D%20to%20%E2%80%9Cin%E2%80%9D%2C%20as%20now%20we%20want%20to%20match%20only%20on%20users%20in%20the%20list%20rather%20than%20exclude%20them.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CUL%3E%0A%3CLI%3EIn%20%3CSPAN%20style%3D%22background-color%3A%20%2300fefe%3B%22%3Ecyan%3C%2FSPAN%3E%2C%20cosmetic%20changes%3A%20changing%20the%20lookup%20table%20name%20from%20whitelist%20to%20watchlist%20and%20updating%20the%20comments.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EYou%20may%20notice%20that%20the%20watchlist%20table%20has%204%20columns%20and%20ask%20yourself%20how%20is%20it%20used%20in%20an%20%E2%80%9Cin%E2%80%9D%20clause.%20When%20a%20table%20is%20used%20with%20the%20%E2%80%9Cin%E2%80%9D%20clause%2C%20the%20first%20column%20is%20used%2C%20which%20is%20what%20we%20need%20here.%20If%20we%20had%20liked%20to%20check%20against%20a%20different%20column%2C%20we%20could%20have%20appended%20a%20%E2%80%9C%3CSPAN%20style%3D%22background-color%3A%20yellow%3B%22%3Eproject%3C%2FSPAN%3E%E2%80%9D%20operator%20after%20the%20%E2%80%9Cwhere%20Risk%20%26gt%3B%2090%E2%80%9D%20phrase%20to%20select%20the%20field%20we%20want%20to%20match%20against%3A%3C%2FP%3E%0A%3CPRE%3Elet%20watchlist%20%3D%20externaldata%20(UserPrincipalName%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000FF%22%3Estring%3CFONT%20color%3D%22%23000000%22%3E%2C%20DisplayName%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000FF%22%3Estring%3C%2FFONT%3E%2C%20Risk%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000FF%22%3Eint%3C%2FFONT%3E%2C%20Location%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000FF%22%3Estring%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FFONT%3E)%20%5Bh%3CFONT%20color%3D%22%23993300%22%3E%22https%3A%2F%2F...%22%3C%2FFONT%3E%5D%20with%20(ignoreFirstRecord%3D%3CFONT%20color%3D%22%230000FF%22%3Etrue%3C%2FFONT%3E)%3CBR%20%2F%3E%7C%20%3CFONT%20color%3D%22%230000FF%22%3Ewhere%3C%2FFONT%3E%20Risk%20%26gt%3B%20%3CFONT%20color%3D%22%23339966%22%3E90%3C%2FFONT%3E%20%7C%20%3CSPAN%20style%3D%22background-color%3A%20yellow%3B%22%3E%3CFONT%20color%3D%22%230000FF%22%3Eproject%20%3C%2FFONT%3EUserPrincipalName%3C%2FSPAN%3E%3C%2FPRE%3E%0A%3CH1%20id%3D%22toc-hId--1214528661%22%20id%3D%22toc-hId--1214528661%22%20id%3D%22toc-hId--1214528661%22%20id%3D%22toc-hId--1214528661%22%20id%3D%22toc-hId--1214528661%22%20id%3D%22toc-hId--1214528661%22%20id%3D%22toc-hId--1214528661%22%3E%26nbsp%3B%3C%2FH1%3E%0A%3CH1%20id%3D%22toc-hId-1272984172%22%20id%3D%22toc-hId-1272984172%22%20id%3D%22toc-hId-1272984172%22%20id%3D%22toc-hId-1272984172%22%20id%3D%22toc-hId-1272984172%22%20id%3D%22toc-hId-1272984172%22%20id%3D%22toc-hId-1272984172%22%3EEnrichment%3C%2FH1%3E%0A%3CP%3ELet%E2%80%99s%20look%20at%20an%20additional%20piece%20of%20information%20available%20in%20the%20lookup%20file%3A%20the%20location%20of%20the%20user.%20Another%20option%20for%20making%20the%20failed%20login%20rule%20better%20is%20to%20alert%20only%20on%20failed%20login%20attempts%20by%20users%20originating%20not%20from%20their%20home%20country.%20To%20do%20that%2C%20we%20need%20to%20enrich%20the%20failed%20login%20event%20with%20information%20about%20the%20user%E2%80%99s%20home%20country.%3C%2FP%3E%0A%3CP%3EThis%20requires%20two%20significant%20additions%20to%20the%20toolbox%20we%20used%20for%20white%20lists%20and%20watch%20lists%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EThe%20country%20information%20is%20a%20part%20of%20a%20field%20value.%20We%20need%20to%20extract%20it%20to%20use%20it.%3C%2FLI%3E%0A%3CLI%3ETo%20look%20up%20a%20user%20and%20enrich%20the%20event%20with%20the%20country%20information%2C%20the%20%E2%80%9Cin%E2%80%9D%20operator%20would%20not%20do.%20We%20need%20a%20more%20versatile%20method%3A%20the%20%E2%80%9Cjoin%E2%80%9D%20operator.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--657651911%22%20id%3D%22toc-hId--657651911%22%20id%3D%22toc-hId--657651911%22%20id%3D%22toc-hId--657651911%22%20id%3D%22toc-hId--657651911%22%20id%3D%22toc-hId--657651911%22%20id%3D%22toc-hId--657651911%22%3EExtracting%20fields%3C%2FH2%3E%0A%3CP%3EExtracting%20the%20country%20code%20from%20the%20reference%20table%20is%20an%20excellent%20example%20of%20the%20versatility%20that%20externaldata%20provides.%20By%20making%20the%20reference%20file%20a%20native%20table%2C%20it%20enables%20further%20processing%20it.%3C%2FP%3E%0A%3CP%3EFor%20example%2C%20we%20can%20extract%20the%20country%20code%20from%20the%20location%20string%20using%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fextractfunction%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eextract%3C%2FA%3E%20function%2C%20which%20applies%20a%20regex%20to%20the%20Location%20field%20and%20assigns%20the%20identified%20part%20to%20the%20user_country%20calculated%20field%3A%3C%2FP%3E%0A%3CPRE%3Eexternaldata%20(UserPrincipalName%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000FF%22%3Estring%3CFONT%20color%3D%22%23000000%22%3E%2C%20DisplayName%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000FF%22%3Estring%3C%2FFONT%3E%2C%20Risk%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000FF%22%3Eint%3C%2FFONT%3E%2C%20Location%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000FF%22%3Estring%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FFONT%3E)%20%5Bh%3CFONT%20color%3D%22%23993300%22%3E%22https%3A%2F%2F...%22%3C%2FFONT%3E%5D%20with%20(ignoreFirstRecord%3D%3CFONT%20color%3D%22%230000FF%22%3Etrue%3C%2FFONT%3E)%3CBR%20%2F%3E%3CSPAN%20style%3D%22background-color%3A%20yellow%3B%22%3E%7C%20%3CFONT%20color%3D%22%230000FF%22%3Eextend%3C%2FFONT%3E%20user_country%20%3D%20extract%20(%3CFONT%20color%3D%22%23800000%22%3E'Country%22%3A%20%22(.*)%22'%3C%2FFONT%3E%2C%20%3CFONT%20color%3D%22%23339966%22%3E1%3C%2FFONT%3E%2C%20Location)%3C%2FSPAN%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHowever%2C%20since%20the%20Location%20field%20is%20in%20JSON%20format%2C%20an%20alternative%20would%20be%20to%20use%20it%20as%20such.%20By%20changing%20the%20type%20of%20the%20Location%20field%20to%20%E2%80%9Cdynamic%E2%80%9D%2C%20we%20can%20get%20user_country%20much%20more%20directly%3A%3C%2FP%3E%0A%3CPRE%3Eexternaldata%20(UserPrincipalName%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000FF%22%3Estring%3CFONT%20color%3D%22%23000000%22%3E%2C%20DisplayName%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20string%2C%20%3CFONT%20color%3D%22%230000FF%22%3ERisk%3C%2FFONT%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20int%2C%20Location%3CFONT%20color%3D%22%23FF0000%22%3E%3A%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000FF%22%3E%3CSPAN%20style%3D%22background-color%3A%20yellow%3B%22%3Edynamic%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FFONT%3E)%20%5Bh%3CFONT%20color%3D%22%23993300%22%3E%22https%3A%2F%2F...%22%3C%2FFONT%3E%5D%20with%20(ignoreFirstRecord%3D%3CFONT%20color%3D%22%230000FF%22%3Etrue%3C%2FFONT%3E)%3CBR%20%2F%3E%7C%20%3CFONT%20color%3D%22%230000FF%22%3Eextend%3C%2FFONT%3E%20user_country%20%3D%20%3CSPAN%20style%3D%22background-color%3A%20yellow%3B%22%3ELocation.Country%3C%2FSPAN%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1829860922%22%20id%3D%22toc-hId-1829860922%22%20id%3D%22toc-hId-1829860922%22%20id%3D%22toc-hId-1829860922%22%20id%3D%22toc-hId-1829860922%22%20id%3D%22toc-hId-1829860922%22%20id%3D%22toc-hId-1829860922%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-22406459%22%20id%3D%22toc-hId-22406459%22%20id%3D%22toc-hId-22406459%22%20id%3D%22toc-hId-22406459%22%20id%3D%22toc-hId-22406459%22%20id%3D%22toc-hId-22406459%22%20id%3D%22toc-hId-22406459%22%3EDetection%20using%20the%20country%20value%3C%2FH2%3E%0A%3CP%3EOnce%20the%20country%20code%20is%20available%2C%20regardless%20of%20the%20method%2C%20we%20can%20apply%20it%20to%20the%20events%20for%20detection%20purposes%20using%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fjoinoperator%3Fpivots%3Dazuredataexplorer%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ejoin%3C%2FA%3E%20operator%3A%3C%2FP%3E%0A%3CPRE%3Elet%20timeRange%20%3D%20%3CFONT%20color%3D%22%23008000%22%3E1%3C%2FFONT%3Ed%3B%3CBR%20%2F%3Elet%20userinfo%20%3D%20externaldata%3CBR%20%2F%3E%E2%80%A6%3CBR%20%2F%3Elet%20failed_singins%20%3D%20SigninLogs%3CBR%20%2F%3E%E2%80%A6%3CBR%20%2F%3E%3CSTRONG%3E%3CSPAN%20style%3D%22background-color%3A%20yellow%3B%22%3Efailed_singins%20%7C%20%3CFONT%20color%3D%22%230000FF%22%3Ejoin%3C%2FFONT%3E%20kind%3D%20inner%20(userinfo)%20%3CFONT%20color%3D%22%230000FF%22%3Eon%3C%2FFONT%3E%20UserPrincipalName%3CBR%20%2F%3E%7C%20%3CFONT%20color%3D%22%230000FF%22%3Ewhere%20%3C%2FFONT%3ELocation%20!%3D%20user_country%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20join%20statement%20works%20as%20follows%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EThe%20query%20assigns%20the%20label%20%E2%80%9Cuserinfo%E2%80%9D%20to%20the%20parsed%20reference%20table%20from%20the%20previous%20section.%3C%2FLI%3E%0A%3CLI%3EIt%20then%20labels%20the%20original%20rule%20query%20as%20%E2%80%9Cfailed_signins%E2%80%9D.%3C%2FLI%3E%0A%3CLI%3EThe%20%E2%80%9Cjoin%E2%80%9D%20operator%20than%20enriches%20the%20failed_singins%20by%20matching%20the%20relevant%20userinfo%20records%20and%20appending%20all%20its%20fields%20to%20the%20failed%20signin%20event.%3C%2FLI%3E%0A%3CLI%3ELastly%2C%20the%20%E2%80%9CLocation%E2%80%9D%20of%20the%20original%20event%20is%20compared%20to%20the%20%E2%80%9Cuser_country%E2%80%9D%20which%20is%20the%20home%20country%20of%20the%20user%20and%20was%20appended%20in%20the%20previous%20step%20and%20alert%20only%20if%20they%20are%20different.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId--1914130723%22%20id%3D%22toc-hId--1914130723%22%20id%3D%22toc-hId--1914130723%22%20id%3D%22toc-hId--1914130723%22%20id%3D%22toc-hId--1914130723%22%20id%3D%22toc-hId--1914130723%22%20id%3D%22toc-hId--1914130723%22%3EHunting%20and%20investigation%3C%2FH1%3E%0A%3CP%3ETo%20make%20reference%20tables%20easier%20to%20use%20interactively%20by%20analysts%2C%20you%20can%20sage%20the%20externaldata%20query%20as%20a%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Flog-query%2Ffunctions%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Efunction%3C%2FA%3E.%20This%20way%2C%20it%20can%20be%20used%20in%20any%20of%20the%20use%20cases%20above%20without%20needing%20to%20include%20the%20URL%20or%20the%20parsing%20clauses%20directly.%20So%2C%20for%20example%2C%20if%20the%20last%20externaldata%20query%20above%20is%20saved%20as%20the%20function%20%22userinfo%22%2C%20the%20%22join%22%20statement%20could%20have%20used%20userinfo%20without%20explicitly%20defining%20it%20in%20the%20query%20itself.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId-573382110%22%20id%3D%22toc-hId-573382110%22%20id%3D%22toc-hId-573382110%22%20id%3D%22toc-hId-573382110%22%20id%3D%22toc-hId-573382110%22%20id%3D%22toc-hId-573382110%22%20id%3D%22toc-hId-573382110%22%3EWrapping%20up%3C%2FH1%3E%0A%3CP%3EThis%20blog%20post%20shows%20how%20to%20use%20the%20KQL%20externaldata%20operator%20to%20utilize%20a%20reference%20file%20for%20three%20use%20cases%3A%20whitelisting%2C%20watch%20lists%2C%20and%20enrichment.%20In%20an%20upcoming%20blog%20post%2C%20I%20will%20show%20you%20how%20to%20implement%20these%20use%20cases%20for%20reference%20tables%2C%20which%20are%20not%20available%20as%20files.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1091306%22%20slang%3D%22en-US%22%3E%3CP%3ELearn%20how%20to%20combine%20external%20data%20sources%20as%20part%20of%20your%20queries%20in%20Sentinel%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1091306%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EQuery%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1092265%22%20slang%3D%22en-US%22%3ERe%3A%20Implementing%20Lookups%20in%20Azure%20Sentinel%20part%20%231%3A%20reference%20files%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1092265%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%2C%20for%20noticing%2C%20updated%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1093954%22%20slang%3D%22en-US%22%3ERe%3A%20Implementing%20Lookups%20in%20Azure%20Sentinel%20part%20%231%3A%20reference%20files%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1093954%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F502083%22%20target%3D%22_blank%22%3E%40nirgafni%3C%2FA%3E%26nbsp%3Bthis%20article%20is%20really%20helpful%20and%20the%20presentation%20is%20crystal%20clear.%20Thanks%20for%20making%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F46875%22%20target%3D%22_blank%22%3E%40Gary%20Bushey%3C%2FA%3E%26nbsp%3Bthanks%20for%20sharing%20this%20link.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1096279%22%20slang%3D%22en-US%22%3ERe%3A%20Implementing%20Lookups%20in%20Azure%20Sentinel%20part%20%231%3A%20reference%20files%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1096279%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F502083%22%20target%3D%22_blank%22%3E%40nirgafni%3C%2FA%3E%26nbsp%3Bi%20have%20tested%20this%20scenario.%20Here%20are%20my%20findings.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E1.%26nbsp%3B%3CSPAN%3Eobfuscation%20is%20not%20working%20even%20i%20used%20h%20or%20H.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E2.%20Storage%20account%20i.e%20blob%20is%20only%20accessible%20if%20i%20use%20allow%20access%20from%20All%20Networks%20option.%20%23%20im%20looking%20if%20we%20can%20only%20allow%20connection%20from%20log%20analytics%20workspace.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E3.%20In%20my%20case%20i%20need%20access%20to%20blob%20for%20more%20time.%20Because%20my%20correlation%20rule%20fetch%20data%20every%20time%20from%20blob%20whenever%20it%20runs.%20%23%20so%20i%20tried%20to%20using%20the%20Blob%20service%20SAS%20URL.%20But%20its%20not%20working.%20i%20compared%20the%20GET%20SAS%20n%26nbsp%3BBlob%20service%20SAS%20URL%20both%20are%20different.%20In%20Blob%20service%20SAS%20URL%20container%20and%20blob%20is%20not%20available.%20I%20think%20that's%20the%20reason%20its%20not%20working.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3ECan%20you%2C%20please%20suggest%20on%20this%3F%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1098092%22%20slang%3D%22en-US%22%3ERe%3A%20Implementing%20Lookups%20in%20Azure%20Sentinel%20part%20%231%3A%20reference%20files%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1098092%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F492724%22%20target%3D%22_blank%22%3E%40Pavan_Gelli1910%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EThe%20obfuscation%20reflects%20in%20our%20logs%2C%20and%20you%20won't%20see%20anything%20on%20your%20side%2C%20see%20details%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fscalar-data-types%2Fstring%23obfuscated-string-literals%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EUnfortunately%2C%20currently%20there%20is%20no%20such%20option%3C%2FLI%3E%0A%3CLI%3E%26nbsp%3BNot%20sure%20I%20follow%20the%20issue%2C%20will%20continue%20in%20private%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EThanks%20for%20reading%20and%20testing%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1098304%22%20slang%3D%22en-US%22%3ERe%3A%20Implementing%20Lookups%20in%20Azure%20Sentinel%20part%20%231%3A%20reference%20files%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1098304%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F502083%22%20target%3D%22_blank%22%3E%40nirgafni%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20your%20response.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20did%20some%20testing%20and%20now%20Im%20able%20to%20use%20shared%20access%20signature%20with%20longer%20duration.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

In this blog post “Active Lists out; make_list() in”, @Ofer_Shezaf referred to one of the uses of Active Lists (ArcSight) or reference sets (QRadar), namely implementing correlation. But Active Lists, reference sets, and the appropriately named Lookups in Splunk have another important use: lookups. In this blog post, I take an initial stub at doing lookups in Azure Sentinel.

Azure Sentinel has a variety of methods to perform lookups, enabling diverse sources for the lookup data and different ways to process it. Overall, I think you will find that Azure Sentinel capabilities offer unparallel lookup prowess. 

 

Why lookups?

Why do you need to look up information in a SIEM query, whether hunting queries or detection rules? The top reasons are:

  • Whitelisting - making sure a query ignores known outliers that do not justify alerting on. For example, excluding a backup process from a query identifying access to large amounts of data.
  • Watch lists - in reverse, making sure that alerts with the listed entities are promoted, whether by assigning a higher severity or by alerting only on those. For example, flagging access to sensitive finance files.
  • Enrichment – extending events or alerts with additional information needed for detection or investigation. Common enrichment sources include user information, asset or resource information, geoinformation, and threat intelligence.

Those are critical capabilities of a SIEM. While each specialized security tool has a partial view of the world, a SIEM can utilize its broader outreach to enrich event and alert data and centrally manage white lists and watch lists.

In this blog post, I examine implementing all those use cases in Azure Sentinel.

 

Lookup files

To reference the data, we first need to locate it. The variety of use cases above implies that the data may exist in many places and accessible by different means. I will discuss referencing lookup data in databases or applications accessible using an API in later blog posts but start with the most common lookup source: files. Being the least common denominator, files are ubiquitous for lookups and can be used in nearly every circumstance:

  • Anyone can manually create or edit them
  • It is easy to fetch data from any other source and keep it as a file for lookups
  • Like Azure Sentinel, they are flexible concerning format, allowing less upfront hassle

 

The KQL externaldata operator

To support a lookup from an external file, KQL offers the "exernaldata" operator. Unlike lookup implementation in other SIEM products, Externaldata is not a lookup operator. Instead, externaldata enable using files as if they were Azure Sentinel tables, which allows preprocessing of the file before actually performing the lookup, for example filtering, parsing. I will demonstrate each in the examples below.

 

Step by step: whitelisting

 

Creating the file

 

  • Create an Azure storage account
  • Create a blob container
  • Upload to it your lookup file

In the following sections I will use the following CSV file, conveniently created in Excel:

UserName,DisplayName,Risk,Location

chris@contoso.com,Chris Green,70,"{ ""City"": ""Redmond"", ""State"": ""Washintgon"", ""Country"": ""US"" }"

ben@contoso.com,Ben Andrews,100,"{ ""City"": ""Oxford"", ""State"": ""Oxfordshare"", ""Country"": ""UK"" }"

nir@contoso.com,Nir Cohen,50,"{ ""City"": ""Tel-Aviv"", ""State"": """", ""Country"": ""IL"" }"

Gabriela@contoso.com,Cynthia Silva,20,"{ ""City"": ""Rio de Janeiro"", ""State"": ""Rio de Janeiro"", ""Country"": ""BR"" }"

melissa@contoso.com,Chandana  Agarwals ,100,"{ ""City"": ""Mumbai"", ""State"": ""Maharashtra"", ""Country"": ""IN"" }"

 

To get a secure access URL, use the “Get Shared Access Signature…” feature, which generates for you a URL similar to this one:

https://***.blob.core.windows.net/externaldata/users.csv?sp=rl&st=2019-12-23T12:49:20Z&se=2019-12-24T12:49:20Z&sv=2019-02-02&sr=b&sig=***...***

 

clipboard_image_0.png

 

Using the reference file in KQL

Since we start with a whitelist example, we need only the first column from the lookup file and can use the following KQL command to reference the file:

externaldata (UserPrincipalName: string) [h"https://..."] with (ignoreFirstRecord=true)

 

Let’s examine the query.

  • First, we defined the type for the first column in the CSV file. String in this case.
  • Next, we provided the URL. Note the “h” added in front of the string: this ensures that we don’t log the string, which includes sensitive information, to our internal audit logs. For more information on query obfuscation read here.
  • Last, we use the attribute ignoreFirstRecord=true, since the first line includes column names and is not relevant.

When you run this query, you get this:

clipboard_image_1.png

Only the first column of the file is used since we defined a type only for it.

The filename extension identifies the file as CSV; however, we could have overridden the type. For example, if we force “txt” as the file type, each file line is considered a single field, and the query returns in the UserName field the entire line. Other supported formats include JSON and AVRO, as well as compressed files.

externaldata (UserPrincipalName: string) [h"https://..."] with (ignoreFirstRecord=true, format="txt")

clipboard_image_2.png

For a full list of supported file types and other attributes, refer to this page.

 

Using the reference table to white list users

To implement while listing, let’s take Azure Sentinel’s rules to detect Failed login attempts to Azure Portal. The modified (and abbreviated) query is below, with the modifications marked in yellow:

let timeRange = 1d;
let whitelist = externaldata (UserPrincipalName: string) [h"https://..."] with (ignoreFirstRecord=true);
SigninLogs
| where TimeGenerated >= ago(timeRange)

// Exclude non-failure types
| where ResultType !in ("0", "50125", "50140")
// Exclude whitelisted users
| where UserPrincipalName !in~ (whitelist)

The first modification defined the whitelist table using the externaldata command. Strictly speaking, you don’t have to define in advance the whitelist table, but it adds a lot to readability. The second modification checked that the UPN is not in the white list table. That’s all.

Wonder why the “~”; in the “not in” operator? It means that the comparison is case insensitive.

 

Watch lists

Let’s use the same alert rule to demonstrate a watch list. Login failures are not particularly interesting; however, there might be a few users for which we want to check each failure. Assume that those are the users for which the risk is higher in our lookup table.

Now we need additional fields in the reference table, so let’s extend the mapping of the fields. By specifying the other columns in the source file, we make them all available for our queries:

externaldata (UserPrincipalName: string, DisplayName: string, Risk: int, Location: dynamic) [h"https://..."] with (ignoreFirstRecord=true)

 

clipboard_image_3.png

 

Now, by slightly modifying the alert rule query we implement our watch list:

let timeRange = 1d;
let watchlist = externaldata (UserPrincipalName: string , DisplayName: string, Risk: int, Location: string) [h"https://..."] with (ignoreFirstRecord=true)
| where Risk > 90;

SigninLogs
| where TimeGenerated >= ago(timeRange)

// Exclude non-failure types
| where ResultType !in ("0", "50125", "50140")
// Include only watched users
| where UserPrincipalName in~ (watchlist)

 

The changes are:

  • In green, As discussed, we now map all the fields in the reference file. Though we still don’t need the location field, it will be handy in the next exercise.
  • In pink,  the logic changes: first filtering the lookup table only for users with a risk higher than 90, and then changing the selection criteria in the query itself from “!in” to “in”, as now we want to match only on users in the list rather than exclude them.
  • In cyan, cosmetic changes: changing the lookup table name from whitelist to watchlist and updating the comments.

You may notice that the watchlist table has 4 columns and ask yourself how is it used in an “in” clause. When a table is used with the “in” clause, the first column is used, which is what we need here. If we had liked to check against a different column, we could have appended a “project” operator after the “where Risk > 90” phrase to select the field we want to match against:

let watchlist = externaldata (UserPrincipalName: string, DisplayName: string, Risk: int, Location: string) [h"https://..."] with (ignoreFirstRecord=true)
| where Risk > 90 | project UserPrincipalName

 

Enrichment

Let’s look at an additional piece of information available in the lookup file: the location of the user. Another option for making the failed login rule better is to alert only on failed login attempts by users originating not from their home country. To do that, we need to enrich the failed login event with information about the user’s home country.

This requires two significant additions to the toolbox we used for white lists and watch lists:

  • The country information is a part of a field value. We need to extract it to use it.
  • To look up a user and enrich the event with the country information, the “in” operator would not do. We need a more versatile method: the “join” operator.

 

Extracting fields

Extracting the country code from the reference table is an excellent example of the versatility that externaldata provides. By making the reference file a native table, it enables further processing it.

For example, we can extract the country code from the location string using the extract function, which applies a regex to the Location field and assigns the identified part to the user_country calculated field:

externaldata (UserPrincipalName: string, DisplayName: string, Risk: int, Location: string) [h"https://..."] with (ignoreFirstRecord=true)
| extend user_country = extract ('Country": "(.*)"', 1, Location)

 

However, since the Location field is in JSON format, an alternative would be to use it as such. By changing the type of the Location field to “dynamic”, we can get user_country much more directly:

externaldata (UserPrincipalName: string, DisplayName: string, Risk: int, Location: dynamic) [h"https://..."] with (ignoreFirstRecord=true)
| extend user_country = Location.Country

 

 

Detection using the country value

Once the country code is available, regardless of the method, we can apply it to the events for detection purposes using the join operator:

let timeRange = 1d;
let userinfo = externaldata

let failed_singins = SigninLogs

failed_singins | join kind= inner (userinfo) on UserPrincipalName
| where Location != user_country

 

The join statement works as follows:

  • The query assigns the label “userinfo” to the parsed reference table from the previous section.
  • It then labels the original rule query as “failed_signins”.
  • The “join” operator than enriches the failed_singins by matching the relevant userinfo records and appending all its fields to the failed signin event.
  • Lastly, the “Location” of the original event is compared to the “user_country” which is the home country of the user and was appended in the previous step and alert only if they are different.

 

Hunting and investigation

To make reference tables easier to use interactively by analysts, you can sage the externaldata query as a function. This way, it can be used in any of the use cases above without needing to include the URL or the parsing clauses directly. So, for example, if the last externaldata query above is saved as the function "userinfo", the "join" statement could have used userinfo without explicitly defining it in the query itself.

 

Wrapping up

This blog post shows how to use the KQL externaldata operator to utilize a reference file for three use cases: whitelisting, watch lists, and enrichment. In an upcoming blog post, I will show you how to implement these use cases for reference tables, which are not available as files.

6 Comments
Frequent Contributor

Looks like a word or two may have been left out this this sentence(s)

"Next, we provided the URL. in front of the string: this ensures that we don’t log the string"

Microsoft

Thanks, for noticing, updated

Occasional Contributor

@nirgafni this article is really helpful and the presentation is crystal clear. Thanks for making it.

 

@Gary Bushey thanks for sharing this link.

Occasional Contributor

@nirgafni i have tested this scenario. Here are my findings.

 

1. obfuscation is not working even i used h or H.

2. Storage account i.e blob is only accessible if i use allow access from All Networks option. # im looking if we can only allow connection from log analytics workspace.

3. In my case i need access to blob for more time. Because my correlation rule fetch data every time from blob whenever it runs. # so i tried to using the Blob service SAS URL. But its not working. i compared the GET SAS n Blob service SAS URL both are different. In Blob service SAS URL container and blob is not available. I think that's the reason its not working.

 

Can you, please suggest on this?

Microsoft

Hi @Pavan_Gelli1910 

  1. The obfuscation reflects in our logs, and you won't see anything on your side, see details here
  2. Unfortunately, currently there is no such option
  3.  Not sure I follow the issue, will continue in private

Thanks for reading and testing

Occasional Contributor

Hi @nirgafni 

 

Thanks for your response.

 

I did some testing and now Im able to use shared access signature with longer duration.