Skip to content

Commit 2592c2d

Browse files
warren830tamas-la
authored andcommitted
feat(q-dev): add AI Cost-Efficiency dashboard (#8793)
Add a Grafana dashboard showing AI tool cost-efficiency metrics: - Credits per merged PR (overall + weekly trend) - Credits per production deployment (overall + weekly trend) - Credits per issue resolved (overall + weekly trend) - Weekly AI activity volume (credits, messages, conversations) Joins _tool_q_dev_user_report with pull_requests, cicd_deployment_commits, and issues by weekly aggregation.
1 parent 1fc5be1 commit 2592c2d

1 file changed

Lines changed: 317 additions & 0 deletions

File tree

Lines changed: 317 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,317 @@
1+
{
2+
"annotations": {
3+
"list": [
4+
{
5+
"builtIn": 1,
6+
"datasource": "-- Grafana --",
7+
"enable": true,
8+
"hide": true,
9+
"iconColor": "rgba(0, 211, 255, 1)",
10+
"name": "Annotations & Alerts",
11+
"type": "dashboard"
12+
}
13+
]
14+
},
15+
"editable": true,
16+
"fiscalYearStartMonth": 0,
17+
"graphTooltip": 1,
18+
"id": null,
19+
"links": [
20+
{
21+
"asDropdown": false,
22+
"icon": "external link",
23+
"includeVars": true,
24+
"keepTime": true,
25+
"tags": [],
26+
"targetBlank": true,
27+
"title": "Kiro Usage Dashboard",
28+
"type": "link",
29+
"url": "/d/qdev_user_report"
30+
}
31+
],
32+
"panels": [
33+
{
34+
"collapsed": false,
35+
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 },
36+
"id": 1,
37+
"panels": [],
38+
"title": "Summary",
39+
"type": "row"
40+
},
41+
{
42+
"datasource": "mysql",
43+
"fieldConfig": {
44+
"defaults": {
45+
"color": { "mode": "thresholds" },
46+
"mappings": [],
47+
"thresholds": { "mode": "absolute", "steps": [{ "color": "blue", "value": null }] }
48+
},
49+
"overrides": []
50+
},
51+
"gridPos": { "h": 6, "w": 6, "x": 0, "y": 1 },
52+
"id": 2,
53+
"options": {
54+
"colorMode": "value",
55+
"graphMode": "area",
56+
"reduceOptions": { "calcs": ["sum"], "fields": "", "values": false },
57+
"textMode": "auto"
58+
},
59+
"targets": [
60+
{
61+
"datasource": "mysql",
62+
"format": "table",
63+
"rawQuery": true,
64+
"rawSql": "SELECT ROUND(SUM(credits_used)) AS 'Total Credits'\nFROM _tool_q_dev_user_report WHERE $__timeFilter(date)",
65+
"refId": "A"
66+
}
67+
],
68+
"title": "Total Credits Used",
69+
"type": "stat"
70+
},
71+
{
72+
"datasource": "mysql",
73+
"fieldConfig": {
74+
"defaults": {
75+
"color": { "mode": "thresholds" },
76+
"mappings": [],
77+
"thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }] }
78+
},
79+
"overrides": []
80+
},
81+
"gridPos": { "h": 6, "w": 6, "x": 6, "y": 1 },
82+
"id": 3,
83+
"options": {
84+
"colorMode": "value",
85+
"graphMode": "area",
86+
"reduceOptions": { "calcs": ["sum"], "fields": "", "values": false },
87+
"textMode": "auto"
88+
},
89+
"targets": [
90+
{
91+
"datasource": "mysql",
92+
"format": "table",
93+
"rawQuery": true,
94+
"rawSql": "SELECT ROUND(SUM(r.credits_used) / NULLIF(COUNT(DISTINCT pr.id), 0), 1) AS 'Credits / PR'\nFROM _tool_q_dev_user_report r\nCROSS JOIN (\n SELECT DISTINCT id FROM pull_requests\n WHERE merged_date IS NOT NULL AND $__timeFilter(merged_date)\n) pr\nWHERE $__timeFilter(r.date)",
95+
"refId": "A"
96+
}
97+
],
98+
"title": "Credits per PR (Overall)",
99+
"type": "stat"
100+
},
101+
{
102+
"datasource": "mysql",
103+
"fieldConfig": {
104+
"defaults": {
105+
"color": { "mode": "thresholds" },
106+
"mappings": [],
107+
"thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }] }
108+
},
109+
"overrides": []
110+
},
111+
"gridPos": { "h": 6, "w": 6, "x": 12, "y": 1 },
112+
"id": 4,
113+
"options": {
114+
"colorMode": "value",
115+
"graphMode": "area",
116+
"reduceOptions": { "calcs": ["sum"], "fields": "", "values": false },
117+
"textMode": "auto"
118+
},
119+
"targets": [
120+
{
121+
"datasource": "mysql",
122+
"format": "table",
123+
"rawQuery": true,
124+
"rawSql": "SELECT ROUND(SUM(r.credits_used) / NULLIF(COUNT(DISTINCT cdc.cicd_deployment_id), 0), 1) AS 'Credits / Deploy'\nFROM _tool_q_dev_user_report r\nCROSS JOIN (\n SELECT DISTINCT cicd_deployment_id\n FROM cicd_deployment_commits\n WHERE result = 'SUCCESS' AND environment = 'PRODUCTION'\n AND $__timeFilter(finished_date)\n) cdc\nWHERE $__timeFilter(r.date)",
125+
"refId": "A"
126+
}
127+
],
128+
"title": "Credits per Deployment (Overall)",
129+
"type": "stat"
130+
},
131+
{
132+
"datasource": "mysql",
133+
"fieldConfig": {
134+
"defaults": {
135+
"color": { "mode": "thresholds" },
136+
"mappings": [],
137+
"thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }] }
138+
},
139+
"overrides": []
140+
},
141+
"gridPos": { "h": 6, "w": 6, "x": 18, "y": 1 },
142+
"id": 5,
143+
"options": {
144+
"colorMode": "value",
145+
"graphMode": "area",
146+
"reduceOptions": { "calcs": ["sum"], "fields": "", "values": false },
147+
"textMode": "auto"
148+
},
149+
"targets": [
150+
{
151+
"datasource": "mysql",
152+
"format": "table",
153+
"rawQuery": true,
154+
"rawSql": "SELECT ROUND(SUM(r.credits_used) / NULLIF(COUNT(DISTINCT i.id), 0), 1) AS 'Credits / Issue'\nFROM _tool_q_dev_user_report r\nCROSS JOIN (\n SELECT DISTINCT id FROM issues\n WHERE resolution_date IS NOT NULL AND type != 'INCIDENT'\n AND $__timeFilter(resolution_date)\n) i\nWHERE $__timeFilter(r.date)",
155+
"refId": "A"
156+
}
157+
],
158+
"title": "Credits per Issue Resolved",
159+
"type": "stat"
160+
},
161+
{
162+
"collapsed": false,
163+
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 7 },
164+
"id": 10,
165+
"panels": [],
166+
"title": "Weekly Trends",
167+
"type": "row"
168+
},
169+
{
170+
"datasource": "mysql",
171+
"description": "Weekly cost per merged PR",
172+
"fieldConfig": {
173+
"defaults": {
174+
"color": { "mode": "palette-classic" },
175+
"custom": {
176+
"axisBorderShow": false, "axisLabel": "", "axisPlacement": "auto",
177+
"drawStyle": "line", "fillOpacity": 10, "lineInterpolation": "smooth", "lineWidth": 2,
178+
"pointSize": 5, "showPoints": "never", "spanNulls": true,
179+
"stacking": { "mode": "none" }, "thresholdsStyle": { "mode": "off" }
180+
},
181+
"unit": "short"
182+
},
183+
"overrides": []
184+
},
185+
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 8 },
186+
"id": 11,
187+
"options": {
188+
"legend": { "calcs": ["mean", "min"], "displayMode": "table", "placement": "right", "showLegend": true },
189+
"tooltip": { "mode": "multi" }
190+
},
191+
"targets": [
192+
{
193+
"datasource": "mysql",
194+
"format": "time_series",
195+
"rawQuery": true,
196+
"rawSql": "WITH _credits AS (\n SELECT DATE_SUB(DATE(date), INTERVAL WEEKDAY(DATE(date)) DAY) AS week_start,\n SUM(credits_used) AS credits\n FROM _tool_q_dev_user_report WHERE $__timeFilter(date)\n GROUP BY DATE_SUB(DATE(date), INTERVAL WEEKDAY(DATE(date)) DAY)\n),\n_prs AS (\n SELECT DATE_SUB(DATE(merged_date), INTERVAL WEEKDAY(DATE(merged_date)) DAY) AS week_start,\n COUNT(*) AS prs\n FROM pull_requests\n WHERE merged_date IS NOT NULL AND $__timeFilter(merged_date)\n GROUP BY DATE_SUB(DATE(merged_date), INTERVAL WEEKDAY(DATE(merged_date)) DAY)\n)\nSELECT c.week_start AS time,\n ROUND(c.credits / NULLIF(p.prs, 0), 1) AS 'Credits per PR'\nFROM _credits c\nLEFT JOIN _prs p ON c.week_start = p.week_start\nORDER BY time",
197+
"refId": "A"
198+
}
199+
],
200+
"title": "Credits per Merged PR (Weekly)",
201+
"type": "timeseries"
202+
},
203+
{
204+
"datasource": "mysql",
205+
"description": "Weekly cost per production deployment",
206+
"fieldConfig": {
207+
"defaults": {
208+
"color": { "mode": "palette-classic" },
209+
"custom": {
210+
"axisBorderShow": false, "axisLabel": "", "axisPlacement": "auto",
211+
"drawStyle": "line", "fillOpacity": 10, "lineInterpolation": "smooth", "lineWidth": 2,
212+
"pointSize": 5, "showPoints": "never", "spanNulls": true,
213+
"stacking": { "mode": "none" }, "thresholdsStyle": { "mode": "off" }
214+
},
215+
"unit": "short"
216+
},
217+
"overrides": []
218+
},
219+
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 8 },
220+
"id": 12,
221+
"options": {
222+
"legend": { "calcs": ["mean", "min"], "displayMode": "table", "placement": "right", "showLegend": true },
223+
"tooltip": { "mode": "multi" }
224+
},
225+
"targets": [
226+
{
227+
"datasource": "mysql",
228+
"format": "time_series",
229+
"rawQuery": true,
230+
"rawSql": "WITH _credits AS (\n SELECT DATE_SUB(DATE(date), INTERVAL WEEKDAY(DATE(date)) DAY) AS week_start,\n SUM(credits_used) AS credits\n FROM _tool_q_dev_user_report WHERE $__timeFilter(date)\n GROUP BY DATE_SUB(DATE(date), INTERVAL WEEKDAY(DATE(date)) DAY)\n),\n_deploys AS (\n SELECT DATE_SUB(DATE(finished_date), INTERVAL WEEKDAY(DATE(finished_date)) DAY) AS week_start,\n COUNT(DISTINCT cicd_deployment_id) AS deploys\n FROM cicd_deployment_commits\n WHERE result = 'SUCCESS' AND environment = 'PRODUCTION'\n AND $__timeFilter(finished_date)\n GROUP BY DATE_SUB(DATE(finished_date), INTERVAL WEEKDAY(DATE(finished_date)) DAY)\n)\nSELECT c.week_start AS time,\n ROUND(c.credits / NULLIF(d.deploys, 0), 1) AS 'Credits per Deploy'\nFROM _credits c\nLEFT JOIN _deploys d ON c.week_start = d.week_start\nORDER BY time",
231+
"refId": "A"
232+
}
233+
],
234+
"title": "Credits per Deployment (Weekly)",
235+
"type": "timeseries"
236+
},
237+
{
238+
"datasource": "mysql",
239+
"description": "Weekly cost per resolved issue",
240+
"fieldConfig": {
241+
"defaults": {
242+
"color": { "mode": "palette-classic" },
243+
"custom": {
244+
"axisBorderShow": false, "axisLabel": "", "axisPlacement": "auto",
245+
"drawStyle": "line", "fillOpacity": 10, "lineInterpolation": "smooth", "lineWidth": 2,
246+
"pointSize": 5, "showPoints": "never", "spanNulls": true,
247+
"stacking": { "mode": "none" }, "thresholdsStyle": { "mode": "off" }
248+
},
249+
"unit": "short"
250+
},
251+
"overrides": []
252+
},
253+
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 16 },
254+
"id": 13,
255+
"options": {
256+
"legend": { "calcs": ["mean", "min"], "displayMode": "table", "placement": "right", "showLegend": true },
257+
"tooltip": { "mode": "multi" }
258+
},
259+
"targets": [
260+
{
261+
"datasource": "mysql",
262+
"format": "time_series",
263+
"rawQuery": true,
264+
"rawSql": "WITH _credits AS (\n SELECT DATE_SUB(DATE(date), INTERVAL WEEKDAY(DATE(date)) DAY) AS week_start,\n SUM(credits_used) AS credits\n FROM _tool_q_dev_user_report WHERE $__timeFilter(date)\n GROUP BY DATE_SUB(DATE(date), INTERVAL WEEKDAY(DATE(date)) DAY)\n),\n_issues AS (\n SELECT DATE_SUB(DATE(resolution_date), INTERVAL WEEKDAY(DATE(resolution_date)) DAY) AS week_start,\n COUNT(*) AS resolved\n FROM issues\n WHERE resolution_date IS NOT NULL AND type != 'INCIDENT'\n AND $__timeFilter(resolution_date)\n GROUP BY DATE_SUB(DATE(resolution_date), INTERVAL WEEKDAY(DATE(resolution_date)) DAY)\n)\nSELECT c.week_start AS time,\n ROUND(c.credits / NULLIF(i.resolved, 0), 1) AS 'Credits per Issue'\nFROM _credits c\nLEFT JOIN _issues i ON c.week_start = i.week_start\nORDER BY time",
265+
"refId": "A"
266+
}
267+
],
268+
"title": "Credits per Issue Resolved (Weekly)",
269+
"type": "timeseries"
270+
},
271+
{
272+
"datasource": "mysql",
273+
"description": "Is cost efficiency improving over time?",
274+
"fieldConfig": {
275+
"defaults": {
276+
"color": { "mode": "palette-classic" },
277+
"custom": {
278+
"axisBorderShow": false, "axisLabel": "", "axisPlacement": "auto",
279+
"drawStyle": "line", "fillOpacity": 10, "lineInterpolation": "smooth", "lineWidth": 2,
280+
"pointSize": 5, "showPoints": "never", "spanNulls": true,
281+
"stacking": { "mode": "none" }, "thresholdsStyle": { "mode": "off" }
282+
},
283+
"unit": "short"
284+
},
285+
"overrides": []
286+
},
287+
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 16 },
288+
"id": 14,
289+
"options": {
290+
"legend": { "calcs": ["mean", "sum"], "displayMode": "table", "placement": "right", "showLegend": true },
291+
"tooltip": { "mode": "multi" }
292+
},
293+
"targets": [
294+
{
295+
"datasource": "mysql",
296+
"format": "time_series",
297+
"rawQuery": true,
298+
"rawSql": "SELECT\n DATE_SUB(DATE(date), INTERVAL WEEKDAY(DATE(date)) DAY) AS time,\n SUM(credits_used) AS 'Credits',\n SUM(total_messages) AS 'Messages',\n SUM(chat_conversations) AS 'Conversations'\nFROM _tool_q_dev_user_report\nWHERE $__timeFilter(date)\nGROUP BY DATE_SUB(DATE(date), INTERVAL WEEKDAY(DATE(date)) DAY)\nORDER BY time",
299+
"refId": "A"
300+
}
301+
],
302+
"title": "Weekly AI Activity Volume",
303+
"type": "timeseries"
304+
}
305+
],
306+
"preload": false,
307+
"refresh": "5m",
308+
"schemaVersion": 41,
309+
"tags": ["q_dev", "kiro", "cost", "efficiency"],
310+
"templating": { "list": [] },
311+
"time": { "from": "now-90d", "to": "now" },
312+
"timepicker": {},
313+
"timezone": "utc",
314+
"title": "AI Cost-Efficiency",
315+
"uid": "ai_cost_efficiency",
316+
"version": 1
317+
}

0 commit comments

Comments
 (0)