{"id":326,"date":"2018-07-31T21:20:54","date_gmt":"2018-08-01T03:20:54","guid":{"rendered":"http:\/\/draith.com\/?p=326"},"modified":"2018-07-31T21:20:54","modified_gmt":"2018-08-01T03:20:54","slug":"custom-log-analytics-logging-with-logic-apps","status":"publish","type":"post","link":"https:\/\/draith.com\/?p=326","title":{"rendered":"Custom Log Analytics logging with Logic Apps!"},"content":{"rendered":"<p>Here is a quick demo on sending a simple API to Log Analytics using Logic Apps.  It used to be quite a pain to get data to Log Analytics &#8211; using an API, sending via something like an Azure Function, Azure Automation Runbook, PowerShell scripts, etc&#8230;  Now, you can do it in about 3 minutes with no code!<\/p>\n<p>First &#8211; some assumptions:<br \/>\n1:  You have a Log Analytics workspace already set in Azure.  See <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/log-analytics\/log-analytics-quick-create-workspace\" rel=\"noopener noreferrer\" target=\"_blank\">this article<\/a> if you need help with that.<br \/>\n2:  Actually, there is no 2.  Just make sure you have a Log Analytics workspace.<\/p>\n<p>Create a Logic Apps&#8230;.App.  That naming convention seems wrong.  <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/draith.com\/wp-content\/uploads\/2018\/07\/LA-new.png\" alt=\"\" width=\"625\" height=\"785\" class=\"alignnone size-full wp-image-327\" srcset=\"\/wp-content\/uploads\/2018\/07\/LA-new.png 625w, \/wp-content\/uploads\/2018\/07\/LA-new-239x300.png 239w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>It will take a few seconds for the app to be created.  When it is, enter the designer.  In this example, we are going to retrieve a simple piece of data via a web API &#8211; we are going to get a current stock quote from IEXTrading.com.  For those that don&#8217;t know, IEXTrading has an AMAZING web API for pulling stock data.  Seriously &#8211; check it out:  <a href=\"https:\/\/iextrading.com\/developer\/docs\/\" rel=\"noopener noreferrer\" target=\"_blank\">https:\/\/iextrading.com\/developer\/docs\/<\/a><\/p>\n<p>In this example we will setup a simple 15 minute timer, pull the data from IEXTrading, take the JSON payload from the API call, and send that to Log Analytics.  It&#8217;s actually really easy.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/draith.com\/wp-content\/uploads\/2018\/07\/LA-App.png\" alt=\"\" width=\"926\" height=\"1004\" class=\"alignnone size-full wp-image-328\" srcset=\"\/wp-content\/uploads\/2018\/07\/LA-App.png 926w, \/wp-content\/uploads\/2018\/07\/LA-App-277x300.png 277w, \/wp-content\/uploads\/2018\/07\/LA-App-768x833.png 768w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/p>\n<p>If you haven&#8217;t setup a Log Analytics connection in Logic Apps, then there are a couple of pieces of information from Log Analytics you are going to need.  Go into your Log Analytics workspace, click on the &#8216;Advanced Settings&#8217; section and copy down the &#8220;Workspace ID&#8221; and either the &#8220;Primary&#8221; or &#8220;Secondary&#8221; key.  Enter those into the connection information for the Logic Apps Connector.  I&#8217;ve shown you mine here:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/draith.com\/wp-content\/uploads\/2018\/07\/LA-LACon.png\" alt=\"\" width=\"957\" height=\"627\" class=\"alignnone size-full wp-image-330\" srcset=\"\/wp-content\/uploads\/2018\/07\/LA-LACon.png 957w, \/wp-content\/uploads\/2018\/07\/LA-LACon-300x197.png 300w, \/wp-content\/uploads\/2018\/07\/LA-LACon-768x503.png 768w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/p>\n<p>Now &#8211; just let it run!  It might fail for the first couple of runs &#8211; I believe this has something to do with the creation of the custom log in Log Analytics.  After a (short) period of time, you can query for your custom log in Log Analytics.  The one thing you should know is that the log name you specified in Logic Apps will be appended with &#8220;_CL&#8221;.  That stands for Custom Log, and it will show up if you want it to or not.  You can search for you log like this:<\/p>\n<pre class=\"lang:default decode:true \" >search *\n| where Type == \"Stock_Prices_CL\"<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/draith.com\/wp-content\/uploads\/2018\/07\/LA-LAData-1.png\" alt=\"\" width=\"3491\" height=\"1199\" class=\"alignnone size-full wp-image-334\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is a quick demo on sending a simple API to Log Analytics using Logic Apps. It used to be quite a pain to get data to Log Analytics &#8211; using an API, sending via something like an Azure Function, Azure Automation Runbook, PowerShell scripts, etc&#8230; Now, you can do it in about 3 minutes &hellip; <a href=\"https:\/\/draith.com\/?p=326\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Custom Log Analytics logging with Logic Apps!&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[13],"class_list":["post-326","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-logic-apps"],"_links":{"self":[{"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/posts\/326","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/draith.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=326"}],"version-history":[{"count":0,"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/posts\/326\/revisions"}],"wp:attachment":[{"href":"https:\/\/draith.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/draith.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/draith.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}