Home
%3CLINGO-SUB%20id%3D%22lingo-sub-795360%22%20slang%3D%22en-US%22%3EAZURE%20SQL%20DB%20AND%20LOG%20ANALYTICS%20BETTER%20TOGETHER%20%E2%80%93%20PART%20%232%20%E2%80%93%20ALERTS%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-795360%22%20slang%3D%22en-US%22%3E%3CP%3EAs%20you%20could%20see%20on%20previous%20post%20(%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Database-Support-Blog%2FAZURE-SQL-DB-AND-LOG-ANALYTICS-BETTER-TOGETHER-PART-1%2Fba-p%2F794833%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3EAZURE%20SQL%20DB%20AND%20LOG%20ANALYTICS%20BETTER%20TOGETHER%20%E2%80%93%20PART%26nbsp%3B%231%3C%2FA%3E)%20using%20Azure%20SQL%20DB%20%2B%20Log%20Analytics%20is%20quite%20easy.%3C%2FP%3E%0A%3CP%3ELet%20see%20how%20can%20we%20improve%20even%20further%20with%26nbsp%3B%3CSTRONG%3EALERTS%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELet%E2%80%99s%20imagine%20I%20want%20to%20receive%20everyday%20a%20list%20of%20all%20failed%20logins%20to%20be%20reviewed%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20will%20reuse%20a%20query%20from%20last%20post%20to%20get%20failed%20logins%2C%20and%20I%20will%20just%20change%20parameter%20of%20time%20to%20filter%20failed%20logins%20on%20last%201%20day%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%2F%2FFailed%20Logins%0AAzureDiagnostics%0A%7C%20where%20TimeGenerated%20%26gt%3B%3D%20ago(1d)%20%2F%2FEvents%20on%20last%201%20days%0A%7C%20where%20action_name_s%20%3D%3D%20%22DATABASE%20AUTHENTICATION%20FAILED%22%0A%7C%20extend%20additional_information_xml%3Dparse_xml(additional_information_s)%0A%7C%20extend%20Error_Code%3Dadditional_information_xml.login_information.error_code%0A%7C%20extend%20Error_State%3Dadditional_information_xml.login_information.error_state%0A%7C%20project%0A%20%20%20%20TimeGenerated%2C%20event_time_t%2C%0A%20%20%20%20ResourceGroup%2C%20LogicalServerName_s%2C%20database_name_s%2C%0A%20%20%20%20session_id_d%2C%20client_ip_s%2C%20application_name_s%2C%20session_server_principal_name_s%2C%0A%20%20%20%20Error_Code%2C%20Error_State%0A%7C%20order%20by%20TimeGenerated%20desc%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20see%20that%20at%20this%20moment%20I%20don%E2%80%99t%20have%20any%20error%20(0%20records).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20create%20an%20Alert%20based%20on%20a%20query%2C%20just%20click%20on%26nbsp%3B%3CSTRONG%3ENew%20alert%20rule%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F126203i8A4CE4EB603BBE87%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%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%3CH2%20id%3D%22toc-hId-1796190619%22%20id%3D%22toc-hId-1796190619%22%3E1%20%E2%80%93%20CONDITIONS%3C%2FH2%3E%0A%3CP%3EResource%20is%20already%20filled%20with%20LogAnalytics%3C%2FP%3E%0A%3CP%3ENow%20we%20need%20to%20define%20in%20which%20condition%20it%20will%20fire.%20Just%20click%20on%26nbsp%3B%3CSTRONG%3ECONDITION%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F126202i1339407E33F52711%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%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%3EYou%20can%20see%20the%20search%20query%20was%20prepopulated%2C%20you%20just%20need%20to%20set%26nbsp%3B%3CSTRONG%3Ethreshold%20value%2C%3C%2FSTRONG%3E%26nbsp%3B%3CSTRONG%3Eperiod%3C%2FSTRONG%3E%26nbsp%3Band%26nbsp%3B%3CSTRONG%3Efrequency.%3C%2FSTRONG%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%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F126201i94B3C20717A3039C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%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%3E%3CSTRONG%3E%3CEM%3ETime%20Period%3C%2FEM%3E%3C%2FSTRONG%3E%3CEM%3E.%20Specifies%20the%20time%20range%20for%20the%20query.%20The%20query%20returns%20only%20records%20that%20were%20created%20within%20this%20range%20of%20the%20current%20time.%20Time%20period%20restricts%20the%20data%20fetched%20for%20log%20query%20to%20prevent%20abuse%20and%20circumvents%20any%20time%20command%20(like%20ago)%20used%20in%20log%20query.%26nbsp%3B%3CBR%20%2F%3EFor%20example%2C%20If%20the%20time%20period%20is%20set%20to%2060%20minutes%2C%20and%20the%20query%20is%20run%20at%201%3A15%20PM%2C%20only%20records%20created%20between%2012%3A15%20PM%20and%201%3A15%20PM%20is%20returned%20to%20execute%20log%20query.%20Now%20if%20the%20log%20query%20uses%20time%20command%20like%20ago%20(7d)%2C%20the%20log%20query%20would%20be%20run%20only%20for%20data%20between%2012%3A15%20PM%20and%201%3A15%20PM%20%E2%80%93%20as%20if%20data%20exists%20for%20only%20the%20past%2060%20minutes.%20And%20not%20for%20seven%20days%20of%20data%20as%20specified%20in%20log%20query.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%3CBR%20%2F%3E%3CSTRONG%3EFrequency%3C%2FSTRONG%3E.%20Specifies%20how%20often%20the%20query%20should%20be%20run.%20Can%20be%20any%20value%20between%205%20minutes%20and%2024%20hours.%20Should%20be%20equal%20to%20or%20less%20than%20the%20time%20period.%20If%20the%20value%20is%20greater%20than%20the%20time%20period%2C%20then%20you%20risk%20records%20being%20missed.%3CBR%20%2F%3EFor%20example%2C%20consider%20a%20time%20period%20of%2030%20minutes%20and%20a%20frequency%20of%2060%20minutes.%20If%20the%20query%20is%20run%20at%201%3A00%2C%20it%20returns%20records%20between%2012%3A30%20and%201%3A00%20PM.%20The%20next%20time%20the%20query%20would%20run%20is%202%3A00%20when%20it%20would%20return%20records%20between%201%3A30%20and%202%3A00.%20Any%20records%20created%20between%201%3A00%20and%201%3A30%20would%20never%20be%20evaluated.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%3CBR%20%2F%3E%3CSTRONG%3EThreshold%3C%2FSTRONG%3E.%20The%20results%20of%20the%20log%20search%20are%20evaluated%20to%20determine%20whether%20an%20alert%20should%20be%20created.%20The%20threshold%20is%20different%20for%20the%20different%20types%20of%20log%20search%20alert%20rules.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3EREF%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Fplatform%2Falerts-unified-log%23log-search-alert-rule---definition-and-types%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Fplatform%2Falerts-unified-log%23log-search-alert-rule%E2%80%94definition-and-types%3C%2FA%3E%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%2F126206i46D3CD2873D35396%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%3CH2%20id%3D%22toc-hId--755966342%22%20id%3D%22toc-hId--755966342%22%3E2%20%E2%80%93%20ACTION%20GROUPS%3C%2FH2%3E%0A%3CP%3E%3CSTRONG%3EActions%20group%3C%2FSTRONG%3E%26nbsp%3Bdefine%20what%20are%20you%20going%20to%20do%20if%20the%20condition%20above%20is%20true.%20You%20can%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CFONT%20size%3D%222%22%3ESend%20an%20email%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%222%22%3ESend%20an%20SMS%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%222%22%3EPush%20a%20notification%20to%20Azure%20App%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%222%22%3EReceive%20a%20call%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%222%22%3EOr%20you%20can%20do%20some%20automation%2C%20using%20a%26nbsp%3B%3CSTRONG%3Erunbook%3C%2FSTRONG%3Eon%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsql-database%2Fsql-database-manage-automation%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSTRONG%3EAutomation%20accounts%3C%2FSTRONG%3E%3C%2FA%3E%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%222%22%3ECall%26nbsp%3B%3CSTRONG%3EAzure%20Functions%3C%2FSTRONG%3E%2F%26nbsp%3B%3CSTRONG%3ELogic%20Apps%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%222%22%3E%3CSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Fplatform%2Falerts-log-webhook%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EWebhook%3C%2FA%3E%26nbsp%3B%3C%2FSTRONG%3Eactions%20allow%20you%20to%20invoke%20an%20external%20process%20through%20a%20single%20HTTP%20POST%20request.%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%222%22%3E%3CSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fblog%2Fsend-your-azure-alerts-to-itsm-tools-using-action-groups%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EITSM%3C%2FA%3E%3C%2FSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fblog%2Fsend-your-azure-alerts-to-itsm-tools-using-action-groups%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E(IT%20Service%20Management)%20action%3C%2FA%3E%26nbsp%3Bwill%20allow%20users%20to%20create%20a%20work%20item%20in%20the%20connected%20ITSM%20tool%20when%20an%20alert%20is%20fired.%3C%2FFONT%3E%3C%2FLI%3E%0A%3C%2FUL%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%2F126204iF49C74A5C4A796CB%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22clipboard_image_4.png%22%20title%3D%22clipboard_image_4.png%22%20%2F%3E%3C%2FSPAN%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%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F126205i2701CC4129C92FF2%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22clipboard_image_5.png%22%20title%3D%22clipboard_image_5.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EIn%20this%20sample%20I%20will%20send%20and%20email%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%2F126207i9F5712B0BF8EC220%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22clipboard_image_6.png%22%20title%3D%22clipboard_image_6.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EYou%20can%20also%20customize%26nbsp%3B%3CSTRONG%3ESubject%20Line%3C%2FSTRONG%3E%26nbsp%3Band%20customize%20the%20JSON%20payload%20for%26nbsp%3B%3CSTRONG%3Ewebhook%26nbsp%3B%3C%2FSTRONG%3Eif%20that%20was%20the%20case%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%2F126208i920A3F5FDABE31F0%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22clipboard_image_7.png%22%20title%3D%22clipboard_image_7.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3EAt%20end%20you%20can%20set%20the%26nbsp%3B%3CSTRONG%3Ealert%20severity%3C%2FSTRONG%3E%2C%20and%26nbsp%3B%3CSTRONG%3Esuppress%20alert%20config%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EAlert%20severity%3C%2FSTRONG%3E%E2%80%93%20For%20this%20test%20I%E2%80%99ve%20used%26nbsp%3B%3CSTRONG%3ESev%202%20Informational%26nbsp%3B%3C%2FSTRONG%3Efor%20my%20scenario%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ESuppress%20alert%20config%3C%2FSTRONG%3E%E2%80%93%20If%20you%20don%E2%80%99t%20want%20the%20alert%20to%20be%20a%20SPAM%20on%20your%20mailbox%2C%20change%20the%20period%20here%3C%2FLI%3E%0A%3C%2FUL%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%2F126209i77060E6A20C12A06%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22clipboard_image_8.png%22%20title%3D%22clipboard_image_8.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-986843993%22%20id%3D%22toc-hId-986843993%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId--1565312968%22%20id%3D%22toc-hId--1565312968%22%3E3%20%E2%80%93%20ALERT%20EMAIL%3C%2FH2%3E%0A%3CP%3EFor%20this%20test%20I%20just%20set%20parameters%3A%26nbsp%3B%3CSTRONG%3EPeriod%2030%20min%2C%20frequency%205%20min%20and%20Suppress%20alerts%2030%20min%3C%2FSTRONG%3E.Find%20below%20the%20email%20that%20I%20have%20received%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%2F126210i55E29F2DA5256B39%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_9.png%22%20title%3D%22clipboard_image_9.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EOn%20this%20tests%20we%20can%20see%202%20errors%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CEM%3E18456%20%2F%208%20%3D%20Login%20failed%20for%20user%20%E2%80%98%25.*ls%E2%80%99.%25.*ls%20%2F%20The%20password%20is%20incorrect.%3C%2FEM%3E%3C%2FLI%3E%0A%3CLI%3E%3CEM%3E18456%20%2F%205%20%3D%20Login%20failed%20for%20user%20%E2%80%98%25.*ls%E2%80%99.%25.*ls%20%2F%20User%20ID%20is%20not%20valid.%3C%2FEM%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EREF%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Ferrors-events%2Fmssqlserver-18456-database-engine-error%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Ferrors-events%2Fmssqlserver-18456-database-engine-error%3C%2FA%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-177497367%22%20id%3D%22toc-hId-177497367%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-1920307702%22%20id%3D%22toc-hId-1920307702%22%3E4%20%E2%80%93%20ALERTS%20IN%20PORTAL%3C%2FH2%3E%0A%3CP%3EIf%20you%20go%20to%20the%26nbsp%3B%3CSTRONG%3EPortal%26nbsp%3B%3C%2FSTRONG%3E%26gt%3B%26nbsp%3B%3CSTRONG%3EMonitor%3C%2FSTRONG%3E%26nbsp%3B%26gt%3B%26nbsp%3B%3CSTRONG%3EAlerts%3C%2FSTRONG%3E%2C%20you%20are%20going%20to%20see%20some%20alerts%20fired%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%2F126211i335789324E1A06E5%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_10.png%22%20title%3D%22clipboard_image_10.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EYou%20can%20see%20that%20the%20way%20I%20configured%2C%20I%20was%20alerted%20during%2030%20min%2C%20every%205%20min%20%3D%26nbsp%3B%3CSTRONG%3E6%20alerts%3C%2FSTRONG%3E.%20However%20I%20just%20received%26nbsp%3B%3CSTRONG%3E1%20email%3C%2FSTRONG%3E%26nbsp%3Bbecause%20I%20had%20the%20option%20to%20suppress%20the%20email%20(Only%20will%20send%20me%20an%20alert%20email%20after%2030%20min%20of%20the%20first%20one)%3C%2FP%3E%0A%3CP%3ENo%20other%20failed%20connection%20error%20happened%20after%20that%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%2F126212iCA49B897E7F70A39%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_11.png%22%20title%3D%22clipboard_image_11.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EYou%20can%20review%20the%20alert%20details%2C%20and%20check%20the%20data%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%2F126215i66A6C663C624C0B5%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_12.png%22%20title%3D%22clipboard_image_12.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EAfter%20reviewing%20this%20alerts%20you%20can%20cleanup%20them%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%2F126214iDF32839560A992F2%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_13.png%22%20title%3D%22clipboard_image_13.png%22%20%2F%3E%3C%2FSPAN%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%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F126213iC0F2A6919E9FA596%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_14.png%22%20title%3D%22clipboard_image_14.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPost%20originally%20from%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ffonsecasergio.wordpress.com%2F2019%2F03%2F31%2Fazure-sql-db-and-log-analytics-better-together-part-2-alerts%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Ffonsecasergio.wordpress.com%2F2019%2F03%2F31%2Fazure-sql-db-and-log-analytics-better-together-part-2-alerts%2F%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-795360%22%20slang%3D%22en-US%22%3E%3CP%3EAs%20you%20could%20see%20on%20previous%20post%20(%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Database-Support-Blog%2FAZURE-SQL-DB-AND-LOG-ANALYTICS-BETTER-TOGETHER-PART-1%2Fba-p%2F794833%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3EAZURE%20SQL%20DB%20AND%20LOG%20ANALYTICS%20BETTER%20TOGETHER%20%E2%80%93%20PART%26nbsp%3B%231%3C%2FA%3E)%20using%20Azure%20SQL%20DB%20%2B%20Log%20Analytics%20is%20quite%20easy.%3C%2FP%3E%0A%3CP%3ELet%20see%20how%20can%20we%20improve%20even%20further%20with%26nbsp%3B%3CSTRONG%3EALERTS%3C%2FSTRONG%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-795360%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20SQL%20DB%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

As you could see on previous post (AZURE SQL DB AND LOG ANALYTICS BETTER TOGETHER – PART #1) using Azure SQL DB + Log Analytics is quite easy.

Let see how can we improve even further with ALERTS

 

Let’s imagine I want to receive everyday a list of all failed logins to be reviewed

 

I will reuse a query from last post to get failed logins, and I will just change parameter of time to filter failed logins on last 1 day

 

 

 

//Failed Logins
AzureDiagnostics
| where TimeGenerated >= ago(1d) //Events on last 1 days
| where action_name_s == "DATABASE AUTHENTICATION FAILED"
| extend additional_information_xml=parse_xml(additional_information_s)
| extend Error_Code=additional_information_xml.login_information.error_code
| extend Error_State=additional_information_xml.login_information.error_state
| project
    TimeGenerated, event_time_t,
    ResourceGroup, LogicalServerName_s, database_name_s,
    session_id_d, client_ip_s, application_name_s, session_server_principal_name_s,
    Error_Code, Error_State
| order by TimeGenerated desc

 

 

 

You can see that at this moment I don’t have any error (0 records).

 

To create an Alert based on a query, just click on New alert rule

clipboard_image_0.png

1 – CONDITIONS

Resource is already filled with LogAnalytics

Now we need to define in which condition it will fire. Just click on CONDITION

clipboard_image_1.png

You can see the search query was prepopulated, you just need to set threshold value, period and frequency. 

clipboard_image_2.png

Time Period. Specifies the time range for the query. The query returns only records that were created within this range of the current time. Time period restricts the data fetched for log query to prevent abuse and circumvents any time command (like ago) used in log query. 
For example, If the time period is set to 60 minutes, and the query is run at 1:15 PM, only records created between 12:15 PM and 1:15 PM is returned to execute log query. Now if the log query uses time command like ago (7d), the log query would be run only for data between 12:15 PM and 1:15 PM – as if data exists for only the past 60 minutes. And not for seven days of data as specified in log query.


Frequency. Specifies how often the query should be run. Can be any value between 5 minutes and 24 hours. Should be equal to or less than the time period. If the value is greater than the time period, then you risk records being missed.
For example, consider a time period of 30 minutes and a frequency of 60 minutes. If the query is run at 1:00, it returns records between 12:30 and 1:00 PM. The next time the query would run is 2:00 when it would return records between 1:30 and 2:00. Any records created between 1:00 and 1:30 would never be evaluated.


Threshold. The results of the log search are evaluated to determine whether an alert should be created. The threshold is different for the different types of log search alert rules.

REF: https://docs.microsoft.com/en-us/azure/azure-monitor/platform/alerts-unified-log#log-search-alert-ru...

clipboard_image_3.png

2 – ACTION GROUPS

Actions group define what are you going to do if the condition above is true. You can:

  • Send an email
  • Send an SMS
  • Push a notification to Azure App
  • Receive a call
  • Or you can do some automation, using a runbookon Automation accounts
  • Call Azure FunctionsLogic Apps
  • Webhook actions allow you to invoke an external process through a single HTTP POST request.
  • ITSM(IT Service Management) action will allow users to create a work item in the connected ITSM tool when an alert is fired.

clipboard_image_4.png

 

clipboard_image_5.png

In this sample I will send and email

clipboard_image_6.png

You can also customize Subject Line and customize the JSON payload for webhook if that was the case

clipboard_image_7.png


At end you can set the alert severity, and suppress alert config

  • Alert severity– For this test I’ve used Sev 2 Informational for my scenario
  • Suppress alert config– If you don’t want the alert to be a SPAM on your mailbox, change the period here

clipboard_image_8.png

 

3 – ALERT EMAIL

For this test I just set parameters: Period 30 min, frequency 5 min and Suppress alerts 30 min.Find below the email that I have received

clipboard_image_9.png

On this tests we can see 2 errors

  • 18456 / 8 = Login failed for user ‘%.*ls’.%.*ls / The password is incorrect.
  • 18456 / 5 = Login failed for user ‘%.*ls’.%.*ls / User ID is not valid.

REF: https://docs.microsoft.com/en-us/sql/relational-databases/errors-events/mssqlserver-18456-database-e...

 

4 – ALERTS IN PORTAL

If you go to the Portal Monitor > Alerts, you are going to see some alerts fired

clipboard_image_10.png

You can see that the way I configured, I was alerted during 30 min, every 5 min = 6 alerts. However I just received 1 email because I had the option to suppress the email (Only will send me an alert email after 30 min of the first one)

No other failed connection error happened after that

clipboard_image_11.png

You can review the alert details, and check the data

clipboard_image_12.png

After reviewing this alerts you can cleanup them

clipboard_image_13.png

 

clipboard_image_14.png

 

Post originally from https://fonsecasergio.wordpress.com/2019/03/31/azure-sql-db-and-log-analytics-better-together-part-2...