Browse Source

[attu metric] divide three part: topo, lineChart, healthyIndex

Signed-off-by: min.tian <min.tian.cn@gmail.com>
min.tian 2 years ago
parent
commit
1b8dc6a157

+ 1 - 1
client/src/http/Prometheus.ts

@@ -35,7 +35,7 @@ export class PrometheusHttp extends BaseModel {
   }) {
     return super.search({
       path: PrometheusHttp.GET_MILVUS_HEALTHY_DATA_URL,
-      params: { start: 1675997400000, end: 1675998480000, step: 180000 },
+      params: { start, end, step },
     });
   }
 }

+ 24 - 84
client/src/pages/systemHealthy/SystemHealthyView.tsx

@@ -8,14 +8,17 @@ import {
   EHealthyStatus,
   ENodeService,
   ENodeType,
+  ILineChartData,
   INodeTreeStructure,
   IPrometheusAllData,
+  IPrometheusNode,
   IThreshold,
   ITimeRangeOption,
 } from './Types';
 import clsx from 'clsx';
 import Topology from './Topology';
 import * as d3 from 'd3';
+import { reconNodeTree } from './dataHandler';
 // import data from "./data.json";
 
 const getStyles = makeStyles((theme: Theme) => ({
@@ -55,13 +58,7 @@ const getStyles = makeStyles((theme: Theme) => ({
   },
 }));
 
-const THIRD_PARTY_SERVICE_HEALTHY_THRESHOLD = 0.95;
-const getThirdPartyServiceHealthyStatus = (rate: number) =>
-  rate > THIRD_PARTY_SERVICE_HEALTHY_THRESHOLD
-    ? EHealthyStatus.healthy
-    : EHealthyStatus.failed;
-const rateList2healthyStatus = (rateList: number[]) =>
-  rateList.map((rate: number) => getThirdPartyServiceHealthyStatus(rate));
+
 
 const SystemHealthyView = () => {
   useNavigationHook(ALL_ROUTER_TYPES.SYSTEM);
@@ -83,19 +80,20 @@ const SystemHealthyView = () => {
     {
       label: '7d',
       value: 7 * 24 * 60 * 60 * 1000,
-      step: 8 * 60 * 60 * 100,
+      step: 8 * 60 * 60 * 1000,
     },
   ];
   const [timeRange, setTimeRange] = useState<ITimeRangeOption>(
-    timeRangeOptions[0]
+    timeRangeOptions[2]
   );
-  const [prometheusData, setPrometheusData] = useState<any>();
+  const [nodes, setNodes] = useState<INodeTreeStructure[]>([]);
+  const [lineChartsData, setLineChartsData] = useState<ILineChartData[]>([]);
   const [selectedNode, setSelectedNode] = useState<string>('');
-  const defaultThresholds = {
+  const defaultThreshold = {
     cpu: 1,
-    memory: 8,
+    memory: 8 * 1024 * 1024 * 1024,
   };
-  const [threshold, setThreshold] = useState<IThreshold>(defaultThresholds);
+  const [threshold, setThreshold] = useState<IThreshold>(defaultThreshold);
 
   const updateData = async () => {
     const curT = new Date().getTime();
@@ -103,9 +101,19 @@ const SystemHealthyView = () => {
       start: curT - timeRange.value,
       end: curT,
       step: timeRange.step,
-    });
+    }) as IPrometheusAllData;
     console.log(result);
-    setPrometheusData(result.data as IPrometheusAllData);
+    setNodes(reconNodeTree(result, threshold));
+    setLineChartsData([{
+      label: 'TotalCount',
+      data: result.totalVectorsCount
+    },{
+      label: 'SearchCount',
+      data: result.searchVectorsCount
+    },{
+      label: 'SearchLatency',
+      data: result.sqLatency
+    },])
   };
 
   useEffect(() => {
@@ -117,75 +125,7 @@ const SystemHealthyView = () => {
     updateData();
   }, INTERVAL);
 
-  const reconNodeTree = (
-    prometheusData: IPrometheusAllData,
-    threshold: IThreshold
-  ) => {
-    const length = prometheusData.meta.length;
-
-    // third party
-    const metaNode: INodeTreeStructure = {
-      service: ENodeService.meta,
-      type: ENodeType.overview,
-      label: 'Meta',
-      healthyStatus: rateList2healthyStatus(prometheusData.meta),
-      children: [],
-    };
-    const msgstreamNode: INodeTreeStructure = {
-      service: ENodeService.msgstream,
-      type: ENodeType.overview,
-      label: 'MsgStream',
-      healthyStatus: rateList2healthyStatus(prometheusData.msgstream),
-      children: [],
-    };
-    const objstorageNode: INodeTreeStructure = {
-      service: ENodeService.objstorage,
-      type: ENodeType.overview,
-      label: 'ObjStorage',
-      healthyStatus: rateList2healthyStatus(prometheusData.msgstream),
-      children: [],
-    };
-
-    // internal
-    const rootNode = {};
-    const indexNodes: INodeTreeStructure[] = prometheusData.indexNodes.map(
-      node => {
-        const healthyStatus = d3.range(length).map((_, i: number) => {
-          const cpu = node.cpu[i];
-          const memory = node.memory[i];
-          return cpu >= threshold.cpu || memory >= threshold.memory
-            ? EHealthyStatus.warning
-            : EHealthyStatus.healthy;
-        });
-        return {
-          service: ENodeService.index,
-          type: node.type === 'coord' ? ENodeType.coord : ENodeType.node,
-          label: node.pod,
-          healthyStatus,
-          cpu: node.cpu,
-          memory: node.memory,
-          children: [],
-        };
-      }
-    );
-    const healthyStatus = d3
-      .range(length)
-      .map((_, i: number) =>
-        indexNodes.reduce(
-          (acc, cur) => acc && cur.healthyStatus[i] === EHealthyStatus.healthy,
-          true
-        )
-          ? EHealthyStatus.healthy
-          : EHealthyStatus.warning
-      );
-    const indexNode: INodeTreeStructure = {
-      service: ENodeService.index,
-      type: ENodeType.overview,
-      label: 'Index',
-      healthyStatus,
-      children: indexNodes,
-    };
-  };
+  console.log('nodes', nodes, lineChartsData);
 
   return (
     <div className={classes.root}>

+ 8 - 2
client/src/pages/systemHealthy/Types.ts

@@ -18,7 +18,12 @@ export enum ENodeService {
   root,
   query,
   index,
-  node,
+  data,
+}
+
+export interface ILineChartData {
+  label: string;
+  data: number[];
 }
 
 export interface INodeTreeStructure {
@@ -32,7 +37,8 @@ export interface INodeTreeStructure {
 }
 
 export enum EHealthyStatus {
-  healthy = 0,
+  noData = 0,
+  healthy,
   warning,
   failed,
 }

+ 93 - 114
client/src/pages/systemHealthy/data.json

@@ -1,192 +1,171 @@
 {
   "totalVectorsCount": [
-    10100, 10100, 10100, 10100, 10100, 10100, 10100, 10100, 10100, 10100, 10100,
-    10100, 10100, 10100, 10100, 10100, 10100, 10100, 10100, 10100
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, 10100, 10100, 10100, 10100, 10100,
+    10100, 10100, 10100, 10100, 10100, 10100, 10100
   ],
   "searchVectorsCount": [
-    34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
-    34
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11, 11, 11, 11, 34, 34,
+    34, 85
+  ],
+  "sqLatency": [
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, 506.8829768717992, 0, 0, 0, 0, 0, 0, 0,
+    0, 508.07466666666664, 0, 0, 1995.776
+  ],
+  "meta": [
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
   ],
-  "sqLatency": [],
-  "meta": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
   "msgstream": [
-    1, 1, 0.9998114274938714, 1.0001883593897156, 0.9998144712430427,
-    1.000185253797703, 0.9996274911529148, 1.0003825554705432, 1, 1, 1, 1, 1, 1,
-    1, 1, 1, 1, 1, 1
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+  ],
+  "objstorage": [
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
   ],
-  "objstorage": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
   "rootNodes": [
     {
-      "label": "coord",
+      "type": "coord",
       "pod": "tianmin-milvus-rootcoord-66bb975f6d-jxx6s",
       "cpu": [
-        3876.64, 3879.11, 3881.62, 3884.09, 3886.6, 3888.98, 3891.4, 3893.85,
-        3896.26, 3898.77, 3901.44, 3903.94, 3906.56, 3909.19, 3911.84, 3914.49,
-        3917.18, 3919.78, 3922.32, 3924.86, 3927.39
+        376.13, 758.03, 1155.1, 1559.85, 1944, 2332.24, 2735.8, 3137.48,
+        3521.33, 3920.21, 4298.6, 4674.12, 5040.54
       ],
       "memory": [
-        256598016, 256598016, 256598016, 256598016, 256598016, 256598016,
-        256598016, 256598016, 256598016, 256598016, 256598016, 256598016,
-        256598016, 256598016, 256598016, 256598016, 256598016, 256598016,
-        256598016, 256598016, 256598016
+        267030528, 267030528, 259407872, 257298432, 257298432, 256708608,
+        256643072, 256626688, 256598016, 256598016, 256794624, 256786432,
+        256786432
       ]
     }
   ],
   "queryNodes": [
     {
-      "label": "coord",
+      "type": "coord",
       "pod": "tianmin-milvus-querycoord-d779dfdd4-njjp5",
       "cpu": [
-        0.004666666666666212, 0.004444444444444192, 0.004333333333333181,
-        0.00438888888888995, 0.004166666666666667, 0.004444444444444192,
-        0.004555555555555202, 0.004444444444444192, 0.0042777777777776764,
-        0.0042777777777776764, 0.004111111111111162, 0.004000000000000152,
-        0.0042222222222221715, 0.0042222222222221715, 0.0042222222222221715,
-        0.004166666666666667, 0.0042777777777776764, 0.004444444444445455,
-        0.004666666666666212, 0.004555555555555202
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, 0.004354861111111111,
+        0.004148263888888889, 0.004453819444444443, 0.004365277777777779,
+        0.004188541666666667, 0.004348263888888889, 0.004374305555555556,
+        0.004205555555555552, 0.004389583333333336, 0.004275347222222218,
+        0.004134375000000006, 0.004095833333333335
       ],
       "memory": [
-        197791744, 198955008, 197935104, 195383296, 196513792, 199458816,
-        200470528, 199585792, 200290304, 196591616, 195936256, 196235264,
-        199966720, 200216576, 194682880, 196231168, 199692288, 196538368,
-        196132864, 198537216
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, 198668288, 198307840, 200466432,
+        199086080, 199942144, 194887680, 200523776, 196640768, 199692288,
+        194867200, 196759552, 198111232
       ]
     },
     {
-      "label": "node",
+      "type": "node",
       "pod": "tianmin-milvus-querynode-68866999f4-t8wtz",
       "cpu": [
-        0.007833333333335052, 0.007555555555553737, 0.007833333333335052,
-        0.007888888888889294, 0.007666666666664747, 0.007555555555556263,
-        0.007444444444445253, 0.0073333333333317164, 0.008277777777779091,
-        0.009222222222221414, 0.008444444444444343, 0.008722222222223132,
-        0.008999999999999394, 0.008722222222223132, 0.008833333333331615,
-        0.009166666666667172, 0.008944444444445152, 0.008611111111112122,
-        0.008722222222220605, 0.008277777777779091
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, 0.006875347222222222,
+        0.007737152777777779, 0.007752083333333333, 0.006654513888888888,
+        0.006953125, 0.007668055555555553, 0.007513194444444448,
+        0.006884374999999999, 0.007900347222222229, 0.007532291666666661,
+        0.007135069444444437, 0.007169791666666675
       ],
       "memory": [
-        227799040, 227799040, 227799040, 227799040, 227799040, 227799040,
-        227799040, 227799040, 227799040, 227799040, 227799040, 227799040,
-        227799040, 227799040, 227799040, 227799040, 227799040, 227799040,
-        227799040, 227799040
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, 229572608, 223236096, 221335552,
+        219553792, 219643904, 220409856, 220393472, 219332608, 227799040,
+        227758080, 226185216, 226619392
       ]
     },
     {
-      "label": "node",
+      "type": "node",
       "pod": "tianmin-milvus-querynode-68866999f4-ftmql",
       "cpu": [
-        0.007888888888889294, 0.007666666666667273, 0.007333333333332979,
-        0.007499999999999495, 0.007333333333334243, 0.00788888888888803,
-        0.007722222222222778, 0.007499999999999495, 0.007166666666666465,
-        0.007055555555556718, 0.00699999999999995, 0.00711111111111096,
-        0.00744444444444399, 0.007055555555555455, 0.0072222222222219695,
-        0.007333333333334243, 0.007499999999999495, 0.007277777777777474,
-        0.007944444444444799, 0.00766666666666601
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, 0.0060999999999999995,
+        0.006392708333333332, 0.006654861111111114, 0.005995486111111109,
+        0.005906597222222223, 0.006739236111111108, 0.006666319444444444,
+        0.005960416666666669, 0.007247916666666667, 0.006772916666666665,
+        0.006012847222222225, 0.006104513888888887
       ],
       "memory": [
-        240599040, 240599040, 240599040, 240599040, 240599040, 240599040,
-        240599040, 240599040, 240599040, 240599040, 240599040, 240599040,
-        240599040, 240599040, 240599040, 240599040, 240599040, 240599040,
-        240599040, 240599040
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, 234229760, 235794432, 235827200,
+        234188800, 234881024, 236142592, 236150784, 235180032, 240599040,
+        240476160, 239734784, 239882240
       ]
     }
   ],
   "indexNodes": [
     {
-      "label": "coord",
+      "type": "coord",
       "pod": "tianmin-milvus-indexcoord-864d49b47f-t7w4k",
       "cpu": [
-        0.0009444444444445328, 0.0010555555555555429, 0.000888888888888712,
-        0.001000000000000038, 0.0009444444444445328, 0.001000000000000038,
-        0.0010555555555555429, 0.0010555555555555429, 0.0008888888888890278,
-        0.000999999999999722, 0.0009444444444445328, 0.001000000000000038,
-        0.0009444444444445328, 0.0010555555555555429, 0.0009444444444445328,
-        0.0010555555555555429, 0.0009444444444442171, 0.001000000000000038,
-        0.001000000000000038, 0.0010555555555555429
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, 0.0010534722222222221,
+        0.0009885416666666666, 0.0010402777777777776, 0.001061805555555556,
+        0.0010104166666666664, 0.0010604166666666663, 0.001054861111111111,
+        0.0010246527777777784, 0.0010458333333333335, 0.0009649305555555543,
+        0.0009010416666666683, 0.0009291666666666664
       ],
       "memory": [
-        179040256, 179040256, 179068928, 179068928, 179068928, 179326976,
-        179339264, 179339264, 179339264, 179339264, 179343360, 179343360,
-        179363840, 179372032, 179372032, 179372032, 179372032, 179372032,
-        179372032, 179372032
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, 172568576, 181334016, 181194752,
+        181170176, 180797440, 179240960, 179204096, 178769920, 179372032,
+        179511296, 179613696, 179302400
       ]
     },
     {
-      "label": "node",
+      "type": "node",
       "pod": "tianmin-milvus-indexnode-6cdc5f745b-j5ttn",
       "cpu": [
-        0.0007222222222221969, 0.0007222222222221969, 0.0007222222222221969,
-        0.0006666666666666919, 0.0007222222222221969, 0.0007222222222221969,
-        0.0006666666666666919, 0.0007222222222221969, 0.0007222222222223549,
-        0.000611111111111029, 0.0006666666666666919, 0.0007222222222221969,
-        0.0007222222222221969, 0.0006666666666666919, 0.0007222222222221969,
-        0.0006666666666666919, 0.0006666666666666919, 0.000777777777777702,
-        0.0007777777777778599, 0.0007222222222221969
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, 0.0007239583333333333,
+        0.0006895833333333333, 0.000747222222222222, 0.0007375000000000003,
+        0.000704861111111111, 0.000752777777777778, 0.0007406249999999994,
+        0.0006965277777777779, 0.0007451388888888892, 0.0006732638888888884,
+        0.0006333333333333336, 0.0006513888888888896
       ],
       "memory": [
-        1076543488, 1076543488, 1076543488, 1075888128, 1075888128, 1075888128,
-        1075888128, 1075888128, 1075888128, 1075888128, 1075888128, 1075892224,
-        1075892224, 1075896320, 1075896320, 1075896320, 1076625408, 1076625408,
-        1076625408, 1076625408
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, 1075355648, 1075339264, 1075503104,
+        1075728384, 1075642368, 1075568640, 1075712000, 1075863552, 1076625408,
+        1075990528, 1076199424, 1076326400
       ]
     }
   ],
   "dataNodes": [
     {
-      "label": "coord",
+      "type": "coord",
       "pod": "tianmin-milvus-datacoord-bb57486b-w29cx",
       "cpu": [
-        0.0036666666666671215, 0.0038333333333323734, 0.0037777777777781314,
-        0.0037777777777781314, 0.0036666666666658582, 0.004166666666666667,
-        0.0038333333333336367, 0.0037222222222226264, 0.0038888888888891416,
-        0.003722222222221363, 0.004000000000000152, 0.0035000000000006064,
-        0.0038333333333323734, 0.0038888888888891416, 0.0037222222222226264,
-        0.0037222222222226264, 0.003944444444443383, 0.0035555555555561113,
-        0.0038333333333336367, 0.003722222222221363
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, 0.0037305555555555555,
+        0.004054513888888888, 0.0042069444444444454, 0.0036847222222222203,
+        0.0034364583333333343, 0.004098611111111114, 0.004046180555555555,
+        0.003398958333333333, 0.0039364583333333335, 0.003711805555555559,
+        0.003448263888888887, 0.003430208333333332
       ],
       "memory": [
-        206331904, 207470592, 207720448, 207720448, 208060416, 205582336,
-        202395648, 205864960, 206917632, 206917632, 205361152, 204087296,
-        203841536, 209223680, 210296832, 210321408, 210554880, 208400384,
-        208814080, 208814080
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, 205545472, 201728000, 208707584,
+        206086144, 202588160, 204652544, 202850304, 207249408, 210554880,
+        203558912, 204767232, 208343040
       ]
     },
     {
-      "label": "node",
+      "type": "node",
       "pod": "tianmin-milvus-datanode-7b759b9697-snqqx",
       "cpu": [
-        0.005777777777778839, 0.005999999999999596, 0.005888888888888586,
-        0.0057222222222220705, 0.005944444444445354, 0.006166666666666111,
-        0.005944444444444091, 0.005666666666666566, 0.005777777777777575,
-        0.005444444444444545, 0.00527777777777803, 0.00527777777777803,
-        0.00527777777777803, 0.00538888888888904, 0.005611111111111061,
-        0.005555555555555556, 0.005500000000000051, 0.0052777777777767675,
-        0.005555555555555556, 0.005333333333333535
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, 0.005490972222222223,
+        0.005468055555555554, 0.005621180555555557, 0.005448958333333332,
+        0.005135763888888888, 0.0055760416666666675, 0.0055836805555555535,
+        0.005151388888888894, 0.005699305555555551, 0.005477777777777778,
+        0.00502673611111111, 0.005077430555555556
       ],
       "memory": [
-        233603072, 233603072, 233603072, 233603072, 233603072, 233603072,
-        233603072, 233603072, 233603072, 233603072, 233603072, 233603072,
-        233603072, 233603072, 233603072, 233603072, 233603072, 233603072,
-        233603072, 233603072
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, 222609408, 235073536, 235151360,
+        235159552, 234332160, 233107456, 233111552, 232488960, 233603072,
+        233611264, 232898560, 233619456
       ]
     },
     {
-      "label": "node",
+      "type": "node",
       "pod": "tianmin-milvus-datanode-7b759b9697-hzd9w",
       "cpu": [
-        0.006111111111110606, 0.006000000000000859, 0.006166666666666111,
-        0.005888888888888586, 0.005888888888889849, 0.0062777777777771205,
-        0.006055555555555101, 0.005777777777778839, 0.005611111111111061,
-        0.005444444444444545, 0.005388888888887777, 0.00527777777777803,
-        0.005333333333333535, 0.0057222222222220705, 0.005666666666666566,
-        0.005666666666666566, 0.005555555555555556, 0.00527777777777803,
-        0.006277777777778384, 0.006333333333332626
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, 0.0060996527777777785,
+        0.006033333333333331, 0.006782291666666668, 0.006199999999999998,
+        0.005823958333333334, 0.007095486111111116, 0.006971180555555555,
+        0.005759722222222218, 0.006396527777777779, 0.0057159722222222265,
+        0.005308680555555551, 0.005292708333333327
       ],
       "memory": [
-        223911936, 223911936, 223911936, 223911936, 223911936, 223911936,
-        223911936, 223911936, 223911936, 223911936, 223911936, 223911936,
-        223911936, 223911936, 223911936, 223911936, 223911936, 223911936,
-        223911936, 223911936
+        -1, -1, -1, -1, -1, -1, -1, -1, -1, 222482432, 222982144, 223010816,
+        222834688, 222400512, 223166464, 223830016, 223051776, 223911936,
+        223911936, 223653888, 223993856
       ]
     }
   ]

+ 123 - 0
client/src/pages/systemHealthy/dataHandler.ts

@@ -0,0 +1,123 @@
+import * as d3 from "d3";
+import { EHealthyStatus, ENodeService, ENodeType, INodeTreeStructure, IPrometheusAllData, IPrometheusNode, IThreshold } from "./Types";
+
+export const getInternalNode = (
+  prometheusNodes: IPrometheusNode[],
+  service: ENodeService,
+  label: string,
+  threshold: IThreshold
+) => {
+  const length = prometheusNodes[0].cpu.length;
+  const nodes = prometheusNodes.map(node => {
+    const healthyStatus = d3.range(length).map((_, i: number) => {
+      const cpu = node.cpu[i];
+      const memory = node.memory[i];
+      if (cpu === -1) return EHealthyStatus.noData;
+      if (cpu === -2) return EHealthyStatus.failed;
+      console.log()
+      return cpu >= threshold.cpu || memory >= threshold.memory
+        ? EHealthyStatus.warning
+        : EHealthyStatus.healthy;
+    });
+    return {
+      service: service,
+      type: node.type === 'coord' ? ENodeType.coord : ENodeType.node,
+      label: node.pod,
+      healthyStatus,
+      cpu: node.cpu,
+      memory: node.memory,
+      children: [],
+    };
+  });
+  const overviewHealthyStatus = d3.range(length).map((_, i: number) => {
+    if (nodes.find(node => node.healthyStatus[i] === EHealthyStatus.failed))
+      return EHealthyStatus.failed;
+    if (nodes.find(node => node.healthyStatus[i] === EHealthyStatus.warning))
+      return EHealthyStatus.warning;
+    if (nodes.find(node => node.healthyStatus[i] === EHealthyStatus.healthy))
+      return EHealthyStatus.healthy;
+    return EHealthyStatus.noData;
+  });
+  const overviewNode = {
+    service,
+    type: ENodeType.overview,
+    label: label,
+    healthyStatus: overviewHealthyStatus,
+    children: nodes,
+  };
+  return overviewNode;
+};
+
+export const reconNodeTree = (
+  prometheusData: IPrometheusAllData,
+  threshold: IThreshold
+) => {
+  // third party
+  const metaNode: INodeTreeStructure = {
+    service: ENodeService.meta,
+    type: ENodeType.overview,
+    label: 'Meta',
+    healthyStatus: rateList2healthyStatus(prometheusData.meta),
+    children: [],
+  };
+  const msgstreamNode: INodeTreeStructure = {
+    service: ENodeService.msgstream,
+    type: ENodeType.overview,
+    label: 'MsgStream',
+    healthyStatus: rateList2healthyStatus(prometheusData.msgstream),
+    children: [],
+  };
+  const objstorageNode: INodeTreeStructure = {
+    service: ENodeService.objstorage,
+    type: ENodeType.overview,
+    label: 'ObjStorage',
+    healthyStatus: rateList2healthyStatus(prometheusData.objstorage),
+    children: [],
+  };
+
+  // internal
+  const rootNode = getInternalNode(
+    prometheusData.rootNodes,
+    ENodeService.root,
+    'Root',
+    threshold
+  );
+  const indexNode = getInternalNode(
+    prometheusData.indexNodes,
+    ENodeService.index,
+    'Index',
+    threshold
+  );
+  const queryNode = getInternalNode(
+    prometheusData.queryNodes,
+    ENodeService.query,
+    'Query',
+    threshold
+  );
+  const DataNode = getInternalNode(
+    prometheusData.dataNodes,
+    ENodeService.data,
+    'Data',
+    threshold
+  );
+
+  return [
+    metaNode,
+    msgstreamNode,
+    objstorageNode,
+    rootNode,
+    indexNode,
+    queryNode,
+    DataNode,
+  ] as INodeTreeStructure[];
+};
+
+export const THIRD_PARTY_SERVICE_HEALTHY_THRESHOLD = 0.95;
+export const getThirdPartyServiceHealthyStatus = (rate: number) => {
+  if (rate === -1) return EHealthyStatus.noData;
+  if (rate > THIRD_PARTY_SERVICE_HEALTHY_THRESHOLD)
+    return EHealthyStatus.healthy;
+  return EHealthyStatus.failed;
+};
+export const rateList2healthyStatus = (rateList: number[]) =>
+  rateList.map((rate: number) => getThirdPartyServiceHealthyStatus(rate));

+ 49 - 26
server/src/prometheus/prometheus.service.ts

@@ -116,7 +116,7 @@ export class PrometheusService {
     const expr = `${metric}${PrometheusService.selector}`;
     const result = await this.queryRange(expr, start, end, step);
     const data = result.data.result;
-    const length = Math.floor((end - start) / step) + 1;
+    const length = Math.floor((end - start) / step);
 
     if (data.length === 0) return Array(length).fill(0);
 
@@ -128,7 +128,7 @@ export class PrometheusService {
     rightLossCount = Math.floor(
       (end - data[0].values[data[0].values.length - 1][0] * 1000) / step
     );
-    res.push(...Array(rightLossCount).fill(-1));
+    res.push(...Array(rightLossCount).fill(-2));
     return res;
   }
   getSearchVectorsCount = (start: number, end: number, step: number) =>
@@ -136,8 +136,27 @@ export class PrometheusService {
   getInsertVectorsCount = (start: number, end: number, step: number) =>
     this.getVectorsCount(totalVectorsCountMetric, start, end, step);
 
-  getSQLatency() {
-    return;
+  async getSQLatency(start: number, end: number, step: number) {
+    const expr =
+      `histogram_quantile(0.99, sum by (le, query_type, pod, node_id)` +
+      `(rate(milvus_proxy_sq_latency_bucket${PrometheusService.selector}[${
+        step / 1000
+      }s])))`;
+    const result = await this.queryRange(expr, start, end, step);
+    const data = result.data.result;
+
+    const length = Math.floor((end - start) / step);
+    if (data.length === 0) return Array(length).fill(0);
+
+    const res = data[0].values.map((d: any) => (isNaN(d[1]) ? 0 : +d[1]));
+    let leftLossCount, rightLossCount;
+    leftLossCount = Math.floor((data[0].values[0][0] * 1000 - start) / step);
+    res.unshift(...Array(leftLossCount).fill(-1));
+    rightLossCount = Math.floor(
+      (end - data[0].values[data[0].values.length - 1][0] * 1000) / step
+    );
+    res.push(...Array(rightLossCount).fill(-2));
+    return res;
   }
 
   async getThirdPartyServiceHealthStatus(
@@ -148,21 +167,25 @@ export class PrometheusService {
   ) {
     const expr = `sum by (status) (${metricName}${PrometheusService.selector})`;
     const result = await this.queryRange(expr, start, end, step);
-    const totalCount = result.data.result
+    const data = result.data.result;
+    const length = Math.floor((end - start) / step);
+    const totalCount = data
       .find((d: any) => d.metric.status === 'total')
       .values.map((d: any) => +d[1]);
     const totalSlices = totalCount
       .map((d: number, i: number) => (i > 0 ? d - totalCount[i - 1] : d))
       .slice(1);
-    const successCount = result.data.result
+    const successCount = data
       .find((d: any) => d.metric.status === 'success')
       .values.map((d: any) => +d[1]);
     const successSlices = successCount
       .map((d: number, i: number) => (i > 0 ? d - successCount[i - 1] : d))
       .slice(1);
-    return totalSlices.map((d: number, i: number) =>
+    const res = totalSlices.map((d: number, i: number) =>
       d === 0 ? 1 : successSlices[i] / d
     );
+    res.unshift(...Array(length - res.length).fill(-1));
+    return res;
   }
 
   async getInternalNodesCPUData(start: number, end: number, step: number) {
@@ -206,7 +229,7 @@ export class PrometheusService {
       rightLossCount = Math.floor(
         (end - d.values[d.values.length - 1][0] * 1000) / step
       );
-      cpu.push(...Array(rightLossCount).fill(-1));
+      cpu.push(...Array(rightLossCount).fill(-2));
 
       const node = memoryNodes.find((data: any) => data.metric.pod === pod);
       const memory = node.values.map((v: any) => +v[1]).slice(1);
@@ -216,7 +239,7 @@ export class PrometheusService {
       rightLossCount = Math.floor(
         (end - node.values[node.values.length - 1][0] * 1000) / step
       );
-      memory.push(...Array(rightLossCount).fill(-1));
+      memory.push(...Array(rightLossCount).fill(-2));
       return { type, pod, cpu, memory } as IPrometheusNode;
     });
 
@@ -227,7 +250,7 @@ export class PrometheusService {
     const cpuNodes = await this.getInternalNodesCPUData(start, end, step);
     const memoryNodes = await this.getInternalNodesMemoryData(start, end, step);
 
-    const [queryNodes, indexNodes, dataNodes] = ['query', 'index', 'data'].map(
+    const [rootNodes, queryNodes, indexNodes, dataNodes] = ['root', 'query', 'index', 'data'].map(
       (metric: string) =>
         this.reconstructNodeData(
           cpuNodes,
@@ -238,7 +261,7 @@ export class PrometheusService {
           step
         )
     );
-    return { queryNodes, indexNodes, dataNodes };
+    return { rootNodes, queryNodes, indexNodes, dataNodes };
   }
 
   async getMilvusHealthyData({
@@ -278,25 +301,25 @@ export class PrometheusService {
       end,
       step
     );
-    const sqLatency: number[] = [];
+    const sqLatency = await this.getSQLatency(start, end, step);
 
     const cpuNodes = await this.getInternalNodesCPUData(start, end, step);
     const memoryNodes = await this.getInternalNodesMemoryData(start, end, step);
 
-    const rootNodes: IPrometheusNode[] = [
-      {
-        type: 'coord',
-        pod: cpuNodes.find((node: any) => node.metric.container === 'rootcoord')
-          .metric.pod,
-        cpu: cpuNodes
-          .find((node: any) => node.metric.container === 'rootcoord')
-          .values.map((d: any) => +d[1]),
-        memory: memoryNodes
-          .find((node: any) => node.metric.container === 'rootcoord')
-          .values.map((d: any) => +d[1]),
-      },
-    ];
-    const { queryNodes, indexNodes, dataNodes } =
+    // const rootNodes: IPrometheusNode[] = [
+    //   {
+    //     type: 'coord',
+    //     pod: cpuNodes.find((node: any) => node.metric.container === 'rootcoord')
+    //       .metric.pod,
+    //     cpu: cpuNodes
+    //       .find((node: any) => node.metric.container === 'rootcoord')
+    //       .values.map((d: any) => +d[1]),
+    //     memory: memoryNodes
+    //       .find((node: any) => node.metric.container === 'rootcoord')
+    //       .values.map((d: any) => +d[1]),
+    //   },
+    // ];
+    const { rootNodes, queryNodes, indexNodes, dataNodes } =
       await this.getInternalNodesData(start, end, step);
 
     return {