|
| 1 | +terraform { |
| 2 | + required_providers { |
| 3 | + azapi = { |
| 4 | + source = "azure/azapi" |
| 5 | + } |
| 6 | + } |
| 7 | +} |
| 8 | + |
| 9 | +locals { |
| 10 | + subscription_resource_id = "/subscriptions/${var.subscription_id}" |
| 11 | + |
| 12 | + overview_markdown = <<-MARKDOWN |
| 13 | + ## ${var.dashboard_display_name} |
| 14 | + This dashboard is the shared entry point for Azure Resource Manager subscription throttling in ${var.subscription_display_name}. |
| 15 | +
|
| 16 | + - Subscription resource: `${local.subscription_resource_id}` |
| 17 | + - Start with the `Traffic` metric and add `StatusCode = 429`. |
| 18 | + - High-signal filters for the current FXCI issue: `Namespace = MICROSOFT.RESOURCES`, `OperationType = write`. |
| 19 | + - Click a chart to open Metrics explorer and split or filter by `RequestRegion`, `Namespace`, or `OperationType`. |
| 20 | + MARKDOWN |
| 21 | + |
| 22 | + drilldown_markdown = <<-MARKDOWN |
| 23 | + ### How to confirm subscription bucket pressure |
| 24 | + 1. Re-run a failing `az` command with `--debug`. |
| 25 | + 2. Capture the `429` response and inspect `x-ms-ratelimit-remaining-subscription-reads` or `x-ms-ratelimit-remaining-subscription-writes`. |
| 26 | + 3. If those headers are near `0`, the general ARM subscription bucket is being exhausted. |
| 27 | +
|
| 28 | + Docs: |
| 29 | + - [Monitor Azure Resource Manager](https://learn.microsoft.com/azure/azure-resource-manager/management/monitor-resource-manager) |
| 30 | + - [Understand how Azure Resource Manager throttles requests](https://learn.microsoft.com/azure/azure-resource-manager/management/request-limits-and-throttling) |
| 31 | + MARKDOWN |
| 32 | +} |
| 33 | + |
| 34 | +resource "azapi_resource" "this" { |
| 35 | + type = "Microsoft.Portal/dashboards@2020-09-01-preview" |
| 36 | + name = var.dashboard_name |
| 37 | + parent_id = var.resource_group_id |
| 38 | + location = var.location |
| 39 | + schema_validation_enabled = false |
| 40 | + |
| 41 | + tags = merge( |
| 42 | + var.tags, |
| 43 | + { |
| 44 | + Name = var.dashboard_name |
| 45 | + "hidden-title" = var.dashboard_display_name |
| 46 | + } |
| 47 | + ) |
| 48 | + |
| 49 | + body = { |
| 50 | + properties = { |
| 51 | + lenses = [ |
| 52 | + { |
| 53 | + order = 0 |
| 54 | + parts = [ |
| 55 | + { |
| 56 | + position = { |
| 57 | + x = 0 |
| 58 | + y = 0 |
| 59 | + rowSpan = 3 |
| 60 | + colSpan = 11 |
| 61 | + } |
| 62 | + metadata = { |
| 63 | + inputs = [] |
| 64 | + type = "Extension/HubsExtension/PartType/MarkdownPart" |
| 65 | + settings = { |
| 66 | + content = { |
| 67 | + settings = { |
| 68 | + content = local.overview_markdown |
| 69 | + title = var.dashboard_display_name |
| 70 | + subtitle = "Azure Resource Manager subscription throttling" |
| 71 | + } |
| 72 | + } |
| 73 | + } |
| 74 | + } |
| 75 | + }, |
| 76 | + { |
| 77 | + position = { |
| 78 | + x = 0 |
| 79 | + y = 3 |
| 80 | + rowSpan = 4 |
| 81 | + colSpan = 6 |
| 82 | + } |
| 83 | + metadata = { |
| 84 | + inputs = [ |
| 85 | + { |
| 86 | + name = "queryInputs" |
| 87 | + value = { |
| 88 | + timespan = { |
| 89 | + duration = var.metric_timespan |
| 90 | + } |
| 91 | + id = local.subscription_resource_id |
| 92 | + chartType = 0 |
| 93 | + metrics = [ |
| 94 | + { |
| 95 | + name = "Traffic" |
| 96 | + resourceId = local.subscription_resource_id |
| 97 | + } |
| 98 | + ] |
| 99 | + } |
| 100 | + } |
| 101 | + ] |
| 102 | + type = "Extension/Microsoft_Azure_Monitoring/PartType/MetricsChartPart" |
| 103 | + } |
| 104 | + }, |
| 105 | + { |
| 106 | + position = { |
| 107 | + x = 6 |
| 108 | + y = 3 |
| 109 | + rowSpan = 4 |
| 110 | + colSpan = 5 |
| 111 | + } |
| 112 | + metadata = { |
| 113 | + inputs = [ |
| 114 | + { |
| 115 | + name = "queryInputs" |
| 116 | + value = { |
| 117 | + timespan = { |
| 118 | + duration = var.metric_timespan |
| 119 | + } |
| 120 | + id = local.subscription_resource_id |
| 121 | + chartType = 0 |
| 122 | + metrics = [ |
| 123 | + { |
| 124 | + name = "Latency" |
| 125 | + resourceId = local.subscription_resource_id |
| 126 | + } |
| 127 | + ] |
| 128 | + } |
| 129 | + } |
| 130 | + ] |
| 131 | + type = "Extension/Microsoft_Azure_Monitoring/PartType/MetricsChartPart" |
| 132 | + } |
| 133 | + }, |
| 134 | + { |
| 135 | + position = { |
| 136 | + x = 0 |
| 137 | + y = 7 |
| 138 | + rowSpan = 5 |
| 139 | + colSpan = 11 |
| 140 | + } |
| 141 | + metadata = { |
| 142 | + inputs = [] |
| 143 | + type = "Extension/HubsExtension/PartType/MarkdownPart" |
| 144 | + settings = { |
| 145 | + content = { |
| 146 | + settings = { |
| 147 | + content = local.drilldown_markdown |
| 148 | + title = "Operational notes" |
| 149 | + } |
| 150 | + } |
| 151 | + } |
| 152 | + } |
| 153 | + } |
| 154 | + ] |
| 155 | + } |
| 156 | + ] |
| 157 | + } |
| 158 | + } |
| 159 | +} |
0 commit comments