@kometolabs/mcp-analytics-receiver 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1108 @@
1
+ {
2
+ "id": null,
3
+ "uid": "mcp-analytics-overview",
4
+ "title": "MCP Analytics",
5
+ "description": "A single-page, metadata-only MCP analytics overview.",
6
+ "tags": [
7
+ "mcp-analytics"
8
+ ],
9
+ "editable": false,
10
+ "graphTooltip": 1,
11
+ "schemaVersion": 40,
12
+ "version": 1,
13
+ "timezone": "utc",
14
+ "weekStart": "monday",
15
+ "refresh": "30s",
16
+ "time": {
17
+ "from": "now-30d",
18
+ "to": "now"
19
+ },
20
+ "timepicker": {
21
+ "refresh_intervals": [
22
+ "30s",
23
+ "1m",
24
+ "5m",
25
+ "15m"
26
+ ]
27
+ },
28
+ "annotations": {
29
+ "list": []
30
+ },
31
+ "links": [],
32
+ "templating": {
33
+ "list": [
34
+ {
35
+ "name": "project",
36
+ "label": "Project",
37
+ "type": "query",
38
+ "datasource": {
39
+ "type": "grafana-postgresql-datasource",
40
+ "uid": "mcp-analytics-postgres"
41
+ },
42
+ "query": "SELECT DISTINCT project_id FROM mcp_analytics.grafana_events ORDER BY 1",
43
+ "definition": "SELECT DISTINCT project_id FROM mcp_analytics.grafana_events ORDER BY 1",
44
+ "refresh": 1,
45
+ "sort": 1,
46
+ "hide": 0,
47
+ "multi": true,
48
+ "includeAll": true,
49
+ "allValue": null,
50
+ "options": [],
51
+ "current": {
52
+ "selected": true,
53
+ "text": [
54
+ "All"
55
+ ],
56
+ "value": [
57
+ "$__all"
58
+ ]
59
+ }
60
+ },
61
+ {
62
+ "name": "server",
63
+ "label": "Server",
64
+ "type": "query",
65
+ "datasource": {
66
+ "type": "grafana-postgresql-datasource",
67
+ "uid": "mcp-analytics-postgres"
68
+ },
69
+ "query": "SELECT DISTINCT server_id FROM mcp_analytics.grafana_events WHERE project_id IN (${project:sqlstring}) ORDER BY 1",
70
+ "definition": "SELECT DISTINCT server_id FROM mcp_analytics.grafana_events WHERE project_id IN (${project:sqlstring}) ORDER BY 1",
71
+ "refresh": 1,
72
+ "sort": 1,
73
+ "hide": 0,
74
+ "multi": true,
75
+ "includeAll": true,
76
+ "allValue": null,
77
+ "options": [],
78
+ "current": {
79
+ "selected": true,
80
+ "text": [
81
+ "All"
82
+ ],
83
+ "value": [
84
+ "$__all"
85
+ ]
86
+ }
87
+ },
88
+ {
89
+ "name": "environment",
90
+ "label": "Environment",
91
+ "type": "query",
92
+ "datasource": {
93
+ "type": "grafana-postgresql-datasource",
94
+ "uid": "mcp-analytics-postgres"
95
+ },
96
+ "query": "SELECT DISTINCT environment FROM mcp_analytics.grafana_events WHERE project_id IN (${project:sqlstring}) AND server_id IN (${server:sqlstring}) ORDER BY 1",
97
+ "definition": "SELECT DISTINCT environment FROM mcp_analytics.grafana_events WHERE project_id IN (${project:sqlstring}) AND server_id IN (${server:sqlstring}) ORDER BY 1",
98
+ "refresh": 1,
99
+ "sort": 1,
100
+ "hide": 0,
101
+ "multi": true,
102
+ "includeAll": true,
103
+ "allValue": null,
104
+ "options": [],
105
+ "current": {
106
+ "selected": true,
107
+ "text": [
108
+ "All"
109
+ ],
110
+ "value": [
111
+ "$__all"
112
+ ]
113
+ }
114
+ },
115
+ {
116
+ "name": "client",
117
+ "label": "Client",
118
+ "type": "query",
119
+ "datasource": {
120
+ "type": "grafana-postgresql-datasource",
121
+ "uid": "mcp-analytics-postgres"
122
+ },
123
+ "query": "SELECT DISTINCT COALESCE(client_application, 'unknown') FROM mcp_analytics.grafana_events WHERE project_id IN (${project:sqlstring}) AND server_id IN (${server:sqlstring}) AND environment IN (${environment:sqlstring}) ORDER BY 1",
124
+ "definition": "SELECT DISTINCT COALESCE(client_application, 'unknown') FROM mcp_analytics.grafana_events WHERE project_id IN (${project:sqlstring}) AND server_id IN (${server:sqlstring}) AND environment IN (${environment:sqlstring}) ORDER BY 1",
125
+ "refresh": 1,
126
+ "sort": 1,
127
+ "hide": 0,
128
+ "multi": true,
129
+ "includeAll": true,
130
+ "allValue": null,
131
+ "options": [],
132
+ "current": {
133
+ "selected": true,
134
+ "text": [
135
+ "All"
136
+ ],
137
+ "value": [
138
+ "$__all"
139
+ ]
140
+ }
141
+ },
142
+ {
143
+ "name": "cohort",
144
+ "label": "Cohort",
145
+ "type": "custom",
146
+ "query": "Authorization : authorization, First observed : first_observed",
147
+ "hide": 0,
148
+ "multi": true,
149
+ "includeAll": true,
150
+ "allValue": null,
151
+ "skipUrlSync": false,
152
+ "current": {
153
+ "selected": true,
154
+ "text": [
155
+ "All"
156
+ ],
157
+ "value": [
158
+ "$__all"
159
+ ]
160
+ },
161
+ "options": [
162
+ {
163
+ "selected": true,
164
+ "text": "All",
165
+ "value": "$__all"
166
+ },
167
+ {
168
+ "selected": false,
169
+ "text": "Authorization",
170
+ "value": "authorization"
171
+ },
172
+ {
173
+ "selected": false,
174
+ "text": "First observed",
175
+ "value": "first_observed"
176
+ }
177
+ ]
178
+ },
179
+ {
180
+ "name": "heading",
181
+ "label": "Heading",
182
+ "type": "query",
183
+ "datasource": {
184
+ "type": "grafana-postgresql-datasource",
185
+ "uid": "mcp-analytics-postgres"
186
+ },
187
+ "query": "WITH datasets AS (SELECT DISTINCT project_id, server_id FROM mcp_analytics.grafana_events)\nSELECT concat_ws(' · ', 'MCP Analytics',\n (SELECT CASE\n WHEN COUNT(*) = 1 OR COUNT(*) FILTER (WHERE project_id IN (${project:sqlstring})) < COUNT(*)\n THEN string_agg(project_id, ' + ' ORDER BY project_id) FILTER (WHERE project_id IN (${project:sqlstring})) END\n FROM (SELECT DISTINCT project_id FROM datasets) choices),\n (SELECT CASE\n WHEN COUNT(*) = 1 OR COUNT(*) FILTER (WHERE server_id IN (${server:sqlstring})) < COUNT(*)\n THEN string_agg(server_id, ' + ' ORDER BY server_id) FILTER (WHERE server_id IN (${server:sqlstring})) END\n FROM (SELECT DISTINCT server_id FROM datasets WHERE project_id IN (${project:sqlstring})) choices)) AS heading",
188
+ "definition": "WITH datasets AS (SELECT DISTINCT project_id, server_id FROM mcp_analytics.grafana_events)\nSELECT concat_ws(' · ', 'MCP Analytics',\n (SELECT CASE\n WHEN COUNT(*) = 1 OR COUNT(*) FILTER (WHERE project_id IN (${project:sqlstring})) < COUNT(*)\n THEN string_agg(project_id, ' + ' ORDER BY project_id) FILTER (WHERE project_id IN (${project:sqlstring})) END\n FROM (SELECT DISTINCT project_id FROM datasets) choices),\n (SELECT CASE\n WHEN COUNT(*) = 1 OR COUNT(*) FILTER (WHERE server_id IN (${server:sqlstring})) < COUNT(*)\n THEN string_agg(server_id, ' + ' ORDER BY server_id) FILTER (WHERE server_id IN (${server:sqlstring})) END\n FROM (SELECT DISTINCT server_id FROM datasets WHERE project_id IN (${project:sqlstring})) choices)) AS heading",
189
+ "refresh": 1,
190
+ "sort": 0,
191
+ "hide": 2,
192
+ "multi": false,
193
+ "includeAll": false,
194
+ "skipUrlSync": true,
195
+ "options": [],
196
+ "current": {
197
+ "text": "MCP Analytics",
198
+ "value": "MCP Analytics"
199
+ }
200
+ }
201
+ ]
202
+ },
203
+ "panels": [
204
+ {
205
+ "id": 1,
206
+ "type": "text",
207
+ "title": "",
208
+ "gridPos": {
209
+ "x": 0,
210
+ "y": 0,
211
+ "w": 24,
212
+ "h": 2
213
+ },
214
+ "datasource": {
215
+ "type": "grafana-postgresql-datasource",
216
+ "uid": "mcp-analytics-postgres"
217
+ },
218
+ "transparent": true,
219
+ "fieldConfig": {
220
+ "defaults": {
221
+ "color": {
222
+ "mode": "fixed",
223
+ "fixedColor": "#635bff"
224
+ },
225
+ "mappings": [],
226
+ "noValue": "—",
227
+ "thresholds": {
228
+ "mode": "absolute",
229
+ "steps": [
230
+ {
231
+ "color": "green",
232
+ "value": null
233
+ }
234
+ ]
235
+ }
236
+ },
237
+ "overrides": []
238
+ },
239
+ "options": {
240
+ "mode": "markdown",
241
+ "content": "## ${heading}"
242
+ },
243
+ "targets": []
244
+ },
245
+ {
246
+ "id": 7,
247
+ "type": "stat",
248
+ "title": "Active users",
249
+ "gridPos": {
250
+ "x": 0,
251
+ "y": 2,
252
+ "w": 6,
253
+ "h": 4
254
+ },
255
+ "datasource": {
256
+ "type": "grafana-postgresql-datasource",
257
+ "uid": "mcp-analytics-postgres"
258
+ },
259
+ "transparent": true,
260
+ "description": "Distinct identified users attempting a tool during the selected period. Counts follow the configured user or account identity; shared and service accounts count as one user.",
261
+ "fieldConfig": {
262
+ "defaults": {
263
+ "color": {
264
+ "mode": "fixed",
265
+ "fixedColor": "#635bff"
266
+ },
267
+ "mappings": [],
268
+ "noValue": "—",
269
+ "thresholds": {
270
+ "mode": "absolute",
271
+ "steps": [
272
+ {
273
+ "color": "green",
274
+ "value": null
275
+ }
276
+ ]
277
+ },
278
+ "unit": "locale",
279
+ "decimals": 0
280
+ },
281
+ "overrides": []
282
+ },
283
+ "options": {
284
+ "reduceOptions": {
285
+ "calcs": [
286
+ "lastNotNull"
287
+ ],
288
+ "fields": "",
289
+ "values": false
290
+ },
291
+ "colorMode": "none",
292
+ "graphMode": "none",
293
+ "justifyMode": "left",
294
+ "textMode": "auto",
295
+ "wideLayout": true,
296
+ "orientation": "horizontal"
297
+ },
298
+ "targets": [
299
+ {
300
+ "refId": "A",
301
+ "datasource": {
302
+ "type": "grafana-postgresql-datasource",
303
+ "uid": "mcp-analytics-postgres"
304
+ },
305
+ "editorMode": "code",
306
+ "format": "table",
307
+ "rawQuery": true,
308
+ "rawSql": "SELECT COUNT(DISTINCT (e.project_id, e.subject_hash, e.identity_key_version))\n FILTER (WHERE e.subject_hash IS NOT NULL) AS \"Active users\" FROM mcp_analytics.grafana_events e\nWHERE e.occurred_at >= $__timeFrom()::timestamptz\n AND e.occurred_at < LEAST(NOW(), $__timeTo()::timestamptz)\n AND e.project_id IN (${project:sqlstring})\n AND e.server_id IN (${server:sqlstring})\n AND e.environment IN (${environment:sqlstring})\n AND COALESCE(e.client_application, 'unknown') IN (${client:sqlstring})\n AND e.kind = 'tool_call'"
309
+ }
310
+ ]
311
+ },
312
+ {
313
+ "id": 8,
314
+ "type": "stat",
315
+ "title": "Tool calls",
316
+ "gridPos": {
317
+ "x": 6,
318
+ "y": 2,
319
+ "w": 6,
320
+ "h": 4
321
+ },
322
+ "datasource": {
323
+ "type": "grafana-postgresql-datasource",
324
+ "uid": "mcp-analytics-postgres"
325
+ },
326
+ "transparent": true,
327
+ "description": "Observed tool attempts, including intermediate input-required attempts. Telemetry delivery retries are deduplicated before this view.",
328
+ "fieldConfig": {
329
+ "defaults": {
330
+ "color": {
331
+ "mode": "fixed",
332
+ "fixedColor": "#635bff"
333
+ },
334
+ "mappings": [],
335
+ "noValue": "—",
336
+ "thresholds": {
337
+ "mode": "absolute",
338
+ "steps": [
339
+ {
340
+ "color": "green",
341
+ "value": null
342
+ }
343
+ ]
344
+ },
345
+ "unit": "locale",
346
+ "decimals": 0
347
+ },
348
+ "overrides": []
349
+ },
350
+ "options": {
351
+ "reduceOptions": {
352
+ "calcs": [
353
+ "lastNotNull"
354
+ ],
355
+ "fields": "",
356
+ "values": false
357
+ },
358
+ "colorMode": "none",
359
+ "graphMode": "none",
360
+ "justifyMode": "left",
361
+ "textMode": "auto",
362
+ "wideLayout": true,
363
+ "orientation": "horizontal"
364
+ },
365
+ "targets": [
366
+ {
367
+ "refId": "A",
368
+ "datasource": {
369
+ "type": "grafana-postgresql-datasource",
370
+ "uid": "mcp-analytics-postgres"
371
+ },
372
+ "editorMode": "code",
373
+ "format": "table",
374
+ "rawQuery": true,
375
+ "rawSql": "SELECT COUNT(*) AS \"Tool calls\" FROM mcp_analytics.grafana_events e\nWHERE e.occurred_at >= $__timeFrom()::timestamptz\n AND e.occurred_at < LEAST(NOW(), $__timeTo()::timestamptz)\n AND e.project_id IN (${project:sqlstring})\n AND e.server_id IN (${server:sqlstring})\n AND e.environment IN (${environment:sqlstring})\n AND COALESCE(e.client_application, 'unknown') IN (${client:sqlstring})\n AND e.kind = 'tool_call'"
376
+ }
377
+ ]
378
+ },
379
+ {
380
+ "id": 9,
381
+ "type": "stat",
382
+ "title": "Success rate",
383
+ "gridPos": {
384
+ "x": 12,
385
+ "y": 2,
386
+ "w": 6,
387
+ "h": 4
388
+ },
389
+ "datasource": {
390
+ "type": "grafana-postgresql-datasource",
391
+ "uid": "mcp-analytics-postgres"
392
+ },
393
+ "transparent": true,
394
+ "description": "Successful terminal tool attempts / all successful or failed terminal attempts. Intermediate/pending results do not enter this denominator.",
395
+ "fieldConfig": {
396
+ "defaults": {
397
+ "color": {
398
+ "mode": "fixed",
399
+ "fixedColor": "#635bff"
400
+ },
401
+ "mappings": [],
402
+ "noValue": "—",
403
+ "thresholds": {
404
+ "mode": "absolute",
405
+ "steps": [
406
+ {
407
+ "color": "green",
408
+ "value": null
409
+ }
410
+ ]
411
+ },
412
+ "unit": "percent",
413
+ "decimals": 1
414
+ },
415
+ "overrides": []
416
+ },
417
+ "options": {
418
+ "reduceOptions": {
419
+ "calcs": [
420
+ "lastNotNull"
421
+ ],
422
+ "fields": "",
423
+ "values": false
424
+ },
425
+ "colorMode": "none",
426
+ "graphMode": "none",
427
+ "justifyMode": "left",
428
+ "textMode": "auto",
429
+ "wideLayout": true,
430
+ "orientation": "horizontal"
431
+ },
432
+ "targets": [
433
+ {
434
+ "refId": "A",
435
+ "datasource": {
436
+ "type": "grafana-postgresql-datasource",
437
+ "uid": "mcp-analytics-postgres"
438
+ },
439
+ "editorMode": "code",
440
+ "format": "table",
441
+ "rawQuery": true,
442
+ "rawSql": "SELECT 100.0 * COUNT(*) FILTER (WHERE e.outcome = 'ok')\n / NULLIF(COUNT(*) FILTER (WHERE e.outcome IN ('ok', 'tool_error', 'exception')), 0) AS \"Success rate\" FROM mcp_analytics.grafana_events e\nWHERE e.occurred_at >= $__timeFrom()::timestamptz\n AND e.occurred_at < LEAST(NOW(), $__timeTo()::timestamptz)\n AND e.project_id IN (${project:sqlstring})\n AND e.server_id IN (${server:sqlstring})\n AND e.environment IN (${environment:sqlstring})\n AND COALESCE(e.client_application, 'unknown') IN (${client:sqlstring})\n AND e.kind = 'tool_call'"
443
+ }
444
+ ]
445
+ },
446
+ {
447
+ "id": 10,
448
+ "type": "stat",
449
+ "title": "p95 server duration",
450
+ "gridPos": {
451
+ "x": 18,
452
+ "y": 2,
453
+ "w": 6,
454
+ "h": 4
455
+ },
456
+ "datasource": {
457
+ "type": "grafana-postgresql-datasource",
458
+ "uid": "mcp-analytics-postgres"
459
+ },
460
+ "transparent": true,
461
+ "description": "Observed terminal handler duration, not client-perceived latency. Missing duration samples are unavailable, not zero.",
462
+ "fieldConfig": {
463
+ "defaults": {
464
+ "color": {
465
+ "mode": "fixed",
466
+ "fixedColor": "#635bff"
467
+ },
468
+ "mappings": [],
469
+ "noValue": "—",
470
+ "thresholds": {
471
+ "mode": "absolute",
472
+ "steps": [
473
+ {
474
+ "color": "green",
475
+ "value": null
476
+ }
477
+ ]
478
+ },
479
+ "unit": "ms"
480
+ },
481
+ "overrides": []
482
+ },
483
+ "options": {
484
+ "reduceOptions": {
485
+ "calcs": [
486
+ "lastNotNull"
487
+ ],
488
+ "fields": "",
489
+ "values": false
490
+ },
491
+ "colorMode": "none",
492
+ "graphMode": "none",
493
+ "justifyMode": "left",
494
+ "textMode": "auto",
495
+ "wideLayout": true,
496
+ "orientation": "horizontal"
497
+ },
498
+ "targets": [
499
+ {
500
+ "refId": "A",
501
+ "datasource": {
502
+ "type": "grafana-postgresql-datasource",
503
+ "uid": "mcp-analytics-postgres"
504
+ },
505
+ "editorMode": "code",
506
+ "format": "table",
507
+ "rawQuery": true,
508
+ "rawSql": "SELECT percentile_cont(0.95) WITHIN GROUP (ORDER BY e.duration_ms)\n FILTER (WHERE e.duration_ms IS NOT NULL AND e.outcome IN ('ok', 'tool_error', 'exception')) AS \"p95 server duration\" FROM mcp_analytics.grafana_events e\nWHERE e.occurred_at >= $__timeFrom()::timestamptz\n AND e.occurred_at < LEAST(NOW(), $__timeTo()::timestamptz)\n AND e.project_id IN (${project:sqlstring})\n AND e.server_id IN (${server:sqlstring})\n AND e.environment IN (${environment:sqlstring})\n AND COALESCE(e.client_application, 'unknown') IN (${client:sqlstring})\n AND e.kind = 'tool_call'"
509
+ }
510
+ ]
511
+ },
512
+ {
513
+ "id": 2,
514
+ "type": "timeseries",
515
+ "title": "Activity",
516
+ "gridPos": {
517
+ "x": 0,
518
+ "y": 6,
519
+ "w": 24,
520
+ "h": 8
521
+ },
522
+ "datasource": {
523
+ "type": "grafana-postgresql-datasource",
524
+ "uid": "mcp-analytics-postgres"
525
+ },
526
+ "transparent": true,
527
+ "description": "Distinct tool attempts and identified users per UTC day. Intermediate input-required attempts remain attempts; calls without an identity stay out of user counts.",
528
+ "fieldConfig": {
529
+ "defaults": {
530
+ "color": {
531
+ "mode": "fixed",
532
+ "fixedColor": "#635bff"
533
+ },
534
+ "mappings": [],
535
+ "noValue": "—",
536
+ "thresholds": {
537
+ "mode": "absolute",
538
+ "steps": [
539
+ {
540
+ "color": "green",
541
+ "value": null
542
+ }
543
+ ]
544
+ },
545
+ "unit": "locale",
546
+ "decimals": 0,
547
+ "custom": {
548
+ "drawStyle": "line",
549
+ "lineInterpolation": "smooth",
550
+ "lineWidth": 2,
551
+ "fillOpacity": 8,
552
+ "gradientMode": "none",
553
+ "spanNulls": false,
554
+ "showPoints": "never",
555
+ "pointSize": 4,
556
+ "axisPlacement": "auto",
557
+ "axisLabel": "",
558
+ "scaleDistribution": {
559
+ "type": "linear"
560
+ },
561
+ "hideFrom": {
562
+ "legend": false,
563
+ "tooltip": false,
564
+ "viz": false
565
+ }
566
+ }
567
+ },
568
+ "overrides": [
569
+ {
570
+ "matcher": {
571
+ "id": "byName",
572
+ "options": "Tool calls"
573
+ },
574
+ "properties": [
575
+ {
576
+ "id": "color",
577
+ "value": {
578
+ "mode": "fixed",
579
+ "fixedColor": "#635bff"
580
+ }
581
+ }
582
+ ]
583
+ },
584
+ {
585
+ "matcher": {
586
+ "id": "byName",
587
+ "options": "Active users"
588
+ },
589
+ "properties": [
590
+ {
591
+ "id": "color",
592
+ "value": {
593
+ "mode": "fixed",
594
+ "fixedColor": "#00a389"
595
+ }
596
+ }
597
+ ]
598
+ }
599
+ ]
600
+ },
601
+ "options": {
602
+ "tooltip": {
603
+ "mode": "multi",
604
+ "sort": "none"
605
+ },
606
+ "legend": {
607
+ "displayMode": "list",
608
+ "placement": "bottom",
609
+ "showLegend": true
610
+ }
611
+ },
612
+ "targets": [
613
+ {
614
+ "refId": "A",
615
+ "datasource": {
616
+ "type": "grafana-postgresql-datasource",
617
+ "uid": "mcp-analytics-postgres"
618
+ },
619
+ "editorMode": "code",
620
+ "format": "time_series",
621
+ "rawQuery": true,
622
+ "rawSql": "SELECT $__timeGroupAlias(e.occurred_at, '1d'),\n COUNT(*) AS \"Tool calls\",\n COUNT(DISTINCT (e.project_id, e.subject_hash, e.identity_key_version))\n FILTER (WHERE e.subject_hash IS NOT NULL) AS \"Active users\"\nFROM mcp_analytics.grafana_events e\nWHERE e.occurred_at >= $__timeFrom()::timestamptz\n AND e.occurred_at < LEAST(NOW(), $__timeTo()::timestamptz)\n AND e.project_id IN (${project:sqlstring})\n AND e.server_id IN (${server:sqlstring})\n AND e.environment IN (${environment:sqlstring})\n AND COALESCE(e.client_application, 'unknown') IN (${client:sqlstring})\n AND e.kind = 'tool_call'\nGROUP BY 1\nORDER BY 1"
623
+ }
624
+ ]
625
+ },
626
+ {
627
+ "id": 11,
628
+ "type": "table",
629
+ "title": "Tools",
630
+ "gridPos": {
631
+ "x": 0,
632
+ "y": 14,
633
+ "w": 14,
634
+ "h": 7
635
+ },
636
+ "datasource": {
637
+ "type": "grafana-postgresql-datasource",
638
+ "uid": "mcp-analytics-postgres"
639
+ },
640
+ "transparent": true,
641
+ "description": "Configured aliases only. No arguments, results, or raw errors. Counts include all attempts; success and latency use known terminal results.",
642
+ "fieldConfig": {
643
+ "defaults": {
644
+ "color": {
645
+ "mode": "fixed",
646
+ "fixedColor": "#635bff"
647
+ },
648
+ "mappings": [],
649
+ "noValue": "—",
650
+ "thresholds": {
651
+ "mode": "absolute",
652
+ "steps": [
653
+ {
654
+ "color": "green",
655
+ "value": null
656
+ }
657
+ ]
658
+ },
659
+ "unit": "locale",
660
+ "decimals": 0
661
+ },
662
+ "overrides": [
663
+ {
664
+ "matcher": {
665
+ "id": "byName",
666
+ "options": "Success"
667
+ },
668
+ "properties": [
669
+ {
670
+ "id": "unit",
671
+ "value": "percent"
672
+ },
673
+ {
674
+ "id": "decimals",
675
+ "value": 1
676
+ }
677
+ ]
678
+ },
679
+ {
680
+ "matcher": {
681
+ "id": "byName",
682
+ "options": "p95"
683
+ },
684
+ "properties": [
685
+ {
686
+ "id": "unit",
687
+ "value": "ms"
688
+ },
689
+ {
690
+ "id": "decimals",
691
+ "value": null
692
+ }
693
+ ]
694
+ }
695
+ ]
696
+ },
697
+ "options": {
698
+ "showHeader": true,
699
+ "cellHeight": "sm",
700
+ "footer": {
701
+ "show": false
702
+ },
703
+ "sortBy": []
704
+ },
705
+ "targets": [
706
+ {
707
+ "refId": "A",
708
+ "datasource": {
709
+ "type": "grafana-postgresql-datasource",
710
+ "uid": "mcp-analytics-postgres"
711
+ },
712
+ "editorMode": "code",
713
+ "format": "table",
714
+ "rawQuery": true,
715
+ "rawSql": "SELECT COALESCE(e.tool_name, '__unknown_tool__') AS \"Tool\",\n COUNT(*) AS \"Calls\", 100.0 * COUNT(*) FILTER (WHERE e.outcome = 'ok')\n / NULLIF(COUNT(*) FILTER (WHERE e.outcome IN ('ok', 'tool_error', 'exception')), 0) AS \"Success\", percentile_cont(0.95) WITHIN GROUP (ORDER BY e.duration_ms)\n FILTER (WHERE e.duration_ms IS NOT NULL AND e.outcome IN ('ok', 'tool_error', 'exception')) AS \"p95\"\nFROM mcp_analytics.grafana_events e\nWHERE e.occurred_at >= $__timeFrom()::timestamptz\n AND e.occurred_at < LEAST(NOW(), $__timeTo()::timestamptz)\n AND e.project_id IN (${project:sqlstring})\n AND e.server_id IN (${server:sqlstring})\n AND e.environment IN (${environment:sqlstring})\n AND COALESCE(e.client_application, 'unknown') IN (${client:sqlstring})\n AND e.kind = 'tool_call'\nGROUP BY 1 ORDER BY \"Calls\" DESC, \"Tool\" LIMIT 20"
716
+ }
717
+ ]
718
+ },
719
+ {
720
+ "id": 12,
721
+ "type": "table",
722
+ "title": "Clients",
723
+ "gridPos": {
724
+ "x": 14,
725
+ "y": 14,
726
+ "w": 10,
727
+ "h": 7
728
+ },
729
+ "datasource": {
730
+ "type": "grafana-postgresql-datasource",
731
+ "uid": "mcp-analytics-postgres"
732
+ },
733
+ "transparent": true,
734
+ "description": "Observed client application labels. Client identity is evidence, not verified end-user host identity. A user can appear under several clients in this breakdown.",
735
+ "fieldConfig": {
736
+ "defaults": {
737
+ "color": {
738
+ "mode": "fixed",
739
+ "fixedColor": "#635bff"
740
+ },
741
+ "mappings": [],
742
+ "noValue": "—",
743
+ "thresholds": {
744
+ "mode": "absolute",
745
+ "steps": [
746
+ {
747
+ "color": "green",
748
+ "value": null
749
+ }
750
+ ]
751
+ },
752
+ "unit": "locale",
753
+ "decimals": 0
754
+ },
755
+ "overrides": [
756
+ {
757
+ "matcher": {
758
+ "id": "byName",
759
+ "options": "Success"
760
+ },
761
+ "properties": [
762
+ {
763
+ "id": "unit",
764
+ "value": "percent"
765
+ },
766
+ {
767
+ "id": "decimals",
768
+ "value": 1
769
+ }
770
+ ]
771
+ },
772
+ {
773
+ "matcher": {
774
+ "id": "byName",
775
+ "options": "p95"
776
+ },
777
+ "properties": [
778
+ {
779
+ "id": "unit",
780
+ "value": "ms"
781
+ },
782
+ {
783
+ "id": "decimals",
784
+ "value": null
785
+ }
786
+ ]
787
+ }
788
+ ]
789
+ },
790
+ "options": {
791
+ "showHeader": true,
792
+ "cellHeight": "sm",
793
+ "footer": {
794
+ "show": false
795
+ },
796
+ "sortBy": []
797
+ },
798
+ "targets": [
799
+ {
800
+ "refId": "A",
801
+ "datasource": {
802
+ "type": "grafana-postgresql-datasource",
803
+ "uid": "mcp-analytics-postgres"
804
+ },
805
+ "editorMode": "code",
806
+ "format": "table",
807
+ "rawQuery": true,
808
+ "rawSql": "SELECT COALESCE(e.client_application, 'unknown') AS \"Client\",\n COUNT(*) AS \"Calls\", COUNT(DISTINCT (e.project_id, e.subject_hash, e.identity_key_version))\n FILTER (WHERE e.subject_hash IS NOT NULL) AS \"Active users\", 100.0 * COUNT(*) FILTER (WHERE e.outcome = 'ok')\n / NULLIF(COUNT(*) FILTER (WHERE e.outcome IN ('ok', 'tool_error', 'exception')), 0) AS \"Success\"\nFROM mcp_analytics.grafana_events e\nWHERE e.occurred_at >= $__timeFrom()::timestamptz\n AND e.occurred_at < LEAST(NOW(), $__timeTo()::timestamptz)\n AND e.project_id IN (${project:sqlstring})\n AND e.server_id IN (${server:sqlstring})\n AND e.environment IN (${environment:sqlstring})\n AND COALESCE(e.client_application, 'unknown') IN (${client:sqlstring})\n AND e.kind = 'tool_call'\nGROUP BY 1 ORDER BY \"Calls\" DESC, \"Client\" LIMIT 20"
809
+ }
810
+ ]
811
+ },
812
+ {
813
+ "id": 3,
814
+ "type": "bargauge",
815
+ "title": "7-day activation",
816
+ "gridPos": {
817
+ "x": 0,
818
+ "y": 21,
819
+ "w": 14,
820
+ "h": 6
821
+ },
822
+ "datasource": {
823
+ "type": "grafana-postgresql-datasource",
824
+ "uid": "mcp-analytics-postgres"
825
+ },
826
+ "transparent": true,
827
+ "description": "Users who authorized or were first observed during the selected range (see the Cohort filter), grouped by their entry client. Existing users from the start of retained history are excluded. Only cohorts with seven complete days before the range end (or now) enter these bars. The value action comes from the configured dataset definition and is unavailable when none is configured.",
828
+ "fieldConfig": {
829
+ "defaults": {
830
+ "color": {
831
+ "mode": "fixed",
832
+ "fixedColor": "#635bff"
833
+ },
834
+ "mappings": [],
835
+ "noValue": "—",
836
+ "thresholds": {
837
+ "mode": "absolute",
838
+ "steps": [
839
+ {
840
+ "color": "green",
841
+ "value": null
842
+ }
843
+ ]
844
+ },
845
+ "unit": "locale",
846
+ "decimals": 0,
847
+ "min": 0
848
+ },
849
+ "overrides": []
850
+ },
851
+ "options": {
852
+ "orientation": "horizontal",
853
+ "displayMode": "basic",
854
+ "showUnfilled": true,
855
+ "reduceOptions": {
856
+ "calcs": [
857
+ "lastNotNull"
858
+ ],
859
+ "fields": "",
860
+ "values": false
861
+ },
862
+ "text": {},
863
+ "minVizWidth": 0,
864
+ "minVizHeight": 10
865
+ },
866
+ "targets": [
867
+ {
868
+ "refId": "A",
869
+ "datasource": {
870
+ "type": "grafana-postgresql-datasource",
871
+ "uid": "mcp-analytics-postgres"
872
+ },
873
+ "editorMode": "code",
874
+ "format": "table",
875
+ "rawQuery": true,
876
+ "rawSql": "WITH cutoff AS (\n SELECT LEAST(NOW(), $__timeTo()::timestamptz) AS as_of\n), in_range AS (\n SELECT c.*, cutoff.as_of\n FROM cutoff CROSS JOIN LATERAL mcp_analytics.subject_cohorts_at(cutoff.as_of,\n ARRAY[${project:sqlstring}], ARRAY[${server:sqlstring}], ARRAY[${environment:sqlstring}],\n $__timeFrom()::timestamptz) c\n WHERE c.cohort_started_at >= $__timeFrom()::timestamptz\n AND c.cohort_started_at < cutoff.as_of\n AND c.project_id IN (${project:sqlstring})\n AND c.server_id IN (${server:sqlstring})\n AND c.environment IN (${environment:sqlstring})\n AND COALESCE(c.client_application, 'unknown') IN (${client:sqlstring})\n), selected AS (\n SELECT * FROM in_range WHERE cohort_kind IN (${cohort:sqlstring})\n), configured AS (\n SELECT EXISTS (SELECT 1 FROM mcp_analytics.grafana_settings s\n WHERE s.project_id IN (${project:sqlstring})\n AND s.server_id IN (${server:sqlstring})\n AND s.environment IN (${environment:sqlstring})) AS value_configured\n)\nSELECT\n COUNT(*) FILTER (WHERE cohort_started_at <= as_of - INTERVAL '7 days') AS \"Eligible users\",\n COUNT(*) FILTER (WHERE cohort_started_at <= as_of - INTERVAL '7 days'\n AND first_tool_at >= cohort_started_at\n AND first_tool_at < cohort_started_at + INTERVAL '7 days'\n AND first_tool_at < as_of) AS \"First tool attempt\",\n CASE WHEN (SELECT value_configured FROM configured) THEN\n COUNT(*) FILTER (WHERE cohort_started_at <= as_of - INTERVAL '7 days'\n AND activated_at < as_of) END AS \"Successful value action\"\nFROM selected"
877
+ }
878
+ ]
879
+ },
880
+ {
881
+ "id": 4,
882
+ "type": "stat",
883
+ "title": "Week-two return",
884
+ "gridPos": {
885
+ "x": 14,
886
+ "y": 21,
887
+ "w": 10,
888
+ "h": 3
889
+ },
890
+ "datasource": {
891
+ "type": "grafana-postgresql-datasource",
892
+ "uid": "mcp-analytics-postgres"
893
+ },
894
+ "transparent": true,
895
+ "description": "Among activated users with 14 complete follow-up days at the range end (or now), the share returning for another successful value action in [activation + 7 days, activation + 14 days). No eligible denominator, including an unconfigured value action, is shown as unavailable.",
896
+ "fieldConfig": {
897
+ "defaults": {
898
+ "color": {
899
+ "mode": "fixed",
900
+ "fixedColor": "#635bff"
901
+ },
902
+ "mappings": [],
903
+ "noValue": "—",
904
+ "thresholds": {
905
+ "mode": "absolute",
906
+ "steps": [
907
+ {
908
+ "color": "green",
909
+ "value": null
910
+ }
911
+ ]
912
+ },
913
+ "unit": "percent",
914
+ "decimals": 1,
915
+ "min": 0,
916
+ "max": 100
917
+ },
918
+ "overrides": []
919
+ },
920
+ "options": {
921
+ "reduceOptions": {
922
+ "calcs": [
923
+ "lastNotNull"
924
+ ],
925
+ "fields": "",
926
+ "values": false
927
+ },
928
+ "colorMode": "none",
929
+ "graphMode": "none",
930
+ "textMode": "auto",
931
+ "justifyMode": "left",
932
+ "wideLayout": true
933
+ },
934
+ "targets": [
935
+ {
936
+ "refId": "A",
937
+ "datasource": {
938
+ "type": "grafana-postgresql-datasource",
939
+ "uid": "mcp-analytics-postgres"
940
+ },
941
+ "editorMode": "code",
942
+ "format": "table",
943
+ "rawQuery": true,
944
+ "rawSql": "WITH cutoff AS (\n SELECT LEAST(NOW(), $__timeTo()::timestamptz) AS as_of\n), in_range AS (\n SELECT c.*, cutoff.as_of\n FROM cutoff CROSS JOIN LATERAL mcp_analytics.subject_cohorts_at(cutoff.as_of,\n ARRAY[${project:sqlstring}], ARRAY[${server:sqlstring}], ARRAY[${environment:sqlstring}],\n $__timeFrom()::timestamptz) c\n WHERE c.cohort_started_at >= $__timeFrom()::timestamptz\n AND c.cohort_started_at < cutoff.as_of\n AND c.project_id IN (${project:sqlstring})\n AND c.server_id IN (${server:sqlstring})\n AND c.environment IN (${environment:sqlstring})\n AND COALESCE(c.client_application, 'unknown') IN (${client:sqlstring})\n), selected AS (\n SELECT * FROM in_range WHERE cohort_kind IN (${cohort:sqlstring})\n), configured AS (\n SELECT EXISTS (SELECT 1 FROM mcp_analytics.grafana_settings s\n WHERE s.project_id IN (${project:sqlstring})\n AND s.server_id IN (${server:sqlstring})\n AND s.environment IN (${environment:sqlstring})) AS value_configured\n)\nSELECT 100.0 * COUNT(*) FILTER (WHERE activated_at + INTERVAL '14 days' <= as_of\n AND returned_week_two_at < as_of)\n / NULLIF(COUNT(*) FILTER (WHERE activated_at + INTERVAL '14 days' <= as_of), 0)\n AS \"Week-two return\"\nFROM selected"
945
+ }
946
+ ]
947
+ },
948
+ {
949
+ "id": 5,
950
+ "type": "stat",
951
+ "title": "Activation window still open",
952
+ "gridPos": {
953
+ "x": 14,
954
+ "y": 24,
955
+ "w": 10,
956
+ "h": 3
957
+ },
958
+ "datasource": {
959
+ "type": "grafana-postgresql-datasource",
960
+ "uid": "mcp-analytics-postgres"
961
+ },
962
+ "transparent": true,
963
+ "description": "Newer cohorts have not had a complete seven-day opportunity to activate. They are pending, not failures. Existing users are not counted.",
964
+ "fieldConfig": {
965
+ "defaults": {
966
+ "color": {
967
+ "mode": "fixed",
968
+ "fixedColor": "#635bff"
969
+ },
970
+ "mappings": [],
971
+ "noValue": "—",
972
+ "thresholds": {
973
+ "mode": "absolute",
974
+ "steps": [
975
+ {
976
+ "color": "green",
977
+ "value": null
978
+ }
979
+ ]
980
+ },
981
+ "unit": "locale",
982
+ "decimals": 0
983
+ },
984
+ "overrides": []
985
+ },
986
+ "options": {
987
+ "reduceOptions": {
988
+ "calcs": [
989
+ "lastNotNull"
990
+ ],
991
+ "fields": "",
992
+ "values": false
993
+ },
994
+ "colorMode": "none",
995
+ "graphMode": "none",
996
+ "textMode": "auto",
997
+ "justifyMode": "left",
998
+ "wideLayout": true
999
+ },
1000
+ "targets": [
1001
+ {
1002
+ "refId": "A",
1003
+ "datasource": {
1004
+ "type": "grafana-postgresql-datasource",
1005
+ "uid": "mcp-analytics-postgres"
1006
+ },
1007
+ "editorMode": "code",
1008
+ "format": "table",
1009
+ "rawQuery": true,
1010
+ "rawSql": "WITH cutoff AS (\n SELECT LEAST(NOW(), $__timeTo()::timestamptz) AS as_of\n), in_range AS (\n SELECT c.*, cutoff.as_of\n FROM cutoff CROSS JOIN LATERAL mcp_analytics.subject_cohorts_at(cutoff.as_of,\n ARRAY[${project:sqlstring}], ARRAY[${server:sqlstring}], ARRAY[${environment:sqlstring}],\n $__timeFrom()::timestamptz) c\n WHERE c.cohort_started_at >= $__timeFrom()::timestamptz\n AND c.cohort_started_at < cutoff.as_of\n AND c.project_id IN (${project:sqlstring})\n AND c.server_id IN (${server:sqlstring})\n AND c.environment IN (${environment:sqlstring})\n AND COALESCE(c.client_application, 'unknown') IN (${client:sqlstring})\n), selected AS (\n SELECT * FROM in_range WHERE cohort_kind IN (${cohort:sqlstring})\n), configured AS (\n SELECT EXISTS (SELECT 1 FROM mcp_analytics.grafana_settings s\n WHERE s.project_id IN (${project:sqlstring})\n AND s.server_id IN (${server:sqlstring})\n AND s.environment IN (${environment:sqlstring})) AS value_configured\n)\nSELECT COUNT(*) FILTER (WHERE cohort_started_at > as_of - INTERVAL '7 days') AS \"Pending users\"\nFROM selected"
1011
+ }
1012
+ ]
1013
+ },
1014
+ {
1015
+ "id": 6,
1016
+ "type": "table",
1017
+ "title": "Coverage & cohort denominators",
1018
+ "gridPos": {
1019
+ "x": 0,
1020
+ "y": 27,
1021
+ "w": 24,
1022
+ "h": 4
1023
+ },
1024
+ "datasource": {
1025
+ "type": "grafana-postgresql-datasource",
1026
+ "uid": "mcp-analytics-postgres"
1027
+ },
1028
+ "transparent": true,
1029
+ "description": "Coverage describes observed tool attempts. Existing users were already active when the retained history began, or within the configured window after it; they are excluded from adoption. Adoption denominators describe users who authorized or were first observed in the selected range. Value action states the configured definition for the selected datasets. Missing identity/client evidence is never treated as a new person or silently discarded from usage totals.",
1030
+ "fieldConfig": {
1031
+ "defaults": {
1032
+ "color": {
1033
+ "mode": "fixed",
1034
+ "fixedColor": "#635bff"
1035
+ },
1036
+ "mappings": [],
1037
+ "noValue": "—",
1038
+ "thresholds": {
1039
+ "mode": "absolute",
1040
+ "steps": [
1041
+ {
1042
+ "color": "green",
1043
+ "value": null
1044
+ }
1045
+ ]
1046
+ },
1047
+ "unit": "locale",
1048
+ "decimals": 0
1049
+ },
1050
+ "overrides": [
1051
+ {
1052
+ "matcher": {
1053
+ "id": "byName",
1054
+ "options": "Identified calls"
1055
+ },
1056
+ "properties": [
1057
+ {
1058
+ "id": "unit",
1059
+ "value": "percent"
1060
+ },
1061
+ {
1062
+ "id": "decimals",
1063
+ "value": 1
1064
+ }
1065
+ ]
1066
+ },
1067
+ {
1068
+ "matcher": {
1069
+ "id": "byName",
1070
+ "options": "Known-client calls"
1071
+ },
1072
+ "properties": [
1073
+ {
1074
+ "id": "unit",
1075
+ "value": "percent"
1076
+ },
1077
+ {
1078
+ "id": "decimals",
1079
+ "value": 1
1080
+ }
1081
+ ]
1082
+ }
1083
+ ]
1084
+ },
1085
+ "options": {
1086
+ "showHeader": true,
1087
+ "cellHeight": "sm",
1088
+ "footer": {
1089
+ "show": false
1090
+ },
1091
+ "sortBy": []
1092
+ },
1093
+ "targets": [
1094
+ {
1095
+ "refId": "A",
1096
+ "datasource": {
1097
+ "type": "grafana-postgresql-datasource",
1098
+ "uid": "mcp-analytics-postgres"
1099
+ },
1100
+ "editorMode": "code",
1101
+ "format": "table",
1102
+ "rawQuery": true,
1103
+ "rawSql": "WITH cutoff AS (\n SELECT LEAST(NOW(), $__timeTo()::timestamptz) AS as_of\n), in_range AS (\n SELECT c.*, cutoff.as_of\n FROM cutoff CROSS JOIN LATERAL mcp_analytics.subject_cohorts_at(cutoff.as_of,\n ARRAY[${project:sqlstring}], ARRAY[${server:sqlstring}], ARRAY[${environment:sqlstring}],\n $__timeFrom()::timestamptz) c\n WHERE c.cohort_started_at >= $__timeFrom()::timestamptz\n AND c.cohort_started_at < cutoff.as_of\n AND c.project_id IN (${project:sqlstring})\n AND c.server_id IN (${server:sqlstring})\n AND c.environment IN (${environment:sqlstring})\n AND COALESCE(c.client_application, 'unknown') IN (${client:sqlstring})\n), selected AS (\n SELECT * FROM in_range WHERE cohort_kind IN (${cohort:sqlstring})\n), configured AS (\n SELECT EXISTS (SELECT 1 FROM mcp_analytics.grafana_settings s\n WHERE s.project_id IN (${project:sqlstring})\n AND s.server_id IN (${server:sqlstring})\n AND s.environment IN (${environment:sqlstring})) AS value_configured\n), calls AS (\n SELECT e.* FROM mcp_analytics.grafana_events e\nWHERE e.occurred_at >= $__timeFrom()::timestamptz\n AND e.occurred_at < LEAST(NOW(), $__timeTo()::timestamptz)\n AND e.project_id IN (${project:sqlstring})\n AND e.server_id IN (${server:sqlstring})\n AND e.environment IN (${environment:sqlstring})\n AND COALESCE(e.client_application, 'unknown') IN (${client:sqlstring})\n AND e.kind = 'tool_call'\n), call_totals AS (\n SELECT COUNT(*) AS calls,\n COUNT(*) FILTER (WHERE subject_hash IS NOT NULL) AS identified,\n COUNT(*) FILTER (WHERE COALESCE(client_application, 'unknown') <> 'unknown') AS known_client\n FROM calls\n), definitions AS (\n SELECT CASE WHEN s.value_mode = 'application' THEN 'Application completion'\n ELSE s.value_tool || ' (tool)' END AS definition\n FROM mcp_analytics.grafana_settings s\n WHERE s.project_id IN (${project:sqlstring})\n AND s.server_id IN (${server:sqlstring})\n AND s.environment IN (${environment:sqlstring})\n UNION\n SELECT 'Not configured' FROM in_range WHERE NOT value_configured\n)\nSELECT\n 100.0 * MAX(identified) / NULLIF(MAX(calls), 0) AS \"Identified calls\",\n 100.0 * MAX(known_client) / NULLIF(MAX(calls), 0) AS \"Known-client calls\",\n (SELECT COUNT(*) FROM in_range WHERE cohort_kind = 'existing') AS \"Existing users\",\n COUNT(*) FILTER (WHERE cohort_started_at <= as_of - INTERVAL '7 days') AS \"Activation eligible\",\n COUNT(*) FILTER (WHERE cohort_started_at > as_of - INTERVAL '7 days') AS \"Activation pending\",\n COUNT(*) FILTER (WHERE activated_at + INTERVAL '14 days' <= as_of) AS \"Retention eligible\",\n COUNT(*) FILTER (WHERE activated_at < as_of AND activated_at + INTERVAL '14 days' > as_of) AS \"Retention pending\",\n (SELECT CASE COUNT(*) WHEN 0 THEN 'Not configured' WHEN 1 THEN MIN(definition) ELSE 'Mixed' END\n FROM definitions) AS \"Value action\"\nFROM call_totals LEFT JOIN selected ON TRUE"
1104
+ }
1105
+ ]
1106
+ }
1107
+ ]
1108
+ }