Log analytics query

This post will show you how you can create a URL to a specific Log Analytics query. When navigated to, this URL will automatically open the Log Analytics Query editor, input your query, and execute it. This URL can be embedded in your custom alerting solutions, used to create a bookmark for queries, or anything else you can think of. All you need to get started is a Log Analytics Workspace and a little bit of PowerShell.

The PowerShell functions you need can be downloaded from my GitHub Gist. To execute it you need to get your Log Analytics Workspace name and the Subscription GUID and Resource Group that contains your workspace. To find these values, you can navigate to your Log Analytics Workspace in the Azure Portal, and copy then from the Overview blade.

Log analytics query

Once you have this information you simply need to call the Write-LogAnalyticsURL function to create your link. I have provided a couple of examples below.

 

The most recent version of this script, and many more scripts are available on my GitHub Gist. For more info, please contact us here.