{"id":4500,"date":"2019-01-25T16:30:11","date_gmt":"2019-01-25T15:30:11","guid":{"rendered":"http:\/\/contoso.se\/blog\/?p=4500"},"modified":"2019-01-25T16:31:15","modified_gmt":"2019-01-25T15:31:15","slug":"building-reports-with-log-analytics-data","status":"publish","type":"post","link":"http:\/\/contoso.se\/blog\/?p=4500","title":{"rendered":"Building reports with Log Analytics data"},"content":{"rendered":"\n<p>A common question I see is how to present the data collected with Log Analytics. We can use View Designer in Log Analytics, PowerBI, Azure Dashboard, and Excel PowerPivot. But in this blog post, I would like to show another way to build a \u00e2\u20ac\u0153report\u00e2\u20ac\u009d direct in the Azure Portal for Log Analytics data.<\/p>\n\n\n\n<p>Workbooks is a feature in Application Insights to build interactive reports. Workbooks are configured under Application Insights but it\u00e2\u20ac\u2122s possible to access data from Log Analytics. <\/p>\n\n\n\n<p>In this example, we will build a workbook for failed logins in Active Directory. The source data (event Id 4625) is collected by the Security and Audit solution in Log Analytics. <\/p>\n\n\n\n<p>If we run a query in Log Analytics to show these events, we can easily see failed login reason and number of events. But we would also like to drill down into these events and see account names. That is not possible in Log Analytics today, and this is where workbooks can bring value.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/01.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"838\" height=\"706\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/01.jpg\" alt=\"\" class=\"wp-image-4502\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/01.jpg 838w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/01-300x253.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/01-768x647.jpg 768w\" sizes=\"(max-width: 838px) 100vw, 838px\" \/><\/a><\/figure>\n\n\n\n<p>Any Application Insights instance can be used; no data needs to be collected by the instance (no extra cost) as we will use Log Analytics as a data source. In Application Insights, there are some default workbooks and quick start templates. For this example, we will use the \u00e2\u20ac\u0153Default Template.\u00e2\u20ac\u009d<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/02.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"740\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/02-1024x740.jpg\" alt=\"\" class=\"wp-image-4503\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/02-1024x740.jpg 1024w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/02-300x217.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/02-768x555.jpg 768w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/02.jpg 1044w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>In the workbook, we can configure it to use any Log Analytics workspace, in any subscription, as a source.  Using different workspaces for different parts of the workbook is possible. The query used in this example is shown below, note it shows data for the last 30 days.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>SecurityEvent<br \/> | where AccountType == &#8216;User&#8217; and EventID == 4625<br \/> | where TimeGenerated &gt; ago(30d) <br \/> | extend Reason = case(<br \/>     SubStatus == &#8216;0xc000005e&#8217;, &#8216;No logon servers available to service the logon request&#8217;,<br \/>     SubStatus == &#8216;0xc0000062&#8217;, &#8216;Account name is not properly formatted&#8217;,<br \/>     SubStatus == &#8216;0xc0000064&#8217;, &#8216;Account name does not exist&#8217;,<br \/>     SubStatus == &#8216;0xc000006a&#8217;, &#8216;Incorrect password&#8217;,<br \/>     SubStatus == &#8216;0xc000006d&#8217;, &#8216;Bad user name or password&#8217;,<br \/>     SubStatus == &#8216;0xc000006f&#8217;, &#8216;User logon blocked by account restriction&#8217;,<br \/>     SubStatus == &#8216;0xc000006f&#8217;, &#8216;User logon outside of restricted logon hours&#8217;,<br \/>     SubStatus == &#8216;0xc0000070&#8217;, &#8216;User logon blocked by workstation restriction&#8217;,<br \/>     SubStatus == &#8216;0xc0000071&#8217;, &#8216;Password has expired&#8217;,<br \/>     SubStatus == &#8216;0xc0000072&#8217;, &#8216;Account is disabled&#8217;,<br \/>     SubStatus == &#8216;0xc0000133&#8217;, &#8216;Clocks between DC and other computer too far out of sync&#8217;,<br \/>     SubStatus == &#8216;0xc000015b&#8217;, &#8216;The user has not been granted the requested logon right at this machine&#8217;,<br \/>     SubStatus == &#8216;0xc0000193&#8217;, &#8216;Account has expirated&#8217;,<br \/>     SubStatus == &#8216;0xc0000224&#8217;, &#8216;User is required to change password at next logon&#8217;,<br \/>     SubStatus == &#8216;0xc0000234&#8217;, &#8216;Account is currently locked out&#8217;,<br \/>     strcat(&#8216;Unknown reason substatus: &#8216;, SubStatus))<br \/> | project TimeGenerated, Account, Reason, Computer<\/p><\/blockquote>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/03.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"432\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/03-1024x432.jpg\" alt=\"\" class=\"wp-image-4504\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/03-1024x432.jpg 1024w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/03-300x127.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/03-768x324.jpg 768w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/03.jpg 1106w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>In the workbook, on Column Settings, we can configure how the result will be grouped together. In this example, we will group by failed login reason and then account name. <\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/04.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"488\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/04-1024x488.jpg\" alt=\"\" class=\"wp-image-4505\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/04-1024x488.jpg 1024w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/04-300x143.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/04-768x366.jpg 768w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/04.jpg 1473w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/07.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"695\" height=\"555\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/07.jpg\" alt=\"\" class=\"wp-image-4509\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/07.jpg 695w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/07-300x240.jpg 300w\" sizes=\"(max-width: 695px) 100vw, 695px\" \/><\/a><\/figure>\n\n\n\n<p>When running the workbook, we get a list of failed login reasons and can expand to see account names and amount of failed logins. It is possible to add an extra filter to the query to remove \u00e2\u20ac\u0153noise\u00e2\u20ac\u009d for example accounts with less than three failed login events. <br \/>It is also possible to pin a workbook or part of a workbook, to an Azure Dashboard, to easily access the information.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"572\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/05-1024x572.jpg\" alt=\"\" class=\"wp-image-4506\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/05-1024x572.jpg 1024w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/05-300x168.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/05-768x429.jpg 768w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/05.jpg 1258w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In the <g class=\"gr_ gr_5 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation only-ins replaceWithoutSep\" id=\"5\" data-gr-id=\"5\">workbook<\/g> you can also add more text fields, metric fields <g class=\"gr_ gr_6 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation only-ins replaceWithoutSep\" id=\"6\" data-gr-id=\"6\">and<\/g> query fields, for <g class=\"gr_ gr_4 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation only-ins replaceWithoutSep\" id=\"4\" data-gr-id=\"4\">example<\/g> a time chart showing the <g class=\"gr_ gr_3 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace\" id=\"3\" data-gr-id=\"3\">amount<\/g> of events per day.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/06.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"442\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/06-1024x442.jpg\" alt=\"\" class=\"wp-image-4507\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/06-1024x442.jpg 1024w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/06-300x130.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2019\/01\/06-768x332.jpg 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>A common question I see is how to present the data collected with Log Analytics. We can use View Designer in Log Analytics, PowerBI, Azure Dashboard, and Excel PowerPivot. But in this blog post, I would like to show another way to build a \u00e2\u20ac\u0153report\u00e2\u20ac\u009d direct in the Azure Portal for Log Analytics data. Workbooks &hellip; <a href=\"http:\/\/contoso.se\/blog\/?p=4500\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":4503,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[64,71],"tags":[],"_links":{"self":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4500"}],"collection":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4500"}],"version-history":[{"count":5,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4500\/revisions"}],"predecessor-version":[{"id":4512,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4500\/revisions\/4512"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/media\/4503"}],"wp:attachment":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4500"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4500"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4500"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}