Azure Monitor

How to Create a Custom Workbook

Azure Monitor is a powerful tool for understanding the performance and availability of an organisation’s applications and services. The Workbooks feature enables monitoring data to be visualised and the supplied sample templates are extremely useful. However, designing your own workbook really exploits the power of Azure Monitor and this blog shows you how to create a basic one for displaying virtual machine information.

Start by creating and saving a new workbook. Remember to keep saving regularly during development.

  • Log on to the Azure portal and navigate to Azure Monitor
  • Select Workbooks and click New
  • Click the Save icon, complete the details and click Apply.

Create parameters to allow the user to choose which subscriptions the data is queried from

  • Click Add and Add Parameter
  • Enter:
    • Parameter name = Subscriptions
    • Parameter type = Subscription picker
    • Required = Yes
    • Allow multiple selections = Yes
    • Get data from = All subscriptions
    • Include in the drop-down = All
  • Click Save and Done Editing at the bottom of the parameter pane

Now, add a query from Azure Resource Graph (ARG) using the selected subscriptions. ARG provides programmatic access to query resources in Azure. Data can be retrieved from a variety of sources, including the ARG.

  • Click Add and Add query
  • Select a Data source of Azure Resource Graph
  • Select Resource Parameters / Subscriptions from the subscriptions drop-down to use the subscriptions selected by the user
  • Click Size of Small. Experiment with how different sizes present data on the screen.
  • Enter a query of:

Resources

| where type =~ ‘Microsoft.Compute/virtualMachines’ 

| extend State = properties.extended.instanceView.powerState.code

| extend PowerHealth = iff((State == ‘PowerState/running’), “Active”, “Inactive”)

| extend Location = location

| extend ResourceGroup = resourceGroup

| extend Size = properties.hardwareProfile.vmSize

| extend Publisher = properties.storageProfile.imageReference.publisher

| extend Sku = properties.storageProfile.imageReference.sku

| extend Offer = properties.storageProfile.imageReference.offer

| extend OS2 = properties.extended.instanceView.osName| extend osDiskId= tolower(properties.storageProfile.osDisk.managedDisk.id)

    | join(

        resources

        | where type =~ ‘microsoft.compute/disks’

        | where properties !has ‘Unattached’

        | where properties has ‘osType’

        | project OS1 = tostring(properties.osType), osSku = tostring(sku.name), osDiskSizeGB = toint(properties.diskSizeGB), osDiskId=tolower(id))

    on osDiskId

| project Computer = name, PowerHealth, Location, ResourceGroup, Size, Publisher, Sku, Offer, OS1, OS2

  • Click Done Editing on the query pane
  • Click Done Editing and the Save icon

The custom workbook now allows the user to display virtual machine information from selected subscriptions.

You can develop similar workbooks based on e.g. Heartbeat data from Log Analytics workspaces and even merge queries from different data sources to combine information from each.

About the author