Skip to content

Commit 859a9e4

Browse files
Fix workbook cross-resource queries for separate RG deployment
Add crossComponentResources and defaultResourceIds to workbook JSON so it can query App Insights from a different resource group. Update Bicep to replace placeholder with actual resource ID at deploy time. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 9418ae8 commit 859a9e4

2 files changed

Lines changed: 73 additions & 19 deletions

File tree

infra/dashboards/deploy-workbook.bicep

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ param appInsightsResourceId string
1010
param location string = resourceGroup().location
1111

1212
var workbookId = guid(resourceGroup().id, 'token-usage-workbook')
13+
var workbookTemplate = loadTextContent('token-usage-workbook.json')
14+
var workbookContent = replace(workbookTemplate, '__APP_INSIGHTS_RESOURCE_ID__', appInsightsResourceId)
1315

1416
resource workbook 'Microsoft.Insights/workbooks@2022-04-01' = {
1517
name: workbookId
@@ -19,7 +21,7 @@ resource workbook 'Microsoft.Insights/workbooks@2022-04-01' = {
1921
displayName: 'LLM Token Usage Dashboard'
2022
category: 'workbook'
2123
sourceId: appInsightsResourceId
22-
serializedData: loadTextContent('token-usage-workbook.json')
24+
serializedData: workbookContent
2325
}
2426
}
2527

infra/dashboards/token-usage-workbook.json

Lines changed: 70 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@
7373
"formatter": 1
7474
}
7575
]
76-
}
76+
},
77+
"crossComponentResources": [
78+
"__APP_INSIGHTS_RESOURCE_ID__"
79+
]
7780
},
7881
"name": "overall-summary"
7982
},
@@ -87,7 +90,10 @@
8790
"timeContextFromParameter": "TimeRange",
8891
"queryType": 0,
8992
"resourceType": "microsoft.insights/components",
90-
"visualization": "table"
93+
"visualization": "table",
94+
"crossComponentResources": [
95+
"__APP_INSIGHTS_RESOURCE_ID__"
96+
]
9197
},
9298
"name": "tokens-by-agent"
9399
},
@@ -101,7 +107,10 @@
101107
"timeContextFromParameter": "TimeRange",
102108
"queryType": 0,
103109
"resourceType": "microsoft.insights/components",
104-
"visualization": "areachart"
110+
"visualization": "areachart",
111+
"crossComponentResources": [
112+
"__APP_INSIGHTS_RESOURCE_ID__"
113+
]
105114
},
106115
"name": "tokens-over-time"
107116
},
@@ -115,7 +124,10 @@
115124
"timeContextFromParameter": "TimeRange",
116125
"queryType": 0,
117126
"resourceType": "microsoft.insights/components",
118-
"visualization": "piechart"
127+
"visualization": "piechart",
128+
"crossComponentResources": [
129+
"__APP_INSIGHTS_RESOURCE_ID__"
130+
]
119131
},
120132
"name": "token-distribution-pie"
121133
},
@@ -136,7 +148,10 @@
136148
"timeContextFromParameter": "TimeRange",
137149
"queryType": 0,
138150
"resourceType": "microsoft.insights/components",
139-
"visualization": "table"
151+
"visualization": "table",
152+
"crossComponentResources": [
153+
"__APP_INSIGHTS_RESOURCE_ID__"
154+
]
140155
},
141156
"name": "cost-estimation"
142157
},
@@ -150,7 +165,10 @@
150165
"timeContextFromParameter": "TimeRange",
151166
"queryType": 0,
152167
"resourceType": "microsoft.insights/components",
153-
"visualization": "table"
168+
"visualization": "table",
169+
"crossComponentResources": [
170+
"__APP_INSIGHTS_RESOURCE_ID__"
171+
]
154172
},
155173
"name": "cost-by-model"
156174
},
@@ -171,7 +189,10 @@
171189
"timeContextFromParameter": "TimeRange",
172190
"queryType": 0,
173191
"resourceType": "microsoft.insights/components",
174-
"visualization": "table"
192+
"visualization": "table",
193+
"crossComponentResources": [
194+
"__APP_INSIGHTS_RESOURCE_ID__"
195+
]
175196
},
176197
"name": "tokens-by-model"
177198
},
@@ -185,7 +206,10 @@
185206
"timeContextFromParameter": "TimeRange",
186207
"queryType": 0,
187208
"resourceType": "microsoft.insights/components",
188-
"visualization": "table"
209+
"visualization": "table",
210+
"crossComponentResources": [
211+
"__APP_INSIGHTS_RESOURCE_ID__"
212+
]
189213
},
190214
"name": "step-model-mapping"
191215
},
@@ -199,7 +223,10 @@
199223
"timeContextFromParameter": "TimeRange",
200224
"queryType": 0,
201225
"resourceType": "microsoft.insights/components",
202-
"visualization": "table"
226+
"visualization": "table",
227+
"crossComponentResources": [
228+
"__APP_INSIGHTS_RESOURCE_ID__"
229+
]
203230
},
204231
"name": "top-consumers"
205232
},
@@ -213,7 +240,10 @@
213240
"timeContextFromParameter": "TimeRange",
214241
"queryType": 0,
215242
"resourceType": "microsoft.insights/components",
216-
"visualization": "table"
243+
"visualization": "table",
244+
"crossComponentResources": [
245+
"__APP_INSIGHTS_RESOURCE_ID__"
246+
]
217247
},
218248
"name": "tokens-by-filetype"
219249
},
@@ -234,7 +264,10 @@
234264
"timeContextFromParameter": "TimeRange",
235265
"queryType": 0,
236266
"resourceType": "microsoft.insights/components",
237-
"visualization": "table"
267+
"visualization": "table",
268+
"crossComponentResources": [
269+
"__APP_INSIGHTS_RESOURCE_ID__"
270+
]
238271
},
239272
"name": "processing-time-by-step"
240273
},
@@ -248,7 +281,10 @@
248281
"timeContextFromParameter": "TimeRange",
249282
"queryType": 0,
250283
"resourceType": "microsoft.insights/components",
251-
"visualization": "table"
284+
"visualization": "table",
285+
"crossComponentResources": [
286+
"__APP_INSIGHTS_RESOURCE_ID__"
287+
]
252288
},
253289
"name": "openai-call-durations"
254290
},
@@ -262,7 +298,10 @@
262298
"timeContextFromParameter": "TimeRange",
263299
"queryType": 0,
264300
"resourceType": "microsoft.insights/components",
265-
"visualization": "table"
301+
"visualization": "table",
302+
"crossComponentResources": [
303+
"__APP_INSIGHTS_RESOURCE_ID__"
304+
]
266305
},
267306
"name": "per-document-time-breakdown"
268307
},
@@ -276,7 +315,10 @@
276315
"timeContextFromParameter": "TimeRange",
277316
"queryType": 0,
278317
"resourceType": "microsoft.insights/components",
279-
"visualization": "table"
318+
"visualization": "table",
319+
"crossComponentResources": [
320+
"__APP_INSIGHTS_RESOURCE_ID__"
321+
]
280322
},
281323
"name": "total-processing-time"
282324
},
@@ -305,7 +347,10 @@
305347
"formatter": 1
306348
}
307349
]
308-
}
350+
},
351+
"crossComponentResources": [
352+
"__APP_INSIGHTS_RESOURCE_ID__"
353+
]
309354
},
310355
"name": "token-percentiles"
311356
},
@@ -319,13 +364,20 @@
319364
"timeContextFromParameter": "TimeRange",
320365
"queryType": 0,
321366
"resourceType": "microsoft.insights/components",
322-
"visualization": "table"
367+
"visualization": "table",
368+
"crossComponentResources": [
369+
"__APP_INSIGHTS_RESOURCE_ID__"
370+
]
323371
},
324372
"name": "daily-volume"
325373
}
326374
],
327375
"isLocked": true,
328-
"defaultResourceIds": [],
329-
"fallbackResourceIds": [],
376+
"defaultResourceIds": [
377+
"__APP_INSIGHTS_RESOURCE_ID__"
378+
],
379+
"fallbackResourceIds": [
380+
"__APP_INSIGHTS_RESOURCE_ID__"
381+
],
330382
"fromTemplateId": "community-Workbooks/Common/Templates"
331383
}

0 commit comments

Comments
 (0)