{"id":91912,"date":"2021-07-26T17:00:26","date_gmt":"2021-07-26T17:00:26","guid":{"rendered":"https:\/\/www.red-gate.com\/simple-talk\/?p=91912"},"modified":"2021-07-20T19:01:00","modified_gmt":"2021-07-20T19:01:00","slug":"azure-data-studio-kql-extension","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/blogs\/azure-data-studio-kql-extension\/","title":{"rendered":"Log Analytics and Azure Data Studio: New Extension"},"content":{"rendered":"<p>You need to dig into old blogs I wrote before to fully understand how interesting this new extension is.<\/p>\n<p>On <a href=\"https:\/\/www.red-gate.com\/simple-talk\/blogs\/saving-money-log-analytics\/\">Saving Money with Log Analytics<\/a>\u00a0I mentioned how important log analytics is for azure clouds. This deserves more in depth analysis, which probably will be broken down in blog articles.<\/p>\n<p>\nOn <a href=\"https:\/\/www.red-gate.com\/simple-talk\/blogs\/connecting-log-analytics-using-azure-data-studio-kql\/\">Connecting to Log Analytics using Azure Data Studio and KQL<\/a>\u00a0 I introduced a solution to make Log Analytic queries in Python notebooks using <strong>Azure Data Studio<\/strong>. Comparing to the new feature I&#8217;m about to show this will seems like something from stone age.<\/p>\n<p>On <a href=\"https:\/\/www.red-gate.com\/simple-talk\/blogs\/using-log-analytics-to-connect-to-power-bi\/\">Using Power BI to Query Log Analytics<\/a>\u00a0 I made demonstrations with <strong>Power BI<\/strong>, bringing log analysis to another level.<\/p>\n<p><strong>The news:<\/strong> A new extension is in preview to allow connecting <strong>Azure Data Studio<\/strong> to <strong>Log Analytics<\/strong> as if you were connecting to a <strong>SQL<\/strong> database.<\/p>\n<p>The extension is in preview, so you need to install it on Azure Data Studio Insiders version, which brings preview features in advance for us. If you are lost in space and don&#8217;t have the Insiders version installed yet, <a href=\"https:\/\/t.co\/GYt8p8CFRP?amp=1\">you can get it here<\/a>\u00a0<\/p>\n<p>Once you installed <strong>Azure Data Studio Insiders<\/strong>, let&#8217;s follow the steps you need to start querying <strong>Azure Log Analytics<\/strong>.<\/p>\n<h2>Install the Extension<\/h2>\n<p style=\"padding-left: 30px\">This is easy and with no mystery: Use the extensions tab, look for <strong>Azure Monitor Log<\/strong> extension and install it.<\/p>\n<p style=\"padding-left: 30px\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-91913\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/07\/ADSLog01.png\" alt=\"\" width=\"606\" height=\"212\" \/><\/p>\n<h2>Create a Connection<\/h2>\n<p style=\"padding-left: 30px\">The regular <strong>Create Connection<\/strong> window has one additional option, <strong>Azure Monitor Logs<\/strong>. We will need to fill some specific log analytics details:<\/p>\n<p style=\"padding-left: 30px\"><strong>Connection Type:<\/strong> Azure Monitor Logs<br \/>\n<strong>Workspace Id:<\/strong> You can find this information on your Azure portal, on your Log Analytics workspace.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-91939\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/07\/ADSLog09.png\" alt=\"\" width=\"324\" height=\"180\" \/>\u00a0<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-91940\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/07\/ADSLog10.png\" alt=\"\" width=\"562\" height=\"88\" \/><\/p>\n<p style=\"padding-left: 30px\">\n<strong>Authentication:<\/strong> You will need to authenticate against the Active Directory where your Log Analytics is. You will need to provide an account and Azure AD Tenant and the authentication will be made using this account<br \/>\n<strong>Database:<\/strong>\u00a0There is only one option. It will only be filled after you provide the authentication<br \/>\n<strong>Server Group:<\/strong> This is an ADS detail about how you organize your connections. You can create a group for all your log analytics connections.<br \/>\n<strong>Name<\/strong>: the name of this connection on the UI<\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-91914\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/07\/ADSLog02.png\" alt=\"\" width=\"621\" height=\"444\" \/><\/p>\n<h2>\nLook Around<\/h2>\n<p style=\"padding-left: 30px\">Take a look around and check the result of your connection.<\/p>\n<ul>\n<li>In the <strong>Connections<\/strong> panel you are able to navigate the tables inside log analytics down to the level of fields. Only a few tables are shared across many services, while others are specific to one azure service.<\/li>\n<\/ul>\n<p style=\"padding-left: 30px\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-91915\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/07\/ADSLog03.png\" alt=\"\" width=\"616\" height=\"602\" \/><\/p>\n<ul>\n<li>Right click the log analytics connection in the <strong>Connections<\/strong> panel and select <strong>Manage<\/strong>. The tab that will open will show you the tables once again, but here you have the option to create a new query or a new notebook.<\/li>\n<\/ul>\n<p style=\"padding-left: 30px\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-91919\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/07\/ADSLog07.png\" alt=\"\" width=\"398\" height=\"306\" \/><\/p>\n<p style=\"padding-left: 30px\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-91916\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/07\/ADSLog04.png\" alt=\"\" width=\"1280\" height=\"598\" \/><\/p>\n<h2>\nCreating a new Notebook<\/h2>\n<p style=\"padding-left: 30px\">Once you created a new Notebook, it will be connected to your <strong>Log Analytics<\/strong>. The kernel will be <strong>Log Analytics<\/strong> and not <strong>Kusto<\/strong>. Yes, I know <strong>Kusto<\/strong> is the <strong>Log Analytics<\/strong> language, but <strong>Azure Data Explorer<\/strong> already uses\u00a0<strong>Kusto<\/strong>\u00a0as Kernel<b>. <\/b>The kernel needs to be <strong>Log Analytics<\/strong>.<\/p>\n<p style=\"padding-left: 30px\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-91917\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/07\/ADSLog05.png\" alt=\"\" width=\"707\" height=\"47\" \/><\/p>\n<p style=\"padding-left: 30px\">The notebook provides intellisense while you type your query, but doesn&#8217;t provide coloring options for the statements yet, the entire query is black, a boring black.<\/p>\n<p style=\"padding-left: 30px\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-91918\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/07\/ADSLog06.png\" alt=\"\" width=\"748\" height=\"339\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px\">As we would expect from an <strong>ADS<\/strong> notebook, we can create graphics from the query results. For example, this is a graphic of weekly access on a website, by day of week:<\/p>\n<p style=\"padding-left: 30px\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-91920\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/07\/ADSLog08.png\" alt=\"\" width=\"820\" height=\"720\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 30px\">The graphics in a notebook are not the same as a <strong>Log Analytics<\/strong> workbook. In order to achieve this line graphic I had to include a <strong>PIVOT<\/strong> function on the query, otherwise the graphic would not show this data, while on the workbook we could configure for this data.<\/p>\n<p style=\"padding-left: 30px\">Without the <strong>PIVOT<\/strong> function, this would be the result of the query:<\/p>\n<p style=\"padding-left: 30px\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-91944\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/07\/ADSLog14.png\" alt=\"\" width=\"418\" height=\"314\" \/><\/p>\n<p style=\"padding-left: 30px\">\u00a0<\/p>\n<p style=\"padding-left: 30px\">Using the <strong>EVALUATE<\/strong> statement and the <strong>PIVOT<\/strong> function, we turn the content of the column Day into columns, allowing us to create the line graphic above:<\/p>\n<p style=\"padding-left: 30px\">\u00a0<\/p>\n<p style=\"padding-left: 30px\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-91943\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/07\/ADSLog13.png\" alt=\"\" width=\"781\" height=\"411\" \/><\/p>\n<h2>\nSmall Pending Problems<\/h2>\n<ul>\n<li>The Azure Connection is lost from time to time. We need to refresh the connection. On the notebook, we can use the <strong>Change Connection<\/strong> for that. On the Connections panel, we can disconnect and connect again.<\/li>\n<\/ul>\n<p style=\"padding-left: 30px\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-91941\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/07\/ADSLog11.png\" alt=\"\" width=\"291\" height=\"105\" \/><\/p>\n<ul>\n<li>The code doesn&#8217;t use any different color for the statements<\/li>\n<li>The graphic features on a notebook may be more difficult to handle than on log analytics workbook. However, I don&#8217;t think this is really an issue, it&#8217;s more about different usages of the tools.<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p style=\"padding-left: 30px\">Each day we get new tools to access Log Analytics, increasing the importance of this great tool for Azure Clouds.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You need to dig into old blogs I wrote before to fully understand how interesting this new extension is. On Saving Money with Log Analytics\u00a0I mentioned how important log analytics is for azure clouds. This deserves more in depth analysis, which probably will be broken down in blog articles. On Connecting to Log Analytics using&#8230;&hellip;<\/p>\n","protected":false},"author":50808,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[145424,126250,126249,143562],"coauthors":[6810],"class_list":["post-91912","post","type-post","status-publish","format-standard","hentry","category-blogs","tag-azure-data-studio","tag-kql","tag-kusto","tag-log-analytics"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/91912","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/50808"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=91912"}],"version-history":[{"count":6,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/91912\/revisions"}],"predecessor-version":[{"id":92021,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/91912\/revisions\/92021"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=91912"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=91912"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=91912"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=91912"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}