Back to Blog
3 min read

Azure Monitor Workbooks: Custom Visualizations

Azure Monitor Workbooks create interactive reports from your monitoring data. Combine metrics, logs, and Azure Resource Graph in rich visualizations.

Workbook Components

  • Text: Markdown documentation
  • Query: KQL, metrics, ARG
  • Parameters: Interactive filters
  • Charts: Line, bar, pie, scatter
  • Grids: Tabular data
  • Tiles: Single values
  • Maps: Geographic visualization

Creating a Workbook

{
    "version": "Notebook/1.0",
    "items": [
        {
            "type": 1,
            "content": {
                "json": "# Infrastructure Dashboard\nMonitor your Azure resources"
            }
        },
        {
            "type": 9,
            "content": {
                "version": "KqlParameterItem/1.0",
                "parameters": [
                    {
                        "name": "TimeRange",
                        "type": 4,
                        "value": { "durationMs": 3600000 }
                    },
                    {
                        "name": "Subscription",
                        "type": 6,
                        "multiSelect": true
                    }
                ]
            }
        }
    ]
}

KQL Query Step

// VM Performance
Perf
| where TimeGenerated {TimeRange}
| where ObjectName == "Processor" and CounterName == "% Processor Time"
| summarize AvgCPU = avg(CounterValue), MaxCPU = max(CounterValue)
    by Computer, bin(TimeGenerated, 5m)
| order by TimeGenerated desc

Metrics Query

{
    "type": 10,
    "content": {
        "chartType": 2,
        "metrics": [
            {
                "resourceMetadata": {
                    "id": "{VirtualMachine}"
                },
                "name": "Percentage CPU",
                "aggregationType": 4,
                "namespace": "microsoft.compute/virtualmachines"
            }
        ],
        "title": "VM CPU Usage",
        "timeContext": { "durationMs": 3600000 }
    }
}

Azure Resource Graph

// Find all VMs and their sizes
resources
| where type == "microsoft.compute/virtualmachines"
| project name, resourceGroup, location,
    size = properties.hardwareProfile.vmSize,
    os = properties.storageProfile.osDisk.osType
| order by name

Conditional Formatting

{
    "type": 3,
    "content": {
        "query": "...",
        "gridSettings": {
            "formatters": [
                {
                    "columnMatch": "CPU",
                    "formatter": 8,
                    "formatOptions": {
                        "palette": "redGreen",
                        "min": 0,
                        "max": 100
                    }
                },
                {
                    "columnMatch": "Status",
                    "formatter": 18,
                    "formatOptions": {
                        "thresholdsOptions": "icons",
                        "thresholdsGrid": [
                            { "operator": "==", "thresholdValue": "Healthy", "representation": "success" },
                            { "operator": "==", "thresholdValue": "Warning", "representation": "warning" },
                            { "operator": "Default", "representation": "error" }
                        ]
                    }
                }
            ]
        }
    }
}
{
    "type": 3,
    "content": {
        "query": "...",
        "gridSettings": {
            "linkColumn": "ResourceId",
            "linkTarget": "Resource",
            "linkLabel": "View Resource"
        }
    }
}

Tabs and Groups

{
    "type": 11,
    "content": {
        "version": "LinkItem/1.0",
        "style": "tabs",
        "links": [
            { "cellValue": "Overview", "linkTarget": "step" },
            { "cellValue": "Compute", "linkTarget": "step" },
            { "cellValue": "Storage", "linkTarget": "step" },
            { "cellValue": "Network", "linkTarget": "step" }
        ]
    }
}

Export and Share

# Export workbook as ARM template
az monitor workbook show \
    --resource-group myRG \
    --name my-workbook \
    --output json > workbook-template.json

# Deploy workbook
az deployment group create \
    --resource-group myRG \
    --template-file workbook-template.json

Pre-built workbooks:

  • VM Insights
  • Container Insights
  • Application Insights
  • Network Insights
  • Storage Insights

Workbooks: storytelling with your monitoring data.

Michael John Peña

Michael John Peña

Senior Data Engineer based in Sydney. Writing about data, cloud, and technology.