Home
%3CLINGO-SUB%20id%3D%22lingo-sub-475729%22%20slang%3D%22en-US%22%3EWhy%20Use%20Jupyter%20for%20Security%20Investigations%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-475729%22%20slang%3D%22en-US%22%3E%3CP%3E%3CFONT%20size%3D%222%22%3EFollow%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2Fianhellen%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%40ianhellen%3C%2FA%3E%20on%20twitter.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22what-is-jupyter%22%20id%3D%22toc-hId-1708459876%22%20id%3D%22toc-hId-1708459876%22%3EWhat%20is%20Jupyter%3F%3C%2FH2%3E%0A%3CP%3EJupyter%20is%20an%20interactive%20development%20and%20data%20manipulation%20environment%20hosted%20in%20a%20browser.%20It%20takes%20code%20that%20you%20type%20into%20a%20cell%2C%20executes%20it%20and%20returns%20the%20output%20to%20you.%20Here%20is%20an%20example%3A%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20902px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F109617i281EB82DCF02EAE5%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22JupyterAndSecurity-JupyterCell.png%22%20title%3D%22JupyterAndSecurity-JupyterCell.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20more%20introductory%20information%20and%20sample%20notebooks%20go%20to%20%3CA%20href%3D%22https%3A%2F%2Fjupyter.org%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ejupyter.org%3C%2FA%3E.%20and%20the%20%3CA%20href%3D%22https%3A%2F%2Fjupyter.readthedocs.io%2Fen%2Flatest%2Ftryjupyter.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ejupyter%20introductory%20documentation%3C%2FA%3E%3C%2FP%3E%0A%3CH2%20id%3D%22why-jupyter%22%20id%3D%22toc-hId--843697085%22%20id%3D%22toc-hId--843697085%22%3EWhy%20Jupyter%3F%3C%2FH2%3E%0A%3CP%3E%22Why%20would%20I%20use%20Jupyter%20notebooks%20to%20work%20with%20Azure%20Sentinel%20data%20rather%20than%20the%20built-in%20query%20and%20investigation%20tools%3F%22%20might%20be%20your%20first%20question.%20And%20the%20first%20answer%20is%20that%2C%20usually%2C%20you%20wouldn't.%20In%20most%20cases%2C%20the%20scenario%20and%20data%20that%20you%20are%20investigating%20can%20be%20handled%20perfectly%20well%20in%20with%20the%20coming%20graphical%20investigation%20tool%2C%20with%20Log%20Analytics%20queries%20and%20cool%20case%20features%20like%20Bookmarks.%3C%2FP%3E%0A%3CP%3EThe%20second%20point%20to%20make%20is%20that%20it%20is%20not%20an%20either%2For%20question%20.You%20should%20think%20about%20Jupyter%20notebooks%20as%20something%20to%20use%20to%20supplement%20the%20built-in%20and%20growing%20capabilities%20of%20the%20Azure%20Sentinel%20portal.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOne%20reason%20that%20you%20might%20want%20to%20reach%20for%20Jupyter%20is%20when%20the%20complexity%20of%20what%20you%20are%20looking%20for%20becomes%20too%20high.%20%22How%20complex%20is%20%3CEM%3Etoo%20complex%3C%2FEM%3E%3F%22%20is%20a%20difficult%20question%20to%20answer%20but%20some%20guidelines%20might%20be%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3Ewhen%20the%20number%20of%20queries%20in%20your%20investigation%20chain%20goes%20beyond%20around%207%20(the%20number%20of%20things%20that%20the%20average%20person%20can%20juggle%20in%20short-term%20memory).%3C%2FLI%3E%0A%3CLI%3Ewhen%20you%20start%20to%20need%20extra-strength%20reading%20glasses%20to%20see%20all%20the%20detail%20of%20the%20investigation%20graph.%3C%2FLI%3E%0A%3CLI%3Ewhen%20you%20discover%20that%20your%20browser%20has%20just%20crashed%20and%20you%20hadn't%20saved%20any%20of%20the%20queries%20or%20results%20that%20you%20were%20working%20on.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3ESome%20of%20the%20other%20benefits%20of%20working%20in%20Jupyter%20are%20outlined%20in%20the%20following%20sections.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22data-persistence-repeatability-and-backtracking%22%20id%3D%22toc-hId-702599745%22%20id%3D%22toc-hId-702599745%22%3EData%20Persistence%2C%20Repeatability%20and%20Backtracking%3C%2FH3%3E%0A%3CP%3EOne%20of%20the%20painful%20things%20when%20working%20on%20a%20more%20complex%20security%20investigation%20is%20keeping%20track%20of%20what%20you%20have%20done.%20You%20might%20easily%20find%20yourself%20with%20tens%20of%20queries%20and%20results%20sets%20-%20many%20of%20which%20turned%20out%20to%20be%20dead%20ends.%20Which%20ones%20do%20you%20keep%3F%20How%20easy%20is%20it%20to%20backtrack%20and%20re-run%20the%20queries%20with%20different%20values%20or%20date%20ranges%3F%20How%20do%20you%20accumulate%20the%20useful%20results%20in%20a%20single%20report%3F%20What%20if%20you%20want%20to%20re-run%20the%20same%20pattern%20on%20a%20future%20investigation%3F%3C%2FP%3E%0A%3CP%3EWith%20most%20data-querying%20environments%20the%20answer%20is%20a%20lot%20of%20manual%20work%20and%20heavy%20reliance%20on%20good%20short-term%20memory.%20Jupyter%2C%20on%20the%20other%20hand%2C%20gives%20you%20a%20linear%20progression%20through%20the%20investigation%20-%20saving%20queries%20and%20data%20as%20you%20go.%20With%20the%20use%20of%20variables%20through%20the%20progression%20of%20the%20queries%20(e.g.%20for%20time%20ranges%2C%20account%20names%2C%20IP%20addresses%2C%20etc.)%20it%20also%20makes%20it%20much%20easier%20to%20backtrack%20and%20re-run%20and%20to%20reuse%20the%20entire%20workflow%20in%20future%20investigations.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22scripting-and-programming-environment%22%20id%3D%22toc-hId--1849557216%22%20id%3D%22toc-hId--1849557216%22%3EScripting%20and%20Programming%20environment%3C%2FH3%3E%0A%3CP%3EIn%20Jupyter%20you%20are%20not%20limited%20to%20querying%20and%20viewing%20results%20but%20have%20the%20full%20power%20of%20a%20programming%20language.%20Although%20you%20can%20do%20a%20lot%20in%20a%20flexible%20declarative%20language%20like%20Kql%20(or%20others%20like%20SQL)%2C%20being%20able%20to%20split%20your%20logic%20into%20procedural%20chunks%20is%20often%20helpful%20and%20sometimes%20essential.%20A%20%3CEM%3Edeclarative%3C%2FEM%3E%20language%20means%20that%20you%20need%20to%20encode%20your%20logic%20in%20a%20single%20(possibly%20complex)%20statement%2C%20while%20%3CEM%3Eprocedural%3C%2FEM%3E%20languages%20allow%20you%20to%20execute%20logic%20in%20a%20series%20of%20steps.%3C%2FP%3E%0A%3CP%3EBeing%20able%20to%20use%20procedural%20code%20lets%20you%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ESee%20and%20debug%20intermediate%20results.%3C%2FLI%3E%0A%3CLI%3EAdd%20functionality%20(such%20as%20decoding%20fields%2C%20parsing%20data)%20that%20may%20not%20be%20available%20in%20the%20query%20language.%3C%2FLI%3E%0A%3CLI%3ERe-use%20partial%20results%20in%20later%20processing%20steps.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22joining-to-external-data%22%20id%3D%22toc-hId--106746881%22%20id%3D%22toc-hId--106746881%22%3EJoining%20to%20External%20Data%3C%2FH3%3E%0A%3CP%3EMost%20of%20your%20telemetry%2Fevent%20data%20will%20be%20in%20Azure%20Sentinel%20workspace%20tables%20but%20there%20will%20often%20be%20exceptions%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3Edata%20in%20an%20external%20service%20that%20you%20do%20not%20own%20-%20e.g.%20IP%20whois%20and%20geolocation%20data%2C%20threat%20intelligence%20source%2C%3C%2FLI%3E%0A%3CLI%3Esensitive%20data%20that%20may%20only%20be%20stored%20within%20your%20organization%20-%20HR%20Database%2C%20lists%20of%20execs%2C%20admins%20or%20high-value%20assets%2C%3C%2FLI%3E%0A%3CLI%3Eor%20simply%20data%20that%20you%20have%20not%20yet%20migrated%20to%20the%20cloud.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EAny%20data%20that%20is%20accessible%20over%20your%20network%20or%20from%20a%20file%20can%20be%20linked%20with%20Azure%20Sentinel%20data%20via%20Python%20and%20Jupyter.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22access-to-sophisticated-data-processing-machine-learing-and-visualization%22%20id%3D%22toc-hId-1636063454%22%20id%3D%22toc-hId-1636063454%22%3EAccess%20to%20Sophisticated%20Data%20Processing%2C%20Machine%20Learing%20and%20Visualization%3C%2FH3%3E%0A%3CP%3EAzure%20Sentinel%20and%20the%20Kusto%2FLog%20Analytics%20data%20store%20underlying%20it%20have%20a%20lot%20of%20options%20for%20visualization%20and%20advanced%20data%20processing%20(even%20clustering%2C%20windowed%20statistical%20and%20machine%20learning%20functions)%20and%20more%20capabilities%20are%20being%20added%20all%20the%20time.%20However%2C%20there%20may%20be%20times%20when%20you%20need%20something%20different%3A%20specialized%20visualizations%2C%20machine%20learning%20libraries%20or%20even%20just%20data%20processing%20and%20transformation%20facilities%20not%20available%20in%20the%20Azure%20Sentinel%20platform.%20You%20can%20see%20examples%20of%20these%20in%20some%20of%20the%20Azure%20Sentinel%20sample%20notebooks%20(see%20References%20at%20the%20end%20of%20the%20document).%3C%2FP%3E%0A%3CP%3ESome%20well-known%20examples%20of%20these%20in%20the%20Python%20language%20are%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CEM%3Epandas%3C%2FEM%3E%20for%20data%20processing%2C%20cleanup%20and%20engineering%3C%2FLI%3E%0A%3CLI%3E%3CEM%3Ematplotlib%3C%2FEM%3E%2C%20%3CEM%3Eholoviews%3C%2FEM%3E%2C%20%3CEM%3Eplotly%3C%2FEM%3E%20and%20many%20others%20for%20visualization%3C%2FLI%3E%0A%3CLI%3E%3CEM%3Enumpy%3C%2FEM%3E%20and%20%3CEM%3Escipy%3C%2FEM%3E%20for%20advanced%20numerical%20and%20scientific%20processing%3C%2FLI%3E%0A%3CLI%3E%3CEM%3Escikit-learn%3C%2FEM%3E%20for%20machine%20learning%3C%2FLI%3E%0A%3CLI%3E%3CEM%3Etensorflow%3C%2FEM%3E%2C%20%3CEM%3Epytorch%3C%2FEM%3E%2C%20%3CEM%3Ekeras%3C%2FEM%3E%20for%20deep%20learning%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22why-python%22%20id%3D%22toc-hId--719580002%22%20id%3D%22toc-hId--719580002%22%3EWhy%20Python%3F%3C%2FH2%3E%0A%3CP%3EJupyter%20can%20be%20used%20with%20many%20different%20languages%20-%20what%20makes%20Python%20a%20good%20choice%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22popularity%22%20id%3D%22toc-hId-826716828%22%20id%3D%22toc-hId-826716828%22%3EPopularity%3C%2FH3%3E%0A%3CP%3EIt%20is%20very%20likely%20that%20you%20already%20have%20Python%20coders%20in%20your%20organization.%20It%20is%20now%20the%20most%20widely%20taught%20language%20in%20Computer%20Science%20courses%20and%20used%20widely%20in%20many%20scientific%20fields.%20It%20is%20also%20frequently%20used%20by%20IT%20Pros%20--%20where%20it%20has%20largely%20replaced%20perl%20as%20the%20go-to%20language%20for%20scripting%20and%20systems%20management%20--%20and%20by%20web%20developers%20(many%20popular%20services%20such%20as%20DropBox%20and%20Instagram%20are%20almost%20entirely%20written%20in%20Python).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22ecosystem%22%20id%3D%22toc-hId--1725440133%22%20id%3D%22toc-hId--1725440133%22%3EEcosystem%3C%2FH3%3E%0A%3CP%3EDriven%20by%20this%20popularity%2C%20there%20is%20a%20vast%20repository%20of%20python%20libraries%20available%20on%20%3CA%20href%3D%22https%3A%2F%2Fpypi.org%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EPyPi%3C%2FA%3E%20and%20nearly%201%20million%20python%20repos%20on%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fsearch%3Fq%3Dpython%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EGithub%3C%2FA%3E.%20For%20many%20of%20the%20tools%20that%20you%20need%20as%20a%20security%20investigator%20-%20data%20manipulation%2C%20data%20analysis%2C%20visualization%2C%20machine%20learning%20and%20statistical%20analysis%20-%20no%20other%20language%20ecosystem%20has%20comparable%20tools.%3C%2FP%3E%0A%3CP%3EOne%20remarkable%20point%20here%20is%20that%20pretty%20much%20every%20major%20python%20package%20and%20the%20core%20language%20itself%20are%20open%20source%20and%20written%20and%20maintained%20by%20volunteers.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22alternatives-to-python%22%20id%3D%22toc-hId-17370202%22%20id%3D%22toc-hId-17370202%22%3EAlternatives%20to%20Python%3C%2FH3%3E%0A%3CP%3EYou%20can%20use%20other%20language%20kernels%20with%20Juypter%2C%20and%20you%20can%20mix%20and%20match%20languages%20(to%20a%20degree)%20within%20the%20same%20notebook%20using%20'magics'%20that%20allow%20execution%20of%20individual%20cells%20using%20another%20language.%20For%20example%2C%20you%20could%20retrieve%20data%20using%20a%20PowerShell%20script%20cell%2C%20process%20the%20data%20in%20python%20and%20use%20JavaScript%20to%20render%20a%20visualization.%20In%20practice%2C%20this%20can%20be%20a%20little%20trickier%20than%20it%20sounds%20but%20certainly%20possible%20with%20a%20bit%20of%20hand-wiring.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22references%22%20id%3D%22toc-hId--1452996689%22%20id%3D%22toc-hId--1452996689%22%3EReferences%3C%2FH2%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fjupyter.org%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ejupyter.org%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fpython.org%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Epython%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fpypi.org%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EPyPi%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fsearch%3Fq%3Dpython%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EGithub%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fkusto.azurewebsites.net%2Fdocs%2Fquery%2Findex.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EKusto%20Query%20Language%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fpandas.pydata.org%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Epandas%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fmatplotlib.org%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ematplotlib%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fholoviews.org%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eholoviews%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fplot.ly%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eplotly%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fwww.numpy.org%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Enumpy%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fwww.scipy.org%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Escipy%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fscikit-learn.org%2Fstable%2Findex.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Escikit-learn%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fwww.tensorflow.org%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Etensorflow%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fpytorch.org%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Epytorch%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fkeras.io%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ekeras%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-475729%22%20slang%3D%22en-US%22%3E%3CP%3E%22Why%20would%20I%20use%20Jupyter%20notebooks%20to%20work%20with%20Azure%20Sentinel%20data%20rather%20than%20the%20built-in%20query%20and%20investigation%20tools%3F%22.%20This%20article%20summarizes%20some%20of%20the%20reasons%20you%20might%20want%20to%20add%20Jupyter%20to%20your%20palatte%20of%20investigation%20and%20hunting%20tools%20available%20in%20Azure%20Sentinel.%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F109634iBB057890F9B4BF18%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22WhyJupyterTeaser.png%22%20title%3D%22WhyJupyterTeaser.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-475729%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EInvestigation%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ENotebooks%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Follow @ianhellen on twitter.

 

What is Jupyter?

Jupyter is an interactive development and data manipulation environment hosted in a browser. It takes code that you type into a cell, executes it and returns the output to you. Here is an example:JupyterAndSecurity-JupyterCell.png

 

For more introductory information and sample notebooks go to jupyter.org. and the jupyter introductory documentation

Why Jupyter?

"Why would I use Jupyter notebooks to work with Azure Sentinel data rather than the built-in query and investigation tools?" might be your first question. And the first answer is that, usually, you wouldn't. In most cases, the scenario and data that you are investigating can be handled perfectly well in with the coming graphical investigation tool, with Log Analytics queries and cool case features like Bookmarks.

The second point to make is that it is not an either/or question .You should think about Jupyter notebooks as something to use to supplement the built-in and growing capabilities of the Azure Sentinel portal. 

 

One reason that you might want to reach for Jupyter is when the complexity of what you are looking for becomes too high. "How complex is too complex?" is a difficult question to answer but some guidelines might be:

  • when the number of queries in your investigation chain goes beyond around 7 (the number of things that the average person can juggle in short-term memory).
  • when you start to need extra-strength reading glasses to see all the detail of the investigation graph.
  • when you discover that your browser has just crashed and you hadn't saved any of the queries or results that you were working on.

Some of the other benefits of working in Jupyter are outlined in the following sections.

 

Data Persistence, Repeatability and Backtracking

One of the painful things when working on a more complex security investigation is keeping track of what you have done. You might easily find yourself with tens of queries and results sets - many of which turned out to be dead ends. Which ones do you keep? How easy is it to backtrack and re-run the queries with different values or date ranges? How do you accumulate the useful results in a single report? What if you want to re-run the same pattern on a future investigation?

With most data-querying environments the answer is a lot of manual work and heavy reliance on good short-term memory. Jupyter, on the other hand, gives you a linear progression through the investigation - saving queries and data as you go. With the use of variables through the progression of the queries (e.g. for time ranges, account names, IP addresses, etc.) it also makes it much easier to backtrack and re-run and to reuse the entire workflow in future investigations.

 

Scripting and Programming environment

In Jupyter you are not limited to querying and viewing results but have the full power of a programming language. Although you can do a lot in a flexible declarative language like Kql (or others like SQL), being able to split your logic into procedural chunks is often helpful and sometimes essential. A declarative language means that you need to encode your logic in a single (possibly complex) statement, while procedural languages allow you to execute logic in a series of steps.

Being able to use procedural code lets you:

  • See and debug intermediate results.
  • Add functionality (such as decoding fields, parsing data) that may not be available in the query language.
  • Re-use partial results in later processing steps.

 

Joining to External Data

Most of your telemetry/event data will be in Azure Sentinel workspace tables but there will often be exceptions:

  • data in an external service that you do not own - e.g. IP whois and geolocation data, threat intelligence source,
  • sensitive data that may only be stored within your organization - HR Database, lists of execs, admins or high-value assets,
  • or simply data that you have not yet migrated to the cloud.

Any data that is accessible over your network or from a file can be linked with Azure Sentinel data via Python and Jupyter.

 

Access to Sophisticated Data Processing, Machine Learing and Visualization

Azure Sentinel and the Kusto/Log Analytics data store underlying it have a lot of options for visualization and advanced data processing (even clustering, windowed statistical and machine learning functions) and more capabilities are being added all the time. However, there may be times when you need something different: specialized visualizations, machine learning libraries or even just data processing and transformation facilities not available in the Azure Sentinel platform. You can see examples of these in some of the Azure Sentinel sample notebooks (see References at the end of the document).

Some well-known examples of these in the Python language are:

  • pandas for data processing, cleanup and engineering
  • matplotlib, holoviews, plotly and many others for visualization
  • numpy and scipy for advanced numerical and scientific processing
  • scikit-learn for machine learning
  • tensorflow, pytorch, keras for deep learning

 

Why Python?

Jupyter can be used with many different languages - what makes Python a good choice?

 

Popularity

It is very likely that you already have Python coders in your organization. It is now the most widely taught language in Computer Science courses and used widely in many scientific fields. It is also frequently used by IT Pros -- where it has largely replaced perl as the go-to language for scripting and systems management -- and by web developers (many popular services such as DropBox and Instagram are almost entirely written in Python).

 

Ecosystem

Driven by this popularity, there is a vast repository of python libraries available on PyPi and nearly 1 million python repos on Github. For many of the tools that you need as a security investigator - data manipulation, data analysis, visualization, machine learning and statistical analysis - no other language ecosystem has comparable tools.

One remarkable point here is that pretty much every major python package and the core language itself are open source and written and maintained by volunteers.

 

Alternatives to Python

You can use other language kernels with Juypter, and you can mix and match languages (to a degree) within the same notebook using 'magics' that allow execution of individual cells using another language. For example, you could retrieve data using a PowerShell script cell, process the data in python and use JavaScript to render a visualization. In practice, this can be a little trickier than it sounds but certainly possible with a bit of hand-wiring.

 

References