├── armTemplate └── template.json ├── galleryTemplate └── template.json └── readme.md /armTemplate/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "contentVersion": "1.0.0.0", 3 | "parameters": { 4 | "workbookDisplayName": { 5 | "type": "string", 6 | "defaultValue": "CostManagement", 7 | "metadata": { 8 | "description": "The friendly name for the workbook that is used in the Gallery or Saved List. This name must be unique within a resource group." 9 | } 10 | }, 11 | "workbookType": { 12 | "type": "string", 13 | "defaultValue": "workbook", 14 | "metadata": { 15 | "description": "The gallery that the workbook will been shown under. Supported values include workbook, tsg, etc. Usually, this is 'workbook'" 16 | } 17 | }, 18 | "workbookSourceId": { 19 | "type": "string", 20 | "defaultValue": "azure monitor", 21 | "metadata": { 22 | "description": "The id of resource instance to which the workbook will be associated" 23 | } 24 | }, 25 | "workbookId": { 26 | "type": "string", 27 | "defaultValue": "[newGuid()]", 28 | "metadata": { 29 | "description": "The unique guid for this workbook instance" 30 | } 31 | } 32 | }, 33 | "resources": [ 34 | { 35 | "name": "[parameters('workbookId')]", 36 | "type": "microsoft.insights/workbooks", 37 | "location": "[resourceGroup().location]", 38 | "apiVersion": "2018-06-17-preview", 39 | "dependsOn": [], 40 | "kind": "shared", 41 | "properties": { 42 | "displayName": "[parameters('workbookDisplayName')]", 43 | "serializedData": "{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":9,\"content\":{\"version\":\"KqlParameterItem/1.0\",\"parameters\":[{\"id\":\"ee507714-9934-47eb-87e2-79857919b101\",\"version\":\"KqlParameterItem/1.0\",\"name\":\"Subscription\",\"type\":6,\"isRequired\":true,\"multiSelect\":true,\"quote\":\"'\",\"delimiter\":\",\",\"value\":[\"/subscriptions/ebb79bc0-aa86-44a7-8111-cabbe0c43993\"],\"typeSettings\":{\"additionalResourceOptions\":[\"value::1\"],\"includeAll\":true,\"showDefault\":false},\"timeContext\":{\"durationMs\":86400000},\"defaultValue\":\"value::1\"},{\"id\":\"910c7952-f49c-42d0-91b2-ad679f8b0785\",\"version\":\"KqlParameterItem/1.0\",\"name\":\"Environment\",\"type\":2,\"isRequired\":true,\"multiSelect\":true,\"quote\":\"\\\"\",\"delimiter\":\",\",\"query\":\"resources | distinct tostring(tags.Demo_Environment)\\r\\n| where tags_Demo_Environment != \\\"\\\"\",\"crossComponentResources\":[\"{Subscription}\"],\"value\":[\"Prod\"],\"typeSettings\":{\"additionalResourceOptions\":[\"value::1\",\"value::all\"],\"showDefault\":false},\"timeContext\":{\"durationMs\":86400000},\"queryType\":1,\"resourceType\":\"microsoft.resourcegraph/resources\"},{\"id\":\"8756cae2-db95-442f-937d-e6d1c86e63ab\",\"version\":\"KqlParameterItem/1.0\",\"name\":\"Aggregation\",\"type\":2,\"isRequired\":true,\"typeSettings\":{\"additionalResourceOptions\":[],\"showDefault\":false},\"jsonData\":\"[\\r\\n { \\\"value\\\": \\\"ResourceGroup\\\", \\\"label\\\": \\\"Resource Group\\\"},\\r\\n { \\\"value\\\": \\\"SubscriptionId\\\", \\\"label\\\": \\\"Subscription\\\", \\\"selected\\\":true },\\r\\n { \\\"value\\\": \\\"ResourceType\\\", \\\"label\\\": \\\"Resource Type\\\"}\\r\\n]\",\"timeContext\":{\"durationMs\":86400000},\"value\":\"ResourceGroup\"},{\"id\":\"de00734d-a605-43bf-aa5a-707fd5f23a06\",\"version\":\"KqlParameterItem/1.0\",\"name\":\"TimeFrame\",\"type\":2,\"typeSettings\":{\"additionalResourceOptions\":[],\"showDefault\":false},\"jsonData\":\"[\\r\\n { \\\"value\\\": \\\"BillingMonthToDate\\\", \\\"label\\\": \\\"Billing MonthToDate\\\"},\\r\\n { \\\"value\\\": \\\"MonthToDate\\\", \\\"label\\\": \\\"MonthToDate\\\", \\\"selected\\\":true },\\r\\n { \\\"value\\\": \\\"TheLastBillingMonth\\\", \\\"label\\\": \\\"Last Billing Month\\\"},\\r\\n { \\\"value\\\": \\\"TheLastMonth\\\", \\\"label\\\": \\\"Last Month\\\"},\\r\\n { \\\"value\\\": \\\"WeekToDate\\\", \\\"label\\\": \\\"WeekToDate\\\"}\\r\\n]\",\"timeContext\":{\"durationMs\":86400000}}],\"style\":\"pills\",\"queryType\":0,\"resourceType\":\"microsoft.operationalinsights/workspaces\"},\"name\":\"parameters - 1\"},{\"type\":3,\"content\":{\"version\":\"KqlItem/1.0\",\"query\":\"{\\\"version\\\":\\\"ARMEndpoint/1.0\\\",\\\"data\\\":\\\" {\\\\r\\\\n \\\\\\\"type\\\\\\\": \\\\\\\"Usage\\\\\\\",\\\\r\\\\n \\\\\\\"timeframe\\\\\\\": \\\\\\\"{TimeFrame}\\\\\\\",\\\\r\\\\n \\\\\\\"dataset\\\\\\\": {\\\\r\\\\n \\\\\\\"granularity\\\\\\\": \\\\\\\"None\\\\\\\",\\\\r\\\\n \\\\\\\"filter\\\\\\\": {\\\\r\\\\n \\\\\\\"tags\\\\\\\" : {\\\\r\\\\n \\\\\\\"name\\\\\\\" : \\\\\\\"Demo_Environment\\\\\\\",\\\\r\\\\n \\\\\\\"operator\\\\\\\" : \\\\\\\"In\\\\\\\",\\\\r\\\\n \\\\\\\"values\\\\\\\" : [\\\\r\\\\n {Environment}\\\\r\\\\n ]\\\\r\\\\n }\\\\r\\\\n },\\\\r\\\\n \\\\\\\"aggregation\\\\\\\": {\\\\r\\\\n \\\\\\\"totalCost\\\\\\\": {\\\\r\\\\n \\\\\\\"name\\\\\\\": \\\\\\\"PreTaxCost\\\\\\\",\\\\r\\\\n \\\\\\\"function\\\\\\\": \\\\\\\"Sum\\\\\\\"\\\\r\\\\n }\\\\r\\\\n },\\\\r\\\\n \\\\\\\"grouping\\\\\\\": [\\\\r\\\\n {\\\\r\\\\n \\\\\\\"type\\\\\\\": \\\\\\\"Dimension\\\\\\\",\\\\r\\\\n \\\\\\\"name\\\\\\\": \\\\\\\"{Aggregation}\\\\\\\"\\\\r\\\\n }\\\\r\\\\n ]\\\\r\\\\n }\\\\r\\\\n }\\\",\\\"headers\\\":[],\\\"method\\\":\\\"POST\\\",\\\"path\\\":\\\"/subscriptions/{Subscription:id}/providers/Microsoft.CostManagement/query?\\\",\\\"urlParams\\\":[{\\\"key\\\":\\\"api-version\\\",\\\"value\\\":\\\"2019-11-01\\\"}],\\\"batchDisabled\\\":true,\\\"transformers\\\":[{\\\"type\\\":\\\"jsonpath\\\",\\\"settings\\\":{\\\"tablePath\\\":\\\"$.properties\\\",\\\"columns\\\":[]}}]}\",\"size\":0,\"queryType\":12},\"name\":\"query - 0\"}],\"isLocked\":false,\"fallbackResourceIds\":[\"azure monitor\"]}", 44 | "version": "1.0", 45 | "sourceId": "[parameters('workbookSourceId')]", 46 | "category": "[parameters('workbookType')]" 47 | } 48 | } 49 | ], 50 | "outputs": { 51 | "workbookId": { 52 | "type": "string", 53 | "value": "[resourceId( 'microsoft.insights/workbooks', parameters('workbookId'))]" 54 | } 55 | }, 56 | "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#" 57 | } -------------------------------------------------------------------------------- /galleryTemplate/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "Notebook/1.0", 3 | "items": [ 4 | { 5 | "type": 9, 6 | "content": { 7 | "version": "KqlParameterItem/1.0", 8 | "parameters": [ 9 | { 10 | "id": "ee507714-9934-47eb-87e2-79857919b101", 11 | "version": "KqlParameterItem/1.0", 12 | "name": "Subscription", 13 | "type": 6, 14 | "isRequired": true, 15 | "multiSelect": true, 16 | "quote": "'", 17 | "delimiter": ",", 18 | "value": [ 19 | "/subscriptions/ebb79bc0-aa86-44a7-8111-cabbe0c43993" 20 | ], 21 | "typeSettings": { 22 | "additionalResourceOptions": [ 23 | "value::1" 24 | ], 25 | "includeAll": true, 26 | "showDefault": false 27 | }, 28 | "timeContext": { 29 | "durationMs": 86400000 30 | }, 31 | "defaultValue": "value::1" 32 | }, 33 | { 34 | "id": "910c7952-f49c-42d0-91b2-ad679f8b0785", 35 | "version": "KqlParameterItem/1.0", 36 | "name": "Environment", 37 | "type": 2, 38 | "isRequired": true, 39 | "multiSelect": true, 40 | "quote": "\"", 41 | "delimiter": ",", 42 | "query": "resources | distinct tostring(tags.Demo_Environment)\r\n| where tags_Demo_Environment != \"\"", 43 | "crossComponentResources": [ 44 | "{Subscription}" 45 | ], 46 | "value": [ 47 | "Prod" 48 | ], 49 | "typeSettings": { 50 | "additionalResourceOptions": [ 51 | "value::1", 52 | "value::all" 53 | ], 54 | "showDefault": false 55 | }, 56 | "timeContext": { 57 | "durationMs": 86400000 58 | }, 59 | "queryType": 1, 60 | "resourceType": "microsoft.resourcegraph/resources" 61 | }, 62 | { 63 | "id": "8756cae2-db95-442f-937d-e6d1c86e63ab", 64 | "version": "KqlParameterItem/1.0", 65 | "name": "Aggregation", 66 | "type": 2, 67 | "isRequired": true, 68 | "typeSettings": { 69 | "additionalResourceOptions": [], 70 | "showDefault": false 71 | }, 72 | "jsonData": "[\r\n { \"value\": \"ResourceGroup\", \"label\": \"Resource Group\"},\r\n { \"value\": \"SubscriptionId\", \"label\": \"Subscription\", \"selected\":true },\r\n { \"value\": \"ResourceType\", \"label\": \"Resource Type\"}\r\n]", 73 | "timeContext": { 74 | "durationMs": 86400000 75 | }, 76 | "value": "ResourceGroup" 77 | }, 78 | { 79 | "id": "de00734d-a605-43bf-aa5a-707fd5f23a06", 80 | "version": "KqlParameterItem/1.0", 81 | "name": "TimeFrame", 82 | "type": 2, 83 | "typeSettings": { 84 | "additionalResourceOptions": [], 85 | "showDefault": false 86 | }, 87 | "jsonData": "[\r\n { \"value\": \"BillingMonthToDate\", \"label\": \"Billing MonthToDate\"},\r\n { \"value\": \"MonthToDate\", \"label\": \"MonthToDate\", \"selected\":true },\r\n { \"value\": \"TheLastBillingMonth\", \"label\": \"Last Billing Month\"},\r\n { \"value\": \"TheLastMonth\", \"label\": \"Last Month\"},\r\n { \"value\": \"WeekToDate\", \"label\": \"WeekToDate\"}\r\n]", 88 | "timeContext": { 89 | "durationMs": 86400000 90 | } 91 | } 92 | ], 93 | "style": "pills", 94 | "queryType": 0, 95 | "resourceType": "microsoft.operationalinsights/workspaces" 96 | }, 97 | "name": "parameters - 1" 98 | }, 99 | { 100 | "type": 3, 101 | "content": { 102 | "version": "KqlItem/1.0", 103 | "query": "{\"version\":\"ARMEndpoint/1.0\",\"data\":\" {\\r\\n \\\"type\\\": \\\"Usage\\\",\\r\\n \\\"timeframe\\\": \\\"{TimeFrame}\\\",\\r\\n \\\"dataset\\\": {\\r\\n \\\"granularity\\\": \\\"None\\\",\\r\\n \\\"filter\\\": {\\r\\n \\\"tags\\\" : {\\r\\n \\\"name\\\" : \\\"Demo_Environment\\\",\\r\\n \\\"operator\\\" : \\\"In\\\",\\r\\n \\\"values\\\" : [\\r\\n {Environment}\\r\\n ]\\r\\n }\\r\\n },\\r\\n \\\"aggregation\\\": {\\r\\n \\\"totalCost\\\": {\\r\\n \\\"name\\\": \\\"PreTaxCost\\\",\\r\\n \\\"function\\\": \\\"Sum\\\"\\r\\n }\\r\\n },\\r\\n \\\"grouping\\\": [\\r\\n {\\r\\n \\\"type\\\": \\\"Dimension\\\",\\r\\n \\\"name\\\": \\\"{Aggregation}\\\"\\r\\n }\\r\\n ]\\r\\n }\\r\\n }\",\"headers\":[],\"method\":\"POST\",\"path\":\"/subscriptions/{Subscription:id}/providers/Microsoft.CostManagement/query?\",\"urlParams\":[{\"key\":\"api-version\",\"value\":\"2019-11-01\"}],\"batchDisabled\":true,\"transformers\":[{\"type\":\"jsonpath\",\"settings\":{\"tablePath\":\"$.properties\",\"columns\":[]}}]}", 104 | "size": 0, 105 | "queryType": 12 106 | }, 107 | "name": "query - 0" 108 | } 109 | ], 110 | "fallbackResourceIds": [ 111 | "azure monitor" 112 | ], 113 | "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" 114 | } -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Azure Cost Management Example Workbook 2 | 3 | ## Related Blog Post 4 | https://techcommunity.microsoft.com/t5/itops-talk-blog/customize-cost-data-visualizations-with-azure-workbooks-and/ba-p/2387779 5 | 6 | 7 | ## Purpose 8 | Example workbook to show how you can query and parameterize JSON body in Azure Workbooks 9 | --------------------------------------------------------------------------------