Home
%3CLINGO-SUB%20id%3D%22lingo-sub-555052%22%20slang%3D%22en-US%22%3ELooking%20for%20unknown%20anomalies%20-%20what%20is%20normal%3F%20Time%20Series%20analysis%20%26amp%3B%20its%20applications%20in%20Security%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-555052%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20previously%20blogged%20about%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-gb%2Fblog%2Fml-powered-detections-with-kusto-query-language-in-azure-sentinel%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EMachine%20learning%20powered%20detections%20with%20Kusto%20query%20language%20in%20Azure%20Sentinel%20%3C%2FA%3Eand%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Sentinel%2FTime-series-analysis-applied-in-a-security-hunting-context%2Fba-p%2F472433%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3ETime%20series%20analysis%20applied%20in%20a%20security%20hunting%20context%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3EThis%20article%20provides%20a%20practical%20outline%20for%20using%20Time%20Series%20analysis%20to%20surface%20anomalies%20on%20security%20event%20log%20data%20sources%2C%20visualizing%20and%20alerting%20on%20anomalies%20for%20further%20investigation%20in%20Azure%20Sentinel.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20will%20describe%20the%20various%20functions%20which%20are%20used%20in%20compiling%20the%20query%20and%20how%20to%20use%20those%20KQL%20queries%20to%20either%20visualize%20the%20output%20or%20transform%20it%20into%20tabular%20data%20outputs%20to%20configure%20alerts%20on%20specific%20anomalies.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%225%22%3E%3CSTRONG%3EWhat%20is%20Time%20Series%20data%3F%20%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EPer%20Wikipedia%2C%20Time%20Series%20is%20a%20series%20of%20data%20points%20indexed%20(or%20listed%20or%20graphed)%20in%20time%20order.%20The%20data%20points%20are%20often%20discrete%20numeric%20points%20such%20as%20frequency%20of%20counts%20or%20occurrences%20against%20a%20column%20of%20the%20dataset.%3C%2FP%3E%0A%3CP%3ETime%20series%20analysis%20and%20forecasting%20is%20effectively%20used%20in%20multiple%20sectors%2C%20%2C%20IoT%2C%20service%20monitoring%20etc%20to%20identify%20meaningful%20statistics%20from%20historical%20data%20as%20well%20as%20predicting%20future%20outcomes.%3C%2FP%3E%0A%3CP%3EWe%20will%20keep%20the%20overview%20short%20and%20simple%20for%20the%20scope%20of%20this%20article%20and%20focus%20on%20applied%20techniques%20on%20security%20event%20log%20data%20sources.%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%225%22%3E%3CSTRONG%3EWhen%20to%20use%20Time%20Series%20analysis%3A%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EBy%20analyzing%20time%20series%20data%20over%20an%20extended%20period%2C%20we%20can%20identify%20time-based%20patterns%20(e.g.%20seasonality%2C%20trend%20etc.)%20in%20the%20data%20and%20extract%20meaningful%20statistics%20which%20can%20help%20in%20flagging%20outliers.%20%26nbsp%3BA%20particular%20example%20in%20a%20security%20context%20is%20user%20logon%20patterns%20over%20a%20period%20of%20time%20exhibiting%20different%20behavior%20after%20hours%20and%20on%20weekends%3A%20computing%20deviations%20from%20these%20changing%20patterns%20is%20rather%20difficult%20in%20traditional%20atomic%20detections%20with%20static%20thresholds.%20KQL%20built-in%20functions%20can%20automatically%20identify%20such%20seasonality%20and%20trend%20from%20the%20input%20data%20and%20take%20it%20into%20consideration%20when%20flagging%20anomalies.%3C%2FP%3E%0A%3CP%3ETo%20prepare%20data%20for%20time%20series%20analysis%2C%20select%20the%20data%20sources%20and%20the%20data%20points%20associated%20with%20it.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThese%20data%20points%20can%20then%20be%20transformed%20series%20of%20%26nbsp%3Baggregated%20values%20against%20continuous%20time%20intervals%20from%20the%20original%20data.%3C%2FP%3E%0A%3CP%3EIdeally%2C%20the%20dataset%20in%20scope%20should%20have%20consistent%20values%20populated%20for%20most%20of%20the%20time%20windows.%20If%20there%20are%20too%20many%20missing%20data%20points%2C%20the%20outlier%20results%20may%20be%20affected.%3C%2FP%3E%0A%3CP%3EHowever%2C%20%3CSTRONG%3E%3CEM%3Emake-series%3C%2FEM%3E%3C%2FSTRONG%3E%20operator%20used%20to%20prepare%20the%20time%20series%20data%20inserts%20values%20for%20missing%20time%20window%20intervals.%20By%20default%20it%20sets%20value%20to%200%20for%20missing%20values%2C%20you%20%26nbsp%3Balso%20have%20control%20to%20change%20default%20values%20to%20avg()%20or%20any%20other%20constants%20by%20setting%20it%20to%20default%20argument%20of%20make-series.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETypical%20time%20series%20analysis%20workflow%20involves%20below%20steps%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ESelect%20the%20data%20source%20table%20which%20contains%20raw%20events%20defined%20for%20the%20scope%20of%20the%20analysis.%3C%2FLI%3E%0A%3CLI%3EDefine%20the%20field%20(such%20as%20%3CEM%3Esourceip%2C%20accountname%2C%20hostname%3C%2FEM%3E%20etc)%20from%20the%20schema%20against%20which%20numeric%20data%20points%20(such%20as%20count%20of%20outbound%20network%20connections%2C%20count%20of%20logons%20etc.)%20will%20be%20calculated.%3C%2FLI%3E%0A%3CLI%3EUse%20built-in%20KQL%20operators%20to%20convert%20the%20input%20data%20into%20time%20series%20by%20using%20%3CSTRONG%3E%3CEM%3Emake-series%3C%2FEM%3E%3C%2FSTRONG%3E%20operator%20which%20transforms%20base%20logs%20into%20series%20of%20aggregated%20values%20of%20specified%20data%20points%20against%20time%20windows%20(e.g.%20count%20of%20logon%20per%20hour%2C%20outbound%20data%20transfer%20per%20day%20etc).%3C%2FLI%3E%0A%3CLI%3EUse%20time%20series%20functions%20(e.g.%20%3CSTRONG%3E%3CEM%3Eseries_decompose%20%3C%2FEM%3E%3CEM%3Eand%20%3C%2FEM%3E%3CEM%3Eseries_decompose_anomalies%3C%2FEM%3E%3C%2FSTRONG%3E)%20to%20apply%20decomposition%20transformation%20on%20an%20input%20data%20series%20and%20extract%20anomalous%20points.%3C%2FLI%3E%0A%3CLI%3EYou%20can%20plot%20the%20output%20in%20a%20time%20chart%20by%20splitting%20seasonal%2C%20trend%2C%20residual%20components%20in%20the%20data%20or%20you%20can%20expand%20the%20output%20to%20filter%20for%20anomalies%20and%20flag%20it%20as%20an%20alert.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CFONT%20size%3D%225%22%3E%3CSTRONG%3EData%20transformation%20and%20Time%20series%20analysis%20with%20KQL%20built-in%20functions%20and%20operators%3A%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EThe%20KQL%20operators%20and%20functions%20below%20are%20generally%20used%20to%20compile%20time%20series-based%20detections%20in%20Kusto.%20Check%20the%20reference%20section%20for%20more%20operators%20to%20customize%20the%20analysis%20or%20read%20more%20about%20its%20syntax%20and%20usage.%3C%2FP%3E%0A%3CP%3EApart%20from%20using%20KQL%20built-in%20functions%2C%20one%20can%20also%20load%20input%20data%20in%20data%20frame%20and%20then%20use%20other%20time%20series%20methods%2Flibraries%20in%20Python%20and%20R%20language%20via%20Jupyter%20notebook.%20However%20built-in%20functions%20natively%20available%20in%20KQL%20are%20optimized%20for%20performance%20and%20works%20efficient%20on%20large%20scale%20of%20data.%3C%2FP%3E%0A%3CP%3EThe%20most%20convenient%20way%20of%20using%20these%20functions%20is%20applying%20it%20to%20the%20results%20of%20%3CEM%3Emake-series%3C%2FEM%3E%20operator%20which%20will%20transform%20your%20input%20data%20into%20multi-value%20series%20ready%20to%20either%20plot%20on%20time%20chart%20or%20alert%20on%20outliers.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3Emake-series%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThis%20operator%20creates%20a%20series%20of%20specified%20aggregated%20values%20along%20specified%20axis.%20It%20is%20used%20to%20aggregate%20data%20points%20in%20a%20series%20by%20specified%20column%20available%20in%20data%20source%20schema.%20This%20will%20transform%20multi%20row%20table%20output%20into%20a%20single%20row%20as%20multi-value%20array.%20The%20operator%20also%20fills%20in%200%20automatically%20for%20missing%20values%20or%20you%20can%20override%20with%20default%20option%20with%20average.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CEM%3Eseries_decompose()%3C%2FEM%3E%3C%2FSTRONG%3E%20%3A%3C%2FP%3E%0A%3CP%3EThis%20function%20applies%20a%20decomposition%20transformation%20on%20a%20series.%20It%20takes%20time%20series%20data%20prepared%20by%20make-series%20and%20decompose%20it%20to%20seasonal%2C%20trend%20and%20residual%20components.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CEM%3Eseries_decompose_anomolies()%3C%2FEM%3E%3C%2FSTRONG%3E%20%3A%3C%2FP%3E%0A%3CP%3EThis%20function%20is%20for%20anomaly%20detection%20which%20is%20based%20on%20%3CEM%3Eseries%20decomposition%3C%2FEM%3E%20(refer%20to%20%3CEM%3Eseries_decompose()%3C%2FEM%3E)%3C%2FP%3E%0A%3CP%3EIt%20takes%20an%20expression%20containing%20a%20series%20(dynamic%20numerical%20array)%20as%20input%20and%20extract%20anomalous%20points%20with%20scores.%20anomaly%20detections%20used%20with%20this%20function%20are%20based%20on%20Tukey%E2%80%99s%20test.%20The%20function%20has%20several%20parameters%20including%20AD_method%2C%20threshold%2C%20seasonality%20and%20trend%20which%20are%20explained%20below.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CFONT%20size%3D%222%22%3E%3CU%3E%3CSTRONG%3E%3CEM%3EAD_method%3C%2FEM%3E%3C%2FSTRONG%3E%20%3C%2FU%3E%3C%2FFONT%3Eparameter%20in%20above%20syntax%20specifically%20controls%20the%20anomaly%20detection%20method%20on%20the%20residual%20time%20series.%20Available%20options%20are%20%3CEM%3Ectukey%3C%2FEM%3E%20(default%20option-%2010th-90th%20percentile%20range)%20and%20%3CEM%3Etukey%3C%2FEM%3E%20(standard%20-%2025th-75th%20percentile%20range)%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%222%22%3E%3CU%3E%3CSTRONG%3Ethreshold%3C%2FSTRONG%3E%20%3C%2FU%3E%3C%2FFONT%3Evalue%20greater%20than%201.5%20or%20less%20than%20-1.5%20indicates%20a%20spike%20or%20dip%20anomaly%20respectively%20in%20the%20same%20element%20of%20the%20input.%26nbsp%3B%20In%20case%20default%20threshold%20(1.5)%20is%20still%20producing%20lot%20of%20results%20with%20false%20positives%20then%2C%20you%20can%20set%20to%203%20which%20corresponds%20to%20a%20far%20outlier%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%222%22%3E%3CU%3E%3CSTRONG%3ESeasonality%3C%2FSTRONG%3E%20%3C%2FU%3E%3C%2FFONT%3Eparameter%20controls%20seasonal%20analysis.%20It%20will%20have%20one%20of%20below%20value.%3CUL%3E%0A%3CLI%3E-1%20%3A%20autodetect%20seasonality%3C%2FLI%3E%0A%3CLI%3EPeriod%3A%20positive%20integer%2C%20specify%20number%20of%20bins%20e.g%20if%20input%20data%20is%20hourly%2C%20weekly%20period%20will%20be%20168%20bins.%3C%2FLI%3E%0A%3CLI%3E0%20%3A%20no%20seasonality%20(skip%20extracting%20component)%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%222%22%3E%3CU%3E%3CSTRONG%3ETrend%26nbsp%3B%3C%2FSTRONG%3E%3C%2FU%3E%3C%2FFONT%3Eparameter%20controls%20trend%20analysis.%20%26nbsp%3BIt%20can%20be%20set%20to%20one%20of%20below%20value.%3CUL%3E%0A%3CLI%3E%E2%80%98avg%E2%80%99%20%3A%20define%20trend%20component%20as%20average(x)%20%5Bdefault%5D%3C%2FLI%3E%0A%3CLI%3E%E2%80%98linefit%E2%80%99%3A%20extracts%20trend%20component%20using%20linear%20regression.%3C%2FLI%3E%0A%3CLI%3E%E2%80%98none%E2%80%99%20%3A%20no%20trend%2C%20skip%20extracting%20this%20component.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSTRONG%3E%3CEM%3Emv-expand%20%3A%20%3C%2FEM%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThis%20operator%20is%20primarily%20used%20to%20expand%20results%20of%20time%20series%20analysis%20decomposition%20functions%20which%20are%20originally%20a%20collection%20of%20multi%20value%20array%20%26nbsp%3Binto%20associated%20timestamps%20and%20data%20points%20with%20total%2C%20baseline%20counts%20and%20score%20as%20individual%20rows.%20This%20output%20is%20useful%20to%20filter%20out%20just%20the%20anomalies%20which%20are%20then%20used%20to%20alerting%20purpose%20or%20join%20against%20other%20tables%20on%20timestamp%20columns%20to%20gather%20additional%20context%20around%20anomalies.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%225%22%3E%3CSTRONG%3EDecomposing%20Time%20series%20as%20a%20Kusto%20Query%3A%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EBelow%20is%20a%20representation%20of%20various%20sections%20of%20Time%20series%20analysis%20and%20corresponding%20Kusto%20Query%20templates%20to%20understand%20it%20better.%20The%20queries%20consist%20of%20different%20steps%20such%20as%20data%20preparation%2C%20visualizing%20the%20results%20or%20alerting%20on%20the%20outliers.%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId-1342208339%22%20id%3D%22toc-hId-1342208339%22%20id%3D%22toc-hId-1342208339%22%3E%26nbsp%3B%3C%2FH4%3E%0A%3CH4%20id%3D%22toc-hId--1209948622%22%20id%3D%22toc-hId--1209948622%22%20id%3D%22toc-hId--1209948622%22%3EPreparing%20Time%20Series%20Data%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%2F112979i217AD9B268A2FB73%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%221-Data%20Preparation.png%22%20title%3D%221-Data%20Preparation.png%22%20%2F%3E%3C%2FSPAN%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%2F112971i9BA64466E6D54DCF%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%222-Data%20Preparation.png%22%20title%3D%222-Data%20Preparation.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FH4%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CFONT%20size%3D%223%22%3EVisualizing%20the%20decomposition%20and%20anomalies%20from%20the%20results%20of%20the%20Time%20Series%20Data.%3C%2FFONT%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F112973iBBB590109864D0E4%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%223-Data%20Visualization.png%22%20title%3D%223-Data%20Visualization.png%22%20%2F%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F112974i9D720BBDB0310A77%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%224-Data%20Visualization.png%22%20title%3D%224-Data%20Visualization.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3EConfigure%20alerts%20on%20specific%20outliers%20from%20the%20results%20of%20the%20Time%20Series%20Analysis%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3E%3CSPAN%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%2F112976iF55CEB9475D819C7%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%225-Alerting.png%22%20title%3D%225-Alerting.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3EInvestigate%20anomalies%20by%20joining%20it%20against%20base%20logs%20to%20populate%20additional%20fields%3C%2FFONT%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%2F112977i538811A18C0C70DD%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%226-Investigation.png%22%20title%3D%226-Investigation.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%225%22%3E%3CSTRONG%3EPractical%20Time%20Series%20Analysis%20applications%20on%20Security%20Event%20Log%20Data%20sources%3A%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EAs%20part%20of%20security%20monitoring%20and%20incident%20response%2C%20analysts%20often%20develop%20several%20detections%20based%20on%20static%20thresholds%20within%20a%20specified%20time%20interval%20window.%20Traditionally%20this%20threshold%20value%20is%20identified%20manually%20by%20historical%20trend%20of%20events%20and%20is%20configured%20as%20a%20static%20value%20in%20the%20detection.%20e.g.%20brute%20force%20attack%20may%20have%20logic%20of%2050%20logon%20failures%20in%201%20min%20etc.%3C%2FP%3E%0A%3CP%3EIt%20is%20often%20cumbersome%20to%20take%20various%20patterns%20at%20different%20time%20intervals%20such%20as%20after%20hours%2C%20weekends%20into%20considerations%20while%20flagging%20anomaly%20which%20results%20in%20false%20positives%20and%20often%20addressed%20by%20maintaining%20whitelist%20manually.%3C%2FP%3E%0A%3CP%3EIn%20addition%2C%20despite%20of%20static%20threshold%20being%20reached%2F%20exceeded%20slightly%2C%20the%20results%20are%20often%20uninteresting%20and%20generate%20false%20positives%20for%20analysts.%20As%20part%20of%20triage%2C%20analyst%20improve%20detections%20via%20whitelisting%20over%20the%20period%20to%20reduce%20false%20positive%20rate.%3C%2FP%3E%0A%3CP%3EThis%20approach%20is%20not%20scalable%20and%20time%20series%20analysis-based%20detections%20can%20effectively%20replace%20these%20static%20detections.%26nbsp%3B%20The%20results%20are%20robust%20to%20outliers%20as%20it%20considers%20seasonality%20and%20historical%20trend%20when%20flagging%20an%20anomaly.%20These%20functions%20also%20perform%20very%20well%20at%20scale%20due%20to%20vectorized%20implementation%20to%20process%20thousands%20of%20time%20series%20in%20seconds.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3E%3CSTRONG%3EScenario%201%3A%20Time%20Series%20anomaly%20for%20process%20execution%20frequency.%3C%2FSTRONG%3E%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FDetections%2FSecurityEvent%2FTimeSeriesAnomaly-ProcessExecutions.txt%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EGitHub%20Link%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20the%20demonstration%20purpose%2C%20we%20will%20run%20it%20against%20sample%20data%20from%20lab%20and%20also%20split%20the%20query%20to%20display%20various%20results%20step%20by%20step.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3E%3CSTRONG%3E%3CU%3EQuery%3A%3C%2FU%3E%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EFirst%20part%20of%20the%20query%20will%20prepare%20the%20time%20series%20data%20per%20each%20process%20by%20using%20%3CSTRONG%3E%3CEM%3Emake-series%3C%2FEM%3E%3C%2FSTRONG%3E%20operator.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CPRE%3E%3CFONT%20color%3D%22%230000FF%22%3Elet%3C%2FFONT%3E%20starttime%20%3D%207d%3B%0A%3CFONT%20color%3D%22%230000FF%22%3Elet%3C%2FFONT%3E%20endtime%20%3D%201d%3B%0A%3CFONT%20color%3D%22%230000FF%22%3Elet%3C%2FFONT%3E%20timeframe%20%3D%201h%3B%0A%3CFONT%20color%3D%22%230000FF%22%3Elet%3C%2FFONT%3E%20TotalEventsThreshold%20%3D%205%3B%0A%3CFONT%20color%3D%22%230000FF%22%3Elet%3C%2FFONT%3E%20ExeList%20%3D%20%3CFONT%20color%3D%22%230000FF%22%3Edynamic%3C%2FFONT%3E(%0A%5B%3CFONT%20color%3D%22%23993300%22%3E%22powershell.exe%22%2C%22cmd.exe%22%2C%22wmic.exe%22%3C%2FFONT%3E%5D)%3B%0A%3CFONT%20color%3D%22%230000FF%22%3Elet%3C%2FFONT%3E%20TimeSeriesData%3D%20%0ASecurityEvent%0A%7C%20%3CFONT%20color%3D%22%23FF00FF%22%3Ewhere%3C%2FFONT%3E%20EventID%20%3D%3D%20%3CFONT%20color%3D%22%23993300%22%3E%224688%22%3C%2FFONT%3E%20%7C%20%3CFONT%20color%3D%22%23FF00FF%22%3Eextend%3C%2FFONT%3E%20Process%20%3D%20%3CFONT%20color%3D%22%230000FF%22%3Etolower%3C%2FFONT%3E(Process)%0A%7C%20%3CFONT%20color%3D%22%23FF00FF%22%3Ewhere%3C%2FFONT%3E%20TimeGenerated%20%3CFONT%20color%3D%22%230000FF%22%3Ebetween%3C%2FFONT%3E%20(%3CFONT%20color%3D%22%230000FF%22%3Estartofday%3C%2FFONT%3E(%3CFONT%20color%3D%22%230000FF%22%3Eago%3C%2FFONT%3E(starttime))..%3CFONT%20color%3D%22%230000FF%22%3Estartofday%3C%2FFONT%3E(%3CFONT%20color%3D%22%230000FF%22%3Eago%3C%2FFONT%3E(endtime)))%0A%7C%20%3CFONT%20color%3D%22%23FF00FF%22%3Ewhere%3C%2FFONT%3E%20Process%20%3CFONT%20color%3D%22%230000FF%22%3Ein%3C%2FFONT%3E%20(ExeList)%0A%7C%20%3CFONT%20color%3D%22%23FF00FF%22%3Eproject%3C%2FFONT%3E%20TimeGenerated%2CComputer%2C%20AccountType%2C%20Account%2C%20Process%0A%7C%20%3CFONT%20color%3D%22%23FF00FF%22%3Emake-series%3C%2FFONT%3E%20Total%3D%3CFONT%20color%3D%22%230000FF%22%3Ecount%3C%2FFONT%3E()%20on%20TimeGenerated%20%3CFONT%20color%3D%22%230000FF%22%3Efrom%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000FF%22%3Eago%3C%2FFONT%3E(starttime)%20to%20%3CFONT%20color%3D%22%230000FF%22%3Eago%3C%2FFONT%3E(endtime)%20%3CFONT%20color%3D%22%230000FF%22%3Estep%3C%2FFONT%3E%20timeframe%20%3CFONT%20color%3D%22%230000FF%22%3Eby%3C%2FFONT%3E%20Process%3B%0ATimeSeriesData%3C%2FPRE%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3E%3CSTRONG%3E%3CU%3EResults%3A%3C%2FU%3E%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ESample%20results%20will%20look%20like%20below.%20%3CU%3E%3CEM%3ETotal%3C%2FEM%3E%3C%2FU%3E%20and%20%3CU%3E%3CEM%3ETimeGenerated%3C%2FEM%3E%3C%2FU%3E%20columns%20are%20vector%20of%20multi-value%20array%20per%20process%20with%20associated%20Timestamp%20hour%20windows%20and%20execution%20count%20in%20that%20hour.%20%26nbsp%3BYou%20can%20also%20notice%200%20values%20which%20are%20filled%20by%20make-series%20operator%20for%20missing%20values.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%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%2F112800iC66A5F96B9FEA73C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%221-TimeSeriesData-Results.png%22%20title%3D%221-TimeSeriesData-Results.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20this%20article%2C%20we%20will%20not%20look%20into%20visualizing%20results%2C%20but%20you%20can%20try%20out%20the%20queries%20yourself%20described%20in%20previous%20section%20on%20your%20logs.%20We%20will%20cover%20visualization%20aspect%20in%20follow-up%20blog%20post%20with%20another%20use%20case.%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CU%3EQuery%3A%3C%2FU%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ENext%20part%20of%20the%20query%20will%20detect%20seasonality%2C%20trend%20in%20your%20data%20automatically%20and%20will%20use%20it%20to%20flag%20spikes%20as%20anomalies%20based%20on%20provided%20parameters.%20(1.5%20as%20threshold%2C%20-1%20to%20detect%20auto-seasonality%20and%20%3CEM%3Elinefit%3C%2FEM%3E%20for%20trend%20analysis).%3C%2FSPAN%3E%3C%2FP%3E%0A%3CPRE%3E%3CFONT%20color%3D%22%230000FF%22%3Elet%3C%2FFONT%3E%20TimeSeriesAlerts%3DTimeSeriesData%0A%7C%20%3CFONT%20color%3D%22%23FF00FF%22%3Eextend%3C%2FFONT%3E%20(anomalies%2C%20score%2C%20baseline)%20%3D%20%3CFONT%20color%3D%22%230000FF%22%3Eseries_decompose_anomalies%3C%2FFONT%3E(Total%2C%201.5%2C%20-1%2C%20%3CFONT%20color%3D%22%23993300%22%3E'linefit'%3C%2FFONT%3E)%0A%7C%20%3CFONT%20color%3D%22%23FF00FF%22%3Emv-expand%3C%2FFONT%3E%20Total%20to%20%3CFONT%20color%3D%22%230000FF%22%3Etypeof%3C%2FFONT%3E(double)%2C%20TimeGenerated%20to%20%3CFONT%20color%3D%22%230000FF%22%3Etypeof%3C%2FFONT%3E(datetime)%2C%20anomalies%20to%20%3CFONT%20color%3D%22%230000FF%22%3Etypeof%3C%2FFONT%3E(double)%2Cscore%20to%20%3CFONT%20color%3D%22%230000FF%22%3Etypeof%3C%2FFONT%3E(double)%2C%20baseline%20to%20%3CFONT%20color%3D%22%230000FF%22%3Etypeof%3C%2FFONT%3E(long)%0A%7C%20%3CFONT%20color%3D%22%23FF00FF%22%3Ewhere%3C%2FFONT%3E%20anomalies%20%26gt%3B%200%0A%7C%20%3CFONT%20color%3D%22%23FF00FF%22%3Eproject%3C%2FFONT%3E%20Process%2CTimeGenerated%2C%20Total%2C%20baseline%2C%20anomalies%2C%20score%0A%7C%20%3CFONT%20color%3D%22%23FF00FF%22%3Ewhere%3C%2FFONT%3E%20Total%20%26gt%3B%20TotalEventsThreshold%3B%0ATimeSeriesAlerts%3C%2FPRE%3E%0A%3CP%3E%3CSTRONG%3E%3CU%3EResults%3A%3C%2FU%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3ESample%20result%20will%20look%20like%20below.%20Total%20column%20indicates%20the%20actual%20count%20observed%20in%20that%20hour%20and%20baseline%20count%20was%20expected%20count%20in%20that%20hour.%20Please%20note%2C%20since%20the%20timestamps%20are%20aggregated%20per%20hour%2C%20timestamp%20will%20show%20the%20hour%20at%20which%20total%20value%20crossed%20baseline.The%20results%20are%20spikes%20as%20anomalies%20observed%20against%20historical%20baseline%20count.%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%2F112802i60BFACA85E6A4DCC%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%222-TimeSeriesAlerts.png%22%20title%3D%222-TimeSeriesAlerts.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20investigate%20the%20results%20of%20the%20anomalies%2C%20you%20can%20join%20it%20with%20base%20table%20of%20windows%20event%20logs%20and%20gather%20additional%20context.%26nbsp%3BYou%20can%20also%20use%20other%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-explorer%2Fmachine-learning-clustering%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Emachine%20learning%20capabilities%20related%20to%20clustering%3C%2FA%3E%20such%20as%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fautoclusterplugin%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eautocluster%3C%2FA%3E%20%2C%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fdiffpatternsplugin%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ediffpatterns%3C%2FA%3E%20to%20perform%20automated%20Root%20Cause%20Analysis%20associated%20with%20anomaly%20which%20will%20be%20covered%20in%20follow-up%20blogs.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CU%3E%3CSTRONG%3EQuery%3A%3C%2FSTRONG%3E%3C%2FU%3E%3C%2FP%3E%0A%3CP%3EThe%20last%20part%20of%20the%20query%20will%20join%20the%20results%20of%20the%20anomalies%20with%20base%20data%20to%20populate%20additional%20fields%20to%20gather%20additional%20context%20to%20determine%20if%20its%20malicious%20or%20not.%3C%2FP%3E%0A%3CPRE%3ETimeSeriesAlerts%0A%7C%20%3CFONT%20color%3D%22%23FF00FF%22%3Ejoin%3C%2FFONT%3E%20(%0ASecurityEvent%0A%7C%20%3CFONT%20color%3D%22%23FF00FF%22%3Ewhere%3C%2FFONT%3E%20EventID%20%3D%3D%20%3CFONT%20color%3D%22%23993300%22%3E%224688%22%3C%2FFONT%3E%20%7C%20%3CFONT%20color%3D%22%23FF00FF%22%3Eextend%3C%2FFONT%3E%20Process%20%3D%20%3CFONT%20color%3D%22%230000FF%22%3Etolower%3C%2FFONT%3E(Process)%0A%7C%20%3CFONT%20color%3D%22%23FF00FF%22%3Esummarize%3C%2FFONT%3E%20CommandlineCount%3D%3CFONT%20color%3D%22%230000FF%22%3Ecount%3C%2FFONT%3E()%20%3CFONT%20color%3D%22%230000FF%22%3Eby%20bin%3C%2FFONT%3E(TimeGenerated%2C%201h)%2CProcess%2C%20CommandLine%2C%20Computer%2C%20Account%0A)%20on%20Process%2C%20TimeGenerated%20%7C%20%3CFONT%20color%3D%22%23FF00FF%22%3Eextend%3C%2FFONT%3E%20AnomalyTimeattheHour%20%3D%20TimeGenerated%20%0A%7C%20%3CFONT%20color%3D%22%23FF00FF%22%3Eproject%3C%2FFONT%3E%20AnomalyTimeattheHour%2C%20Computer%2C%20Account%2CProcess%2C%20CommandLine%20%2CCommandlineCount%2C%20Total%2C%20baseline%2C%20anomalies%20%2C%20score%20%3C%2FPRE%3E%0A%3CP%3E%3CU%3E%3CSTRONG%3EResults%3A%3C%2FSTRONG%3E%3C%2FU%3E%3C%2FP%3E%0A%3CP%3ESample%20results%20may%20look%20like%20below%20along%20with%20host%20%2C%20account%20name%20%2C%20process%20and%20command%20line%20details%20seen%20in%20the%20respective%20hour.%20Below%20screenshots%20filtered%20to%20interesting%20events%20for%20demo%20purposes%20but%20ideally%20query%20will%20return%20all%20events%20happened%20during%20that%20hour%20and%20analyst%20has%20to%20manually%20see%20what%20additional%20events%20were%20observed%20during%20the%20time%20window%20and%20if%20anything%20is%20malicious%20or%20worth%20investigating.%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%2F112804iFE348DFD71829C16%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%223-AlertResults.png%22%20title%3D%223-AlertResults.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20find%20additional%20Time%20Series%20based%20detection%20queries%20in%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Sentinel%20github%20repo.%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EBelow%20direct%20links%20for%20reference.%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3E%3CEM%3E%3CSTRONG%3EScenario%202%3A%20Time%20series%20anomaly%20for%20Data%20exfiltration%3A%3C%2FSTRONG%3E%3C%2FEM%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FDetections%2FMultipleDataSources%2FTimeSeriesAnomaly-MultiVendor_DataExfiltration.txt%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EGithub%20Link%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3E%3CEM%3E%3CSTRONG%3EScenario%203%3A%20Time%20Series%20anomaly%20for%20total%20volume%20in%20network%20logs%3A%3C%2FSTRONG%3E%3C%2FEM%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Fblob%2Fmaster%2FDetections%2FCommonSecurityLog%2FTimeSeriesAnomaly-MultiVendor_NetworkTraffic.txt%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EGithub%20Link%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%225%22%3E%3CSTRONG%3EConclusion%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3ETime%20series%20analysis%20is%20an%20effective%20technique%20to%20understand%20various%20time-based%20patterns%20in%20your%20data.%20Applying%20time%20series%20analysis%20technique%20on%20various%20security%20data%20sources%20provides%20unique%20capability%20as%20compared%20to%20traditional%20detection%20mechanisms%20which%20are%20atomic%20or%20static%20in%20nature.%20It%20helps%20in%20finding%20deviations%20from%20normal%20patterns%20by%20KQL%20built-in%20functions%20which%20detects%20seasonality%20and%20trend%20at%20scale%20automatically%20from%20the%20input%20time%20series%20data.%3C%2FP%3E%0A%3CP%3EIn%20this%20article%2C%20we%20looked%20into%20practical%20example%20where%20we%20analyzed%20series%20of%20process%20execution%20data%20for%20sensitive%20processes%20which%20are%20often%20leveraged%20as%20attack%20vectors.%20By%20analyzing%20trend%20of%20frequency%20of%20executions%20over%2030%20days%2C%20we%20detected%20seasonality%20and%20trend%20in%20the%20data%20which%20helped%20to%20identify%20two%20anomalies%20on%2019%3CSUP%3Eth%3C%2FSUP%3E%20Apr%20at%206%20and%207%20UTC%20hour.%20The%20deviation%20from%20the%20baseline%20count%20alone%20are%20not%20necessarily%20an%20indication%20of%20malicious%20activity%20but%20gathering%20more%20context%20around%20the%20timestamp%20of%20anomaly%20such%20as%20command%20line%20activity%20helps%20uncover%20additional%20events%20seen%20during%20that%20time%20window.%20In%20this%20case%2C%20we%20saw%20records%20of%20Powershell%20running%20mimikatz%20on%20multiple%20hosts.%3C%2FP%3E%0A%3CP%3EIn%20traditional%20scenario%2C%20calculating%20right%20threshold%20for%20the%20range%20of%20execution%20count%20would%20have%20been%20challenging%2C%20resulting%20in%20either%20too%20many%20false%20positives%20or%20true%20negatives.%20The%20built-in%20functions%20also%3C%2FP%3E%0A%3CP%3Eprovides%20capability%20to%20customize%20thresholds%20to%20flag%20the%20outliers%20which%20are%20far%20from%20the%20normal%20baseline%20in%20multiple%20ways%20(adjust%20the%20threshold%20value%2C%20custom%20score%20threshold)%20so%20as%20to%20reduce%20false%20positive%20rate%20if%20required.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFeel%20free%20to%20submit%20pull%20requests%20on%20other%20time%20series%20analysis%20based%20queries%20on%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Sentinel%20Github%20Repo%3C%2FA%3E.%20%26nbsp%3BHappy%20Hunting.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%225%22%3E%3CSTRONG%3EReferences%3A%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ETime%20Series%20-%20Wikipedia%20%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FTime_series%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fen.wikipedia.org%2Fwiki%2FTime_series%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EHow%20To%20Identify%20Patterns%20in%20Time%20Series%20Data%3A%20Time%20Series%20Analysis%26nbsp%3B.%20(2018).%20Statsoft.com%3A%26nbsp%3B%3CA%20href%3D%22http%3A%2F%2Fwww.statsoft.com%2FTextbook%2FTime-Series-Analysis%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fwww.statsoft.com%2FTextbook%2FTime-Series-Analysis%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EAnomaly%20detection%20and%20forecasting%20in%20Azure%20Data%20Explorer%20%3A%20%3CA%20style%3D%22font-family%3A%20inherit%3B%20background-color%3A%20%23ffffff%3B%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-explorer%2Fanomaly-detection%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-explorer%2Fanomaly-detection%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3ETime%20series%20analysis%20in%20Azure%20Data%20Explorer%3A%20%3CA%20style%3D%22font-family%3A%20inherit%3B%20background-color%3A%20%23ffffff%3B%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-explorer%2Ftime-series-analysis%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-explorer%2Ftime-series-analysis%3C%2FA%3E%3CU%3E%3C%2FU%3E%3C%2FLI%3E%0A%3CLI%3EMachine%20Learning%20Capability%20in%20Azure%20Data%20Explorer%20%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-explorer%2Fmachine-learning-clustering%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-explorer%2Fmachine-learning-clustering%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3ETukey%60s%20fence%20test%3A%20%3CA%20href%3D%22https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FOutlier%23Tukey's_fences%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fen.wikipedia.org%2Fwiki%2FOutlier%23Tukey's_fences%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EForecasting%3A%20Principles%20and%20Practice%20-%20Chapter%206%3A%20Time%20series%20decomposition%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fotexts.com%2Ffpp2%2Fdecomposition.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fotexts.com%2Ffpp2%2Fdecomposition.html%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EKQL%20operators%20syntax%20and%20example%20usage%20documentation%3A%0A%3CUL%3E%0A%3CLI%3Emake-series%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fmake-seriesoperator%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fmake-seriesoperator%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3Eseries_decompose()%20%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fseries-decomposefunction%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fseries-decomposefunction%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3Eseries_decompose_anomalies()%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fseries-decompose-anomaliesfunction%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fseries-decompose-anomaliesfunction%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3Eseries_outliers()%20%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fseries-outliersfunction%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fseries-outliersfunction%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3Emv-expand%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fmvexpandoperator%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Fmvexpandoperator%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3Erender%20%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Frenderoperator%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Frenderoperator%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-555052%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20article%20provides%20a%20practical%20outline%20for%20using%20Time%20Series%20analysis%20to%20surface%20anomalies%20on%20security%20event%20log%20data%20sources%2C%20visualizing%20and%20alerting%20on%20anomalies%20for%20further%20investigation%20in%20Azure%20Sentinel.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20will%20describe%20the%20various%20functions%20which%20are%20used%20in%20compiling%20the%20query%20and%20how%20to%20use%20those%20KQL%20queries%20to%20either%20visualize%20the%20output%20or%20transform%20it%20into%20tabular%20data%20outputs%20to%20configure%20alerts%20on%20specific%20anomalies.%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%2F113281i9FB39C81F95FD373%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%222-TimeSeriesAlerts.png%22%20title%3D%222-TimeSeriesAlerts.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-555052%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDetection%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMachine%20Learning%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1043874%22%20slang%3D%22en-US%22%3ERe%3A%20Looking%20for%20unknown%20anomalies%20-%20what%20is%20normal%3F%20Time%20Series%20analysis%20%26amp%3B%20its%20applications%20in%20S%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1043874%22%20slang%3D%22en-US%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F313528%22%20target%3D%22_blank%22%3E%40Ashwin_Patil%3C%2FA%3E%26nbsp%3B%3A%20Thank%20you%20for%20sharing.%20its%20really%20good%20informative%20use-case%20on%20Azure%20sentinel.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

We previously blogged about Machine learning powered detections with Kusto query language in Azure Sentinel and Time series analysis applied in a security hunting context.

This article provides a practical outline for using Time Series analysis to surface anomalies on security event log data sources, visualizing and alerting on anomalies for further investigation in Azure Sentinel. 

 

We will describe the various functions which are used in compiling the query and how to use those KQL queries to either visualize the output or transform it into tabular data outputs to configure alerts on specific anomalies.

 

What is Time Series data?

Per Wikipedia, Time Series is a series of data points indexed (or listed or graphed) in time order. The data points are often discrete numeric points such as frequency of counts or occurrences against a column of the dataset.

Time series analysis and forecasting is effectively used in multiple sectors, , IoT, service monitoring etc to identify meaningful statistics from historical data as well as predicting future outcomes.

We will keep the overview short and simple for the scope of this article and focus on applied techniques on security event log data sources.

 

When to use Time Series analysis:

By analyzing time series data over an extended period, we can identify time-based patterns (e.g. seasonality, trend etc.) in the data and extract meaningful statistics which can help in flagging outliers.  A particular example in a security context is user logon patterns over a period of time exhibiting different behavior after hours and on weekends: computing deviations from these changing patterns is rather difficult in traditional atomic detections with static thresholds. KQL built-in functions can automatically identify such seasonality and trend from the input data and take it into consideration when flagging anomalies.

To prepare data for time series analysis, select the data sources and the data points associated with it. 

These data points can then be transformed series of  aggregated values against continuous time intervals from the original data.

Ideally, the dataset in scope should have consistent values populated for most of the time windows. If there are too many missing data points, the outlier results may be affected.

However, make-series operator used to prepare the time series data inserts values for missing time window intervals. By default it sets value to 0 for missing values, you  also have control to change default values to avg() or any other constants by setting it to default argument of make-series.

 

Typical time series analysis workflow involves below steps:

  • Select the data source table which contains raw events defined for the scope of the analysis.
  • Define the field (such as sourceip, accountname, hostname etc) from the schema against which numeric data points (such as count of outbound network connections, count of logons etc.) will be calculated.
  • Use built-in KQL operators to convert the input data into time series by using make-series operator which transforms base logs into series of aggregated values of specified data points against time windows (e.g. count of logon per hour, outbound data transfer per day etc).
  • Use time series functions (e.g. series_decompose and series_decompose_anomalies) to apply decomposition transformation on an input data series and extract anomalous points.
  • You can plot the output in a time chart by splitting seasonal, trend, residual components in the data or you can expand the output to filter for anomalies and flag it as an alert.

Data transformation and Time series analysis with KQL built-in functions and operators:

The KQL operators and functions below are generally used to compile time series-based detections in Kusto. Check the reference section for more operators to customize the analysis or read more about its syntax and usage.

Apart from using KQL built-in functions, one can also load input data in data frame and then use other time series methods/libraries in Python and R language via Jupyter notebook. However built-in functions natively available in KQL are optimized for performance and works efficient on large scale of data.

The most convenient way of using these functions is applying it to the results of make-series operator which will transform your input data into multi-value series ready to either plot on time chart or alert on outliers.

 

make-series:

This operator creates a series of specified aggregated values along specified axis. It is used to aggregate data points in a series by specified column available in data source schema. This will transform multi row table output into a single row as multi-value array. The operator also fills in 0 automatically for missing values or you can override with default option with average.

 

series_decompose() :

This function applies a decomposition transformation on a series. It takes time series data prepared by make-series and decompose it to seasonal, trend and residual components.

 

series_decompose_anomolies() :

This function is for anomaly detection which is based on series decomposition (refer to series_decompose())

It takes an expression containing a series (dynamic numerical array) as input and extract anomalous points with scores. anomaly detections used with this function are based on Tukey’s test. The function has several parameters including AD_method, threshold, seasonality and trend which are explained below.

  • AD_method parameter in above syntax specifically controls the anomaly detection method on the residual time series. Available options are ctukey (default option- 10th-90th percentile range) and tukey (standard - 25th-75th percentile range)
  • threshold value greater than 1.5 or less than -1.5 indicates a spike or dip anomaly respectively in the same element of the input.  In case default threshold (1.5) is still producing lot of results with false positives then, you can set to 3 which corresponds to a far outlier
  • Seasonality parameter controls seasonal analysis. It will have one of below value.
    • -1 : autodetect seasonality
    • Period: positive integer, specify number of bins e.g if input data is hourly, weekly period will be 168 bins.
    • 0 : no seasonality (skip extracting component)
  • Trend parameter controls trend analysis.  It can be set to one of below value.
    • ‘avg’ : define trend component as average(x) [default]
    • ‘linefit’: extracts trend component using linear regression.
    • ‘none’ : no trend, skip extracting this component.

mv-expand :

This operator is primarily used to expand results of time series analysis decomposition functions which are originally a collection of multi value array  into associated timestamps and data points with total, baseline counts and score as individual rows. This output is useful to filter out just the anomalies which are then used to alerting purpose or join against other tables on timestamp columns to gather additional context around anomalies.

 

Decomposing Time series as a Kusto Query:

Below is a representation of various sections of Time series analysis and corresponding Kusto Query templates to understand it better. The queries consist of different steps such as data preparation, visualizing the results or alerting on the outliers.

 

Preparing Time Series Data1-Data Preparation.png2-Data Preparation.png

 

Visualizing the decomposition and anomalies from the results of the Time Series Data.3-Data Visualization.png4-Data Visualization.png

 

Configure alerts on specific outliers from the results of the Time Series Analysis

 

5-Alerting.png

Investigate anomalies by joining it against base logs to populate additional fields

6-Investigation.png

 

Practical Time Series Analysis applications on Security Event Log Data sources:

As part of security monitoring and incident response, analysts often develop several detections based on static thresholds within a specified time interval window. Traditionally this threshold value is identified manually by historical trend of events and is configured as a static value in the detection. e.g. brute force attack may have logic of 50 logon failures in 1 min etc.

It is often cumbersome to take various patterns at different time intervals such as after hours, weekends into considerations while flagging anomaly which results in false positives and often addressed by maintaining whitelist manually.

In addition, despite of static threshold being reached/ exceeded slightly, the results are often uninteresting and generate false positives for analysts. As part of triage, analyst improve detections via whitelisting over the period to reduce false positive rate.

This approach is not scalable and time series analysis-based detections can effectively replace these static detections.  The results are robust to outliers as it considers seasonality and historical trend when flagging an anomaly. These functions also perform very well at scale due to vectorized implementation to process thousands of time series in seconds.

 

Scenario 1: Time Series anomaly for process execution frequency.

GitHub Link

 

For the demonstration purpose, we will run it against sample data from lab and also split the query to display various results step by step.

 

Query:

First part of the query will prepare the time series data per each process by using make-series operator.

let starttime = 7d;
let endtime = 1d;
let timeframe = 1h;
let TotalEventsThreshold = 5;
let ExeList = dynamic(
["powershell.exe","cmd.exe","wmic.exe"]);
let TimeSeriesData= 
SecurityEvent
| where EventID == "4688" | extend Process = tolower(Process)
| where TimeGenerated between (startofday(ago(starttime))..startofday(ago(endtime)))
| where Process in (ExeList)
| project TimeGenerated,Computer, AccountType, Account, Process
| make-series Total=count() on TimeGenerated from ago(starttime) to ago(endtime) step timeframe by Process;
TimeSeriesData

Results:

Sample results will look like below. Total and TimeGenerated columns are vector of multi-value array per process with associated Timestamp hour windows and execution count in that hour.  You can also notice 0 values which are filled by make-series operator for missing values.

1-TimeSeriesData-Results.png

 

For this article, we will not look into visualizing results, but you can try out the queries yourself described in previous section on your logs. We will cover visualization aspect in follow-up blog post with another use case.

 

Query:

Next part of the query will detect seasonality, trend in your data automatically and will use it to flag spikes as anomalies based on provided parameters. (1.5 as threshold, -1 to detect auto-seasonality and linefit for trend analysis).

let TimeSeriesAlerts=TimeSeriesData
| extend (anomalies, score, baseline) = series_decompose_anomalies(Total, 1.5, -1, 'linefit')
| mv-expand Total to typeof(double), TimeGenerated to typeof(datetime), anomalies to typeof(double),score to typeof(double), baseline to typeof(long)
| where anomalies > 0
| project Process,TimeGenerated, Total, baseline, anomalies, score
| where Total > TotalEventsThreshold;
TimeSeriesAlerts

Results:

Sample result will look like below. Total column indicates the actual count observed in that hour and baseline count was expected count in that hour. Please note, since the timestamps are aggregated per hour, timestamp will show the hour at which total value crossed baseline.The results are spikes as anomalies observed against historical baseline count.

2-TimeSeriesAlerts.png

 

To investigate the results of the anomalies, you can join it with base table of windows event logs and gather additional context. You can also use other machine learning capabilities related to clustering such as autocluster , diffpatterns to perform automated Root Cause Analysis associated with anomaly which will be covered in follow-up blogs.

 

Query:

The last part of the query will join the results of the anomalies with base data to populate additional fields to gather additional context to determine if its malicious or not.

TimeSeriesAlerts
| join (
SecurityEvent
| where EventID == "4688" | extend Process = tolower(Process)
| summarize CommandlineCount=count() by bin(TimeGenerated, 1h),Process, CommandLine, Computer, Account
) on Process, TimeGenerated | extend AnomalyTimeattheHour = TimeGenerated 
| project AnomalyTimeattheHour, Computer, Account,Process, CommandLine ,CommandlineCount, Total, baseline, anomalies , score 

Results:

Sample results may look like below along with host , account name , process and command line details seen in the respective hour. Below screenshots filtered to interesting events for demo purposes but ideally query will return all events happened during that hour and analyst has to manually see what additional events were observed during the time window and if anything is malicious or worth investigating.

3-AlertResults.png

 

You can find additional Time Series based detection queries in Azure Sentinel github repo.

Below direct links for reference.

Scenario 2: Time series anomaly for Data exfiltration:

Github Link

Scenario 3: Time Series anomaly for total volume in network logs:

Github Link

 

Conclusion

Time series analysis is an effective technique to understand various time-based patterns in your data. Applying time series analysis technique on various security data sources provides unique capability as compared to traditional detection mechanisms which are atomic or static in nature. It helps in finding deviations from normal patterns by KQL built-in functions which detects seasonality and trend at scale automatically from the input time series data.

In this article, we looked into practical example where we analyzed series of process execution data for sensitive processes which are often leveraged as attack vectors. By analyzing trend of frequency of executions over 30 days, we detected seasonality and trend in the data which helped to identify two anomalies on 19th Apr at 6 and 7 UTC hour. The deviation from the baseline count alone are not necessarily an indication of malicious activity but gathering more context around the timestamp of anomaly such as command line activity helps uncover additional events seen during that time window. In this case, we saw records of Powershell running mimikatz on multiple hosts.

In traditional scenario, calculating right threshold for the range of execution count would have been challenging, resulting in either too many false positives or true negatives. The built-in functions also

provides capability to customize thresholds to flag the outliers which are far from the normal baseline in multiple ways (adjust the threshold value, custom score threshold) so as to reduce false positive rate if required.

 

Feel free to submit pull requests on other time series analysis based queries on Azure Sentinel Github Repo.  Happy Hunting.

 

References:

1 Comment
Regular Visitor

Hello @Ashwin_Patil : Thank you for sharing. its really good informative use-case on Azure sentinel.