local-ttft.json 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. {
  2. "title": "ZCode 本地发送 TTFT",
  3. "uid": "zcode-local-ttft-v1",
  4. "schemaVersion": 39,
  5. "version": 2,
  6. "refresh": "30s",
  7. "time": {
  8. "from": "now-1h",
  9. "to": "now"
  10. },
  11. "__inputs": [
  12. {
  13. "name": "DS_PROMETHEUS",
  14. "label": "ARMS Prometheus",
  15. "type": "datasource",
  16. "pluginId": "prometheus",
  17. "pluginName": "Prometheus"
  18. }
  19. ],
  20. "templating": {
  21. "list": [
  22. {
  23. "name": "total_metric",
  24. "type": "textbox",
  25. "query": "zcode_local_ttft_duration",
  26. "current": {
  27. "text": "zcode_local_ttft_duration",
  28. "value": "zcode_local_ttft_duration"
  29. }
  30. },
  31. {
  32. "name": "stage_metric",
  33. "type": "textbox",
  34. "query": "zcode_local_ttft_stage_duration",
  35. "current": {
  36. "text": "zcode_local_ttft_stage_duration",
  37. "value": "zcode_local_ttft_stage_duration"
  38. }
  39. },
  40. {
  41. "name": "provider",
  42. "type": "textbox",
  43. "query": ".*",
  44. "current": {
  45. "text": ".*",
  46. "value": ".*"
  47. }
  48. },
  49. {
  50. "name": "model",
  51. "type": "textbox",
  52. "query": ".*",
  53. "current": {
  54. "text": ".*",
  55. "value": ".*"
  56. }
  57. },
  58. {
  59. "name": "app_version",
  60. "type": "textbox",
  61. "query": ".*",
  62. "current": {
  63. "text": ".*",
  64. "value": ".*"
  65. }
  66. },
  67. {
  68. "name": "os",
  69. "type": "textbox",
  70. "query": ".*",
  71. "current": {
  72. "text": ".*",
  73. "value": ".*"
  74. }
  75. },
  76. {
  77. "name": "visibility",
  78. "type": "custom",
  79. "query": "foreground,background_returned,background",
  80. "includeAll": true,
  81. "allValue": ".*",
  82. "current": {
  83. "text": "foreground",
  84. "value": "foreground"
  85. }
  86. },
  87. {
  88. "name": "send_mode",
  89. "type": "custom",
  90. "query": "idle,queued",
  91. "includeAll": true,
  92. "allValue": ".*",
  93. "current": {
  94. "text": ".*",
  95. "value": ".*"
  96. }
  97. }
  98. ]
  99. },
  100. "panels": [
  101. {
  102. "id": 1,
  103. "title": "点击到首有效输出 P50/P95 (ms)",
  104. "type": "timeseries",
  105. "datasource": {
  106. "type": "prometheus",
  107. "uid": "${DS_PROMETHEUS}"
  108. },
  109. "gridPos": {
  110. "x": 0,
  111. "y": 0,
  112. "w": 24,
  113. "h": 9
  114. },
  115. "fieldConfig": {
  116. "defaults": {
  117. "unit": "ms"
  118. }
  119. },
  120. "targets": [
  121. {
  122. "refId": "A",
  123. "expr": "histogram_quantile(0.5, sum by (le) (sum_over_time(${total_metric}_bucket{provider=~\"$provider\",model=~\"$model\",app_version=~\"$app_version\",os=~\"$os\",quality=\"complete\",visibility=~\"$visibility\",send_mode=~\"$send_mode\"}[5m])))",
  124. "legendFormat": "P50 {{stage}}"
  125. },
  126. {
  127. "refId": "B",
  128. "expr": "histogram_quantile(0.95, sum by (le) (sum_over_time(${total_metric}_bucket{provider=~\"$provider\",model=~\"$model\",app_version=~\"$app_version\",os=~\"$os\",quality=\"complete\",visibility=~\"$visibility\",send_mode=~\"$send_mode\"}[5m])))",
  129. "legendFormat": "P95 {{stage}}"
  130. }
  131. ]
  132. },
  133. {
  134. "id": 2,
  135. "title": "六主阶段 P50/P95 (ms)",
  136. "type": "timeseries",
  137. "datasource": {
  138. "type": "prometheus",
  139. "uid": "${DS_PROMETHEUS}"
  140. },
  141. "gridPos": {
  142. "x": 0,
  143. "y": 9,
  144. "w": 24,
  145. "h": 9
  146. },
  147. "fieldConfig": {
  148. "defaults": {
  149. "unit": "ms"
  150. }
  151. },
  152. "targets": [
  153. {
  154. "refId": "A",
  155. "expr": "histogram_quantile(0.5, sum by (le,stage) (sum_over_time(${stage_metric}_bucket{provider=~\"$provider\",model=~\"$model\",app_version=~\"$app_version\",os=~\"$os\",quality=\"complete\",visibility=~\"$visibility\",send_mode=~\"$send_mode\"}[5m])))",
  156. "legendFormat": "P50 {{stage}}"
  157. },
  158. {
  159. "refId": "B",
  160. "expr": "histogram_quantile(0.95, sum by (le,stage) (sum_over_time(${stage_metric}_bucket{provider=~\"$provider\",model=~\"$model\",app_version=~\"$app_version\",os=~\"$os\",quality=\"complete\",visibility=~\"$visibility\",send_mode=~\"$send_mode\"}[5m])))",
  161. "legendFormat": "P95 {{stage}}"
  162. }
  163. ]
  164. },
  165. {
  166. "id": 3,
  167. "title": "主 TTFT 样本数",
  168. "type": "stat",
  169. "datasource": {
  170. "type": "prometheus",
  171. "uid": "${DS_PROMETHEUS}"
  172. },
  173. "gridPos": {
  174. "x": 0,
  175. "y": 18,
  176. "w": 12,
  177. "h": 5
  178. },
  179. "targets": [
  180. {
  181. "refId": "A",
  182. "expr": "sum (sum_over_time(${total_metric}_count{provider=~\"$provider\",model=~\"$model\",app_version=~\"$app_version\",os=~\"$os\",quality=\"complete\",visibility=~\"$visibility\",send_mode=~\"$send_mode\"}[$__range]))"
  183. }
  184. ]
  185. },
  186. {
  187. "id": 4,
  188. "title": "各阶段样本数",
  189. "type": "stat",
  190. "datasource": {
  191. "type": "prometheus",
  192. "uid": "${DS_PROMETHEUS}"
  193. },
  194. "gridPos": {
  195. "x": 12,
  196. "y": 18,
  197. "w": 12,
  198. "h": 5
  199. },
  200. "targets": [
  201. {
  202. "refId": "A",
  203. "expr": "sum by (stage) (sum_over_time(${stage_metric}_count{provider=~\"$provider\",model=~\"$model\",app_version=~\"$app_version\",os=~\"$os\",quality=\"complete\",visibility=~\"$visibility\",send_mode=~\"$send_mode\"}[$__range]))"
  204. }
  205. ]
  206. },
  207. {
  208. "id": 5,
  209. "title": "分桶精度与单消息关联",
  210. "type": "text",
  211. "gridPos": {
  212. "x": 0,
  213. "y": 23,
  214. "w": 24,
  215. "h": 6
  216. },
  217. "options": {
  218. "mode": "markdown",
  219. "content": "单位 ms;分桶边界:1,5,10,20,50,100,200,500,1000,2000,5000,10000,30000,60000,300000。P50/P95 是桶内插值;须同时读取样本数,不相加分位数。\n\n在 ARMS Trace Explorer 选择 service.name=zcode-local-ttft,按 observation_id 精确过滤,展开 local_ttft 及六阶段。trace ID 为 observation UUID 去掉连字符。Trace 数据源跳转地址需在目标租户验证后配置;当前未通过平台验收。"
  220. }
  221. },
  222. {
  223. "id": 6,
  224. "type": "timeseries",
  225. "title": "准备子阶段 P50 / P95",
  226. "datasource": {
  227. "type": "prometheus",
  228. "uid": "${DS_PROMETHEUS}"
  229. },
  230. "gridPos": {
  231. "x": 0,
  232. "y": 29,
  233. "w": 16,
  234. "h": 7
  235. },
  236. "fieldConfig": {
  237. "defaults": {
  238. "unit": "ms"
  239. }
  240. },
  241. "targets": [
  242. {
  243. "refId": "P50",
  244. "expr": "histogram_quantile(0.5, sum by (le,stage) (sum_over_time(zcode_local_ttft_preparation_duration_bucket{quality=\"complete\",visibility=\"foreground\"}[5m])))",
  245. "legendFormat": "P50 {{stage}}"
  246. },
  247. {
  248. "refId": "P95",
  249. "expr": "histogram_quantile(0.95, sum by (le,stage) (sum_over_time(zcode_local_ttft_preparation_duration_bucket{quality=\"complete\",visibility=\"foreground\"}[5m])))",
  250. "legendFormat": "P95 {{stage}}"
  251. }
  252. ]
  253. },
  254. {
  255. "id": 7,
  256. "type": "stat",
  257. "title": "准备子阶段 样本数",
  258. "datasource": {
  259. "type": "prometheus",
  260. "uid": "${DS_PROMETHEUS}"
  261. },
  262. "gridPos": {
  263. "x": 16,
  264. "y": 29,
  265. "w": 8,
  266. "h": 7
  267. },
  268. "targets": [
  269. {
  270. "refId": "A",
  271. "expr": "sum by (stage) (sum_over_time(zcode_local_ttft_preparation_duration_count{quality=\"complete\",visibility=\"foreground\"}[$__range]))"
  272. }
  273. ]
  274. },
  275. {
  276. "id": 8,
  277. "type": "timeseries",
  278. "title": "开始执行后 TTFT P50 / P95",
  279. "datasource": {
  280. "type": "prometheus",
  281. "uid": "${DS_PROMETHEUS}"
  282. },
  283. "gridPos": {
  284. "x": 0,
  285. "y": 36,
  286. "w": 16,
  287. "h": 7
  288. },
  289. "fieldConfig": {
  290. "defaults": {
  291. "unit": "ms"
  292. }
  293. },
  294. "targets": [
  295. {
  296. "refId": "P50",
  297. "expr": "histogram_quantile(0.5, sum by (le,send_mode) (sum_over_time(zcode_local_ttft_execution_duration_bucket{quality=\"complete\",visibility=\"foreground\"}[5m])))",
  298. "legendFormat": "P50 {{send_mode}}"
  299. },
  300. {
  301. "refId": "P95",
  302. "expr": "histogram_quantile(0.95, sum by (le,send_mode) (sum_over_time(zcode_local_ttft_execution_duration_bucket{quality=\"complete\",visibility=\"foreground\"}[5m])))",
  303. "legendFormat": "P95 {{send_mode}}"
  304. }
  305. ]
  306. },
  307. {
  308. "id": 9,
  309. "type": "stat",
  310. "title": "开始执行后 TTFT 样本数",
  311. "datasource": {
  312. "type": "prometheus",
  313. "uid": "${DS_PROMETHEUS}"
  314. },
  315. "gridPos": {
  316. "x": 16,
  317. "y": 36,
  318. "w": 8,
  319. "h": 7
  320. },
  321. "targets": [
  322. {
  323. "refId": "A",
  324. "expr": "sum by (send_mode) (sum_over_time(zcode_local_ttft_execution_duration_count{quality=\"complete\",visibility=\"foreground\"}[$__range]))"
  325. }
  326. ]
  327. },
  328. {
  329. "id": 10,
  330. "type": "timeseries",
  331. "title": "扣除确认等待的 TTFT P50 / P95",
  332. "datasource": {
  333. "type": "prometheus",
  334. "uid": "${DS_PROMETHEUS}"
  335. },
  336. "gridPos": {
  337. "x": 0,
  338. "y": 43,
  339. "w": 16,
  340. "h": 7
  341. },
  342. "fieldConfig": {
  343. "defaults": {
  344. "unit": "ms"
  345. }
  346. },
  347. "targets": [
  348. {
  349. "refId": "P50",
  350. "expr": "histogram_quantile(0.5, sum by (le,send_mode) (sum_over_time(zcode_local_ttft_system_duration_bucket{quality=\"complete\",visibility=\"foreground\"}[5m])))",
  351. "legendFormat": "P50 {{send_mode}}"
  352. },
  353. {
  354. "refId": "P95",
  355. "expr": "histogram_quantile(0.95, sum by (le,send_mode) (sum_over_time(zcode_local_ttft_system_duration_bucket{quality=\"complete\",visibility=\"foreground\"}[5m])))",
  356. "legendFormat": "P95 {{send_mode}}"
  357. }
  358. ]
  359. },
  360. {
  361. "id": 11,
  362. "type": "stat",
  363. "title": "扣除确认等待的 TTFT 样本数",
  364. "datasource": {
  365. "type": "prometheus",
  366. "uid": "${DS_PROMETHEUS}"
  367. },
  368. "gridPos": {
  369. "x": 16,
  370. "y": 43,
  371. "w": 8,
  372. "h": 7
  373. },
  374. "targets": [
  375. {
  376. "refId": "A",
  377. "expr": "sum by (send_mode) (sum_over_time(zcode_local_ttft_system_duration_count{quality=\"complete\",visibility=\"foreground\"}[$__range]))"
  378. }
  379. ]
  380. },
  381. {
  382. "id": 12,
  383. "type": "timeseries",
  384. "title": "无首输出等待(明确结果) P50 / P95",
  385. "datasource": {
  386. "type": "prometheus",
  387. "uid": "${DS_PROMETHEUS}"
  388. },
  389. "gridPos": {
  390. "x": 0,
  391. "y": 50,
  392. "w": 16,
  393. "h": 7
  394. },
  395. "fieldConfig": {
  396. "defaults": {
  397. "unit": "ms"
  398. }
  399. },
  400. "targets": [
  401. {
  402. "refId": "P50",
  403. "expr": "histogram_quantile(0.5, sum by (le,outcome) (sum_over_time(zcode_local_ttft_no_output_wait_bucket[5m])))",
  404. "legendFormat": "P50 {{outcome}}"
  405. },
  406. {
  407. "refId": "P95",
  408. "expr": "histogram_quantile(0.95, sum by (le,outcome) (sum_over_time(zcode_local_ttft_no_output_wait_bucket[5m])))",
  409. "legendFormat": "P95 {{outcome}}"
  410. }
  411. ]
  412. },
  413. {
  414. "id": 13,
  415. "type": "stat",
  416. "title": "无首输出等待(明确结果) 样本数",
  417. "datasource": {
  418. "type": "prometheus",
  419. "uid": "${DS_PROMETHEUS}"
  420. },
  421. "gridPos": {
  422. "x": 16,
  423. "y": 50,
  424. "w": 8,
  425. "h": 7
  426. },
  427. "targets": [
  428. {
  429. "refId": "A",
  430. "expr": "sum by (outcome) (sum_over_time(zcode_local_ttft_no_output_wait_count[$__range]))"
  431. }
  432. ]
  433. },
  434. {
  435. "id": 14,
  436. "type": "timeseries",
  437. "title": "物理 attempt(含准备) P50 / P95",
  438. "datasource": {
  439. "type": "prometheus",
  440. "uid": "${DS_PROMETHEUS}"
  441. },
  442. "gridPos": {
  443. "x": 0,
  444. "y": 57,
  445. "w": 16,
  446. "h": 7
  447. },
  448. "fieldConfig": {
  449. "defaults": {
  450. "unit": "ms"
  451. }
  452. },
  453. "targets": [
  454. {
  455. "refId": "P50",
  456. "expr": "histogram_quantile(0.5, sum by (le,role,outcome) (sum_over_time(zcode_local_ttft_attempt_duration_bucket[5m])))",
  457. "legendFormat": "P50 {{role}}"
  458. },
  459. {
  460. "refId": "P95",
  461. "expr": "histogram_quantile(0.95, sum by (le,role,outcome) (sum_over_time(zcode_local_ttft_attempt_duration_bucket[5m])))",
  462. "legendFormat": "P95 {{role}}"
  463. }
  464. ]
  465. },
  466. {
  467. "id": 15,
  468. "type": "stat",
  469. "title": "物理 attempt(含准备) 样本数",
  470. "datasource": {
  471. "type": "prometheus",
  472. "uid": "${DS_PROMETHEUS}"
  473. },
  474. "gridPos": {
  475. "x": 16,
  476. "y": 57,
  477. "w": 8,
  478. "h": 7
  479. },
  480. "targets": [
  481. {
  482. "refId": "A",
  483. "expr": "sum by (role,outcome) (sum_over_time(zcode_local_ttft_attempt_duration_count[$__range]))"
  484. }
  485. ]
  486. },
  487. {
  488. "id": 16,
  489. "type": "timeseries",
  490. "title": "累计准备观察(不代表持续前台) P50 / P95",
  491. "datasource": {
  492. "type": "prometheus",
  493. "uid": "${DS_PROMETHEUS}"
  494. },
  495. "gridPos": {
  496. "x": 0,
  497. "y": 64,
  498. "w": 16,
  499. "h": 7
  500. },
  501. "fieldConfig": {
  502. "defaults": {
  503. "unit": "ms"
  504. }
  505. },
  506. "targets": [
  507. {
  508. "refId": "P50",
  509. "expr": "histogram_quantile(0.5, sum by (le,stage) (sum_over_time(zcode_local_ttft_preparation_observation_duration_bucket[5m])))",
  510. "legendFormat": "P50 {{stage}}"
  511. },
  512. {
  513. "refId": "P95",
  514. "expr": "histogram_quantile(0.95, sum by (le,stage) (sum_over_time(zcode_local_ttft_preparation_observation_duration_bucket[5m])))",
  515. "legendFormat": "P95 {{stage}}"
  516. }
  517. ]
  518. },
  519. {
  520. "id": 17,
  521. "type": "stat",
  522. "title": "累计准备观察(不代表持续前台) 样本数",
  523. "datasource": {
  524. "type": "prometheus",
  525. "uid": "${DS_PROMETHEUS}"
  526. },
  527. "gridPos": {
  528. "x": 16,
  529. "y": 64,
  530. "w": 8,
  531. "h": 7
  532. },
  533. "targets": [
  534. {
  535. "refId": "A",
  536. "expr": "sum by (stage) (sum_over_time(zcode_local_ttft_preparation_observation_duration_count[$__range]))"
  537. }
  538. ]
  539. },
  540. {
  541. "id": 18,
  542. "type": "timeseries",
  543. "title": "诊断:前后台与质量 P50 / P95",
  544. "datasource": {
  545. "type": "prometheus",
  546. "uid": "${DS_PROMETHEUS}"
  547. },
  548. "gridPos": {
  549. "x": 0,
  550. "y": 71,
  551. "w": 16,
  552. "h": 7
  553. },
  554. "fieldConfig": {
  555. "defaults": {
  556. "unit": "ms"
  557. }
  558. },
  559. "targets": [
  560. {
  561. "refId": "P50",
  562. "expr": "histogram_quantile(0.5, sum by (le,visibility,quality) (sum_over_time(zcode_local_ttft_duration_bucket[5m])))",
  563. "legendFormat": "P50 {{visibility}}"
  564. },
  565. {
  566. "refId": "P95",
  567. "expr": "histogram_quantile(0.95, sum by (le,visibility,quality) (sum_over_time(zcode_local_ttft_duration_bucket[5m])))",
  568. "legendFormat": "P95 {{visibility}}"
  569. }
  570. ]
  571. },
  572. {
  573. "id": 19,
  574. "type": "stat",
  575. "title": "诊断:前后台与质量 样本数",
  576. "datasource": {
  577. "type": "prometheus",
  578. "uid": "${DS_PROMETHEUS}"
  579. },
  580. "gridPos": {
  581. "x": 16,
  582. "y": 71,
  583. "w": 8,
  584. "h": 7
  585. },
  586. "targets": [
  587. {
  588. "refId": "A",
  589. "expr": "sum by (visibility,quality) (sum_over_time(zcode_local_ttft_duration_count[$__range]))"
  590. }
  591. ]
  592. },
  593. {
  594. "id": 20,
  595. "type": "table",
  596. "title": "输入结果数量",
  597. "datasource": {
  598. "type": "prometheus",
  599. "uid": "${DS_PROMETHEUS}"
  600. },
  601. "gridPos": {
  602. "x": 0,
  603. "y": 78,
  604. "w": 24,
  605. "h": 5
  606. },
  607. "targets": [
  608. {
  609. "refId": "A",
  610. "expr": "sum by (kind,outcome) (sum_over_time(zcode_local_ttft_records{kind=~\"start|first_output|excluded\"}[$__range]))"
  611. }
  612. ]
  613. },
  614. {
  615. "id": 21,
  616. "type": "table",
  617. "title": "首输出前结果比例",
  618. "datasource": {
  619. "type": "prometheus",
  620. "uid": "${DS_PROMETHEUS}"
  621. },
  622. "gridPos": {
  623. "x": 0,
  624. "y": 83,
  625. "w": 24,
  626. "h": 5
  627. },
  628. "targets": [
  629. {
  630. "refId": "A",
  631. "expr": "sum by (outcome) (sum_over_time(zcode_local_ttft_records{kind=\"excluded\",outcome=~\"failed|cancelled|rejected|interrupted\"}[$__range])) / scalar(sum(sum_over_time(zcode_local_ttft_records{kind=\"start\"}[$__range])))"
  632. }
  633. ]
  634. },
  635. {
  636. "id": 22,
  637. "type": "table",
  638. "title": "遥测资源丢弃",
  639. "datasource": {
  640. "type": "prometheus",
  641. "uid": "${DS_PROMETHEUS}"
  642. },
  643. "gridPos": {
  644. "x": 0,
  645. "y": 88,
  646. "w": 24,
  647. "h": 5
  648. },
  649. "targets": [
  650. {
  651. "refId": "A",
  652. "expr": "sum by (reason) (sum_over_time(zcode_local_ttft_dropped[$__range]))"
  653. }
  654. ]
  655. },
  656. {
  657. "id": 23,
  658. "type": "text",
  659. "title": "未收口与瀑布诊断",
  660. "gridPos": {
  661. "x": 0,
  662. "y": 93,
  663. "w": 24,
  664. "h": 6
  665. },
  666. "options": {
  667. "mode": "markdown",
  668. "content": "在 Trace Explorer 按 observation_id 关联 start、checkpoint 与 first_output/明确 excluded。只存在开始或部分阶段时标未收口,不能因查询窗口推断超时;跨窗口的开始/结果比例需按同批 observation join。阶段 .started 是开始点,不是零耗时成功。并行阶段按区间并集对账,检查 missing_stages、unattributed_ms、truncated 与 clock_source。\n\n主 TTFT=输入;stage/preparation=区间;attempt=物理请求。observation 系列是阶段观察当时的前后台状态,不用于默认持续前台体验。指标映射、瀑布链接、平台容量/费用/7天与30天保留仍待 ARMS 核验。"
  669. }
  670. }
  671. ]
  672. }