|
| 1 | +resource "random_uuid" "uid" {} |
| 2 | + |
| 3 | +resource "azurerm_application_insights" "insights" { |
| 4 | + count = var.include_app_insights ? 1 : 0 |
| 5 | + |
| 6 | + application_type = "web" |
| 7 | + location = azurerm_resource_group.this.location |
| 8 | + name = "${var.resource_prefix}-appinsights-${var.resource_suffix}" |
| 9 | + resource_group_name = azurerm_resource_group.this.name |
| 10 | +} |
| 11 | + |
| 12 | +resource "azurerm_application_insights_workbook" "workbook" { |
| 13 | + count = var.include_app_insights ? 1 : 0 |
| 14 | + |
| 15 | + data_json = jsonencode({ |
| 16 | + "version" : "Notebook/1.0", |
| 17 | + "items" : [ |
| 18 | + { |
| 19 | + "type" : 1, |
| 20 | + "content" : { |
| 21 | + "json" : "${var.app_insights_workbook_description}", |
| 22 | + "style" : "info" |
| 23 | + }, |
| 24 | + "name" : "Notebook description" |
| 25 | + }, |
| 26 | + { |
| 27 | + "type" : 3, |
| 28 | + "content" : { |
| 29 | + "version" : "KqlItem/1.0", |
| 30 | + "query" : "${var.app_insights_sections["section_1"].query}", |
| 31 | + "size" : 0, |
| 32 | + "timeContext" : { |
| 33 | + "durationMs" : 1800000 |
| 34 | + }, |
| 35 | + "queryType" : 0, |
| 36 | + "resourceType" : "microsoft.insights/components", |
| 37 | + "crossComponentResources" : [ |
| 38 | + "/subscriptions/${data.azurerm_client_config.current.subscription_id}/resourceGroups/${azurerm_resource_group.this.name}/providers/Microsoft.Insights/components/${azurerm_application_insights.insights[0].name}" |
| 39 | + ], |
| 40 | + "visualization" : "${var.app_insights_sections["section_1"].chart}" |
| 41 | + }, |
| 42 | + "name" : "${var.app_insights_sections["section_1"].name}" |
| 43 | + }, |
| 44 | + { |
| 45 | + "type" : 3, |
| 46 | + "content" : { |
| 47 | + "version" : "KqlItem/1.0", |
| 48 | + "query" : "${var.app_insights_sections["section_2"].query}", |
| 49 | + "size" : 0, |
| 50 | + "timeContext" : { |
| 51 | + "durationMs" : 1800000 |
| 52 | + }, |
| 53 | + "queryType" : 0, |
| 54 | + "resourceType" : "microsoft.insights/components", |
| 55 | + "crossComponentResources" : [ |
| 56 | + "/subscriptions/${data.azurerm_client_config.current.subscription_id}/resourceGroups/${azurerm_resource_group.this.name}/providers/Microsoft.Insights/components/${azurerm_application_insights.insights[0].name}" |
| 57 | + ], |
| 58 | + "visualization" : "${var.app_insights_sections["section_2"].chart}" |
| 59 | + }, |
| 60 | + "name" : "${var.app_insights_sections["section_2"].name}" |
| 61 | + }, |
| 62 | + { |
| 63 | + "type" : 3, |
| 64 | + "content" : { |
| 65 | + "version" : "KqlItem/1.0", |
| 66 | + "query" : "${var.app_insights_sections["section_3"].query}", |
| 67 | + "size" : 0, |
| 68 | + "timeContext" : { |
| 69 | + "durationMs" : 1800000 |
| 70 | + }, |
| 71 | + "queryType" : 0, |
| 72 | + "resourceType" : "microsoft.insights/components", |
| 73 | + "crossComponentResources" : [ |
| 74 | + "/subscriptions/${data.azurerm_client_config.current.subscription_id}/resourceGroups/${azurerm_resource_group.this.name}/providers/Microsoft.Insights/components/${azurerm_application_insights.insights[0].name}" |
| 75 | + ], |
| 76 | + "visualization" : "${var.app_insights_sections["section_3"].chart}" |
| 77 | + }, |
| 78 | + "name" : "${var.app_insights_sections["section_3"].name}" |
| 79 | + }, |
| 80 | + { |
| 81 | + "type" : 3, |
| 82 | + "content" : { |
| 83 | + "version" : "KqlItem/1.0", |
| 84 | + "query" : "${var.app_insights_sections["section_4"].query}", |
| 85 | + "size" : 0, |
| 86 | + "timeContext" : { |
| 87 | + "durationMs" : 1800000 |
| 88 | + }, |
| 89 | + "queryType" : 0, |
| 90 | + "resourceType" : "microsoft.insights/components", |
| 91 | + "crossComponentResources" : [ |
| 92 | + "/subscriptions/${data.azurerm_client_config.current.subscription_id}/resourceGroups/${azurerm_resource_group.this.name}/providers/Microsoft.Insights/components/${azurerm_application_insights.insights[0].name}" |
| 93 | + ], |
| 94 | + "visualization" : "${var.app_insights_sections["section_4"].chart}" |
| 95 | + }, |
| 96 | + "name" : "${var.app_insights_sections["section_4"].name}" |
| 97 | + }, |
| 98 | + { |
| 99 | + "type" : 3, |
| 100 | + "content" : { |
| 101 | + "version" : "KqlItem/1.0", |
| 102 | + "query" : "${var.app_insights_sections["section_5"].query}", |
| 103 | + "size" : 0, |
| 104 | + "timeContext" : { |
| 105 | + "durationMs" : 1800000 |
| 106 | + }, |
| 107 | + "queryType" : 0, |
| 108 | + "resourceType" : "microsoft.insights/components", |
| 109 | + "crossComponentResources" : [ |
| 110 | + "/subscriptions/${data.azurerm_client_config.current.subscription_id}/resourceGroups/${azurerm_resource_group.this.name}/providers/Microsoft.Insights/components/${azurerm_application_insights.insights[0].name}" |
| 111 | + ], |
| 112 | + "visualization" : "${var.app_insights_sections["section_5"].chart}" |
| 113 | + }, |
| 114 | + "name" : "${var.app_insights_sections["section_5"].name}" |
| 115 | + }, |
| 116 | + { |
| 117 | + "type" : 3, |
| 118 | + "content" : { |
| 119 | + "version" : "KqlItem/1.0", |
| 120 | + "query" : "${var.app_insights_sections["section_6"].query}", |
| 121 | + "size" : 0, |
| 122 | + "timeContext" : { |
| 123 | + "durationMs" : 1800000 |
| 124 | + }, |
| 125 | + "queryType" : 0, |
| 126 | + "resourceType" : "microsoft.insights/components", |
| 127 | + "crossComponentResources" : [ |
| 128 | + "/subscriptions/${data.azurerm_client_config.current.subscription_id}/resourceGroups/${azurerm_resource_group.this.name}/providers/Microsoft.Insights/components/${azurerm_application_insights.insights[0].name}" |
| 129 | + ], |
| 130 | + "visualization" : "${var.app_insights_sections["section_6"].chart}" |
| 131 | + }, |
| 132 | + "name" : "${var.app_insights_sections["section_6"].name}" |
| 133 | + } |
| 134 | + ], |
| 135 | + "fallbackResourceIds" : [ |
| 136 | + "azure monitor" |
| 137 | + ], |
| 138 | + "$schema" : "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" |
| 139 | + }) |
| 140 | + display_name = "Azure Monitor Workbook" |
| 141 | + location = azurerm_resource_group.this.location |
| 142 | + name = random_uuid.uid.result |
| 143 | + resource_group_name = azurerm_resource_group.this.name |
| 144 | +} |
0 commit comments