This is an automated email from the ASF dual-hosted git repository. zyk pushed a commit to branch rc/1.1.0 in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit a8c4e7a64979226161507edf7fa7b83eed02ee51 Author: Chen YZ <[email protected]> AuthorDate: Thu Mar 16 21:06:52 2023 +0800 [To rel/1.1][IOTDB-5675] Metric of Schema Template (#9349) --- .../Apache-IoTDB-DataNode-Dashboard.json | 920 +++++++++++++++------ docs/UserGuide/Monitor-Alert/Metric-Tool.md | 21 +- docs/zh/UserGuide/Monitor-Alert/Metric-Tool.md | 19 +- .../db/metadata/metric/SchemaEngineMemMetric.java | 16 +- .../db/metadata/metric/SchemaRegionMemMetric.java | 34 + .../db/metadata/mtree/MTreeBelowSGCachedImpl.java | 26 +- .../db/metadata/mtree/MTreeBelowSGMemoryImpl.java | 15 +- .../mtree/snapshot/MemMTreeSnapshotUtil.java | 13 +- .../db/metadata/mtree/store/MemMTreeStore.java | 4 +- .../metadata/rescon/ISchemaEngineStatistics.java | 2 + .../metadata/rescon/ISchemaRegionStatistics.java | 4 + .../metadata/rescon/MemSchemaEngineStatistics.java | 26 +- .../metadata/rescon/MemSchemaRegionStatistics.java | 36 +- .../schemaregion/SchemaRegionMemoryImpl.java | 5 + .../schemaregion/SchemaRegionSchemaFileImpl.java | 5 + .../metadata/template/ClusterTemplateManager.java | 7 + .../iotdb/db/metadata/template/Template.java | 4 + .../schemaRegion/SchemaStatisticsTest.java | 106 +++ 18 files changed, 977 insertions(+), 286 deletions(-) diff --git a/docs/UserGuide/Monitor-Alert/Apache-IoTDB-DataNode-Dashboard.json b/docs/UserGuide/Monitor-Alert/Apache-IoTDB-DataNode-Dashboard.json index 2b5ac95dda..673e00ba31 100644 --- a/docs/UserGuide/Monitor-Alert/Apache-IoTDB-DataNode-Dashboard.json +++ b/docs/UserGuide/Monitor-Alert/Apache-IoTDB-DataNode-Dashboard.json @@ -11,12 +11,24 @@ ], "__elements": {}, "__requires": [ + { + "type": "panel", + "id": "bargauge", + "name": "Bar gauge", + "version": "" + }, { "type": "grafana", "id": "grafana", "name": "Grafana", "version": "9.3.1" }, + { + "type": "panel", + "id": "piechart", + "name": "Pie chart", + "version": "" + }, { "type": "datasource", "id": "prometheus", @@ -66,6 +78,81 @@ "links": [], "liveNow": false, "panels": [ + { + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 0 + }, + "id": 231, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "title": "Panel Title", + "type": "timeseries" + }, { "collapsed": true, "datasource": { @@ -76,7 +163,7 @@ "h": 1, "w": 24, "x": 0, - "y": 0 + "y": 8 }, "id": 1, "panels": [ @@ -136,7 +223,7 @@ "h": 8, "w": 8, "x": 0, - "y": 41 + "y": 49 }, "id": 2, "options": { @@ -225,7 +312,7 @@ "h": 8, "w": 8, "x": 8, - "y": 41 + "y": 49 }, "id": 3, "options": { @@ -315,7 +402,7 @@ "h": 8, "w": 8, "x": 16, - "y": 41 + "y": 49 }, "id": 4, "options": { @@ -371,7 +458,7 @@ "h": 1, "w": 24, "x": 0, - "y": 1 + "y": 9 }, "id": 5, "panels": [ @@ -432,7 +519,7 @@ "h": 8, "w": 8, "x": 0, - "y": 42 + "y": 50 }, "id": 6, "options": { @@ -521,7 +608,7 @@ "h": 8, "w": 8, "x": 8, - "y": 42 + "y": 50 }, "id": 55, "options": { @@ -610,7 +697,7 @@ "h": 8, "w": 8, "x": 16, - "y": 42 + "y": 50 }, "id": 56, "options": { @@ -699,7 +786,7 @@ "h": 8, "w": 8, "x": 0, - "y": 50 + "y": 58 }, "id": 9, "options": { @@ -789,7 +876,7 @@ "h": 8, "w": 8, "x": 8, - "y": 50 + "y": 58 }, "id": 10, "options": { @@ -881,7 +968,7 @@ "h": 8, "w": 8, "x": 16, - "y": 50 + "y": 58 }, "id": 11, "options": { @@ -981,7 +1068,7 @@ "h": 8, "w": 8, "x": 0, - "y": 58 + "y": 66 }, "id": 12, "options": { @@ -1069,7 +1156,7 @@ "h": 8, "w": 8, "x": 8, - "y": 58 + "y": 66 }, "id": 13, "options": { @@ -1125,7 +1212,7 @@ "h": 1, "w": 24, "x": 0, - "y": 2 + "y": 10 }, "id": 14, "panels": [ @@ -1185,7 +1272,7 @@ "h": 8, "w": 12, "x": 0, - "y": 3 + "y": 11 }, "id": 15, "options": { @@ -1275,7 +1362,7 @@ "h": 8, "w": 12, "x": 12, - "y": 3 + "y": 11 }, "id": 16, "options": { @@ -1365,7 +1452,7 @@ "h": 8, "w": 8, "x": 0, - "y": 11 + "y": 19 }, "id": 17, "options": { @@ -1467,7 +1554,7 @@ "h": 8, "w": 8, "x": 8, - "y": 11 + "y": 19 }, "id": 18, "options": { @@ -1557,7 +1644,7 @@ "h": 8, "w": 8, "x": 16, - "y": 11 + "y": 19 }, "id": 19, "options": { @@ -1674,7 +1761,7 @@ "h": 8, "w": 12, "x": 0, - "y": 19 + "y": 27 }, "id": 169, "options": { @@ -1797,7 +1884,7 @@ "h": 8, "w": 12, "x": 12, - "y": 19 + "y": 27 }, "id": 171, "options": { @@ -1851,7 +1938,7 @@ "h": 1, "w": 24, "x": 0, - "y": 3 + "y": 11 }, "id": 58, "panels": [ @@ -1912,7 +1999,7 @@ "h": 8, "w": 6, "x": 0, - "y": 4 + "y": 12 }, "id": 80, "options": { @@ -2000,7 +2087,7 @@ "h": 8, "w": 6, "x": 6, - "y": 4 + "y": 12 }, "id": 60, "options": { @@ -2088,7 +2175,7 @@ "h": 8, "w": 6, "x": 12, - "y": 4 + "y": 12 }, "id": 61, "options": { @@ -2176,7 +2263,7 @@ "h": 8, "w": 6, "x": 18, - "y": 4 + "y": 12 }, "id": 62, "options": { @@ -2264,7 +2351,7 @@ "h": 8, "w": 6, "x": 0, - "y": 12 + "y": 20 }, "id": 63, "options": { @@ -2352,7 +2439,7 @@ "h": 8, "w": 6, "x": 6, - "y": 12 + "y": 20 }, "id": 81, "options": { @@ -2440,7 +2527,7 @@ "h": 8, "w": 6, "x": 12, - "y": 12 + "y": 20 }, "id": 64, "options": { @@ -2528,7 +2615,7 @@ "h": 8, "w": 6, "x": 18, - "y": 12 + "y": 20 }, "id": 65, "options": { @@ -2616,7 +2703,7 @@ "h": 8, "w": 6, "x": 0, - "y": 20 + "y": 28 }, "id": 83, "options": { @@ -2704,7 +2791,7 @@ "h": 8, "w": 6, "x": 6, - "y": 20 + "y": 28 }, "id": 66, "options": { @@ -2792,7 +2879,7 @@ "h": 8, "w": 6, "x": 12, - "y": 20 + "y": 28 }, "id": 67, "options": { @@ -2880,7 +2967,7 @@ "h": 8, "w": 6, "x": 18, - "y": 20 + "y": 28 }, "id": 68, "options": { @@ -2968,7 +3055,7 @@ "h": 8, "w": 6, "x": 0, - "y": 28 + "y": 36 }, "id": 82, "options": { @@ -3056,7 +3143,7 @@ "h": 8, "w": 6, "x": 6, - "y": 28 + "y": 36 }, "id": 69, "options": { @@ -3144,7 +3231,7 @@ "h": 8, "w": 6, "x": 12, - "y": 28 + "y": 36 }, "id": 70, "options": { @@ -3232,7 +3319,7 @@ "h": 8, "w": 6, "x": 18, - "y": 28 + "y": 36 }, "id": 71, "options": { @@ -3320,7 +3407,7 @@ "h": 8, "w": 6, "x": 0, - "y": 36 + "y": 44 }, "id": 72, "options": { @@ -3408,7 +3495,7 @@ "h": 8, "w": 6, "x": 6, - "y": 36 + "y": 44 }, "id": 84, "options": { @@ -3496,7 +3583,7 @@ "h": 8, "w": 6, "x": 12, - "y": 36 + "y": 44 }, "id": 73, "options": { @@ -3584,7 +3671,7 @@ "h": 8, "w": 6, "x": 18, - "y": 36 + "y": 44 }, "id": 74, "options": { @@ -3672,7 +3759,7 @@ "h": 8, "w": 6, "x": 0, - "y": 44 + "y": 52 }, "id": 131, "options": { @@ -3761,7 +3848,7 @@ "h": 8, "w": 6, "x": 6, - "y": 44 + "y": 52 }, "id": 132, "options": { @@ -3850,7 +3937,7 @@ "h": 8, "w": 6, "x": 12, - "y": 44 + "y": 52 }, "id": 133, "options": { @@ -3940,7 +4027,7 @@ "h": 8, "w": 6, "x": 18, - "y": 44 + "y": 52 }, "id": 134, "options": { @@ -4029,7 +4116,7 @@ "h": 8, "w": 6, "x": 0, - "y": 52 + "y": 60 }, "id": 76, "options": { @@ -4117,7 +4204,7 @@ "h": 8, "w": 6, "x": 6, - "y": 52 + "y": 60 }, "id": 128, "options": { @@ -4205,7 +4292,7 @@ "h": 8, "w": 6, "x": 12, - "y": 52 + "y": 60 }, "id": 129, "options": { @@ -4293,7 +4380,7 @@ "h": 8, "w": 6, "x": 18, - "y": 52 + "y": 60 }, "id": 130, "options": { @@ -4381,7 +4468,7 @@ "h": 8, "w": 6, "x": 0, - "y": 60 + "y": 68 }, "id": 135, "options": { @@ -4469,7 +4556,7 @@ "h": 8, "w": 6, "x": 6, - "y": 60 + "y": 68 }, "id": 136, "options": { @@ -4557,7 +4644,7 @@ "h": 8, "w": 6, "x": 12, - "y": 60 + "y": 68 }, "id": 137, "options": { @@ -4645,7 +4732,7 @@ "h": 8, "w": 6, "x": 18, - "y": 60 + "y": 68 }, "id": 138, "options": { @@ -4733,7 +4820,7 @@ "h": 8, "w": 8, "x": 0, - "y": 68 + "y": 76 }, "id": 139, "options": { @@ -4821,7 +4908,7 @@ "h": 8, "w": 8, "x": 8, - "y": 68 + "y": 76 }, "id": 140, "options": { @@ -4909,7 +4996,7 @@ "h": 8, "w": 8, "x": 16, - "y": 68 + "y": 76 }, "id": 167, "options": { @@ -4998,7 +5085,7 @@ "h": 8, "w": 6, "x": 0, - "y": 76 + "y": 84 }, "id": 163, "options": { @@ -5087,7 +5174,7 @@ "h": 8, "w": 6, "x": 6, - "y": 76 + "y": 84 }, "id": 164, "options": { @@ -5176,7 +5263,7 @@ "h": 8, "w": 6, "x": 12, - "y": 76 + "y": 84 }, "id": 165, "options": { @@ -5265,7 +5352,7 @@ "h": 8, "w": 6, "x": 18, - "y": 76 + "y": 84 }, "id": 166, "options": { @@ -5320,7 +5407,7 @@ "h": 1, "w": 24, "x": 0, - "y": 4 + "y": 12 }, "id": 100, "panels": [ @@ -5381,7 +5468,7 @@ "h": 8, "w": 6, "x": 0, - "y": 5 + "y": 13 }, "id": 75, "options": { @@ -5469,7 +5556,7 @@ "h": 8, "w": 6, "x": 6, - "y": 5 + "y": 13 }, "id": 85, "options": { @@ -5557,7 +5644,7 @@ "h": 8, "w": 6, "x": 12, - "y": 5 + "y": 13 }, "id": 77, "options": { @@ -5645,7 +5732,7 @@ "h": 8, "w": 6, "x": 18, - "y": 5 + "y": 13 }, "id": 78, "options": { @@ -5733,7 +5820,7 @@ "h": 8, "w": 6, "x": 0, - "y": 13 + "y": 21 }, "id": 86, "options": { @@ -5821,7 +5908,7 @@ "h": 8, "w": 6, "x": 6, - "y": 13 + "y": 21 }, "id": 87, "options": { @@ -5909,7 +5996,7 @@ "h": 8, "w": 6, "x": 12, - "y": 13 + "y": 21 }, "id": 88, "options": { @@ -5997,7 +6084,7 @@ "h": 8, "w": 6, "x": 18, - "y": 13 + "y": 21 }, "id": 89, "options": { @@ -6085,7 +6172,7 @@ "h": 8, "w": 6, "x": 0, - "y": 21 + "y": 29 }, "id": 90, "options": { @@ -6173,7 +6260,7 @@ "h": 8, "w": 6, "x": 6, - "y": 21 + "y": 29 }, "id": 91, "options": { @@ -6261,7 +6348,7 @@ "h": 8, "w": 6, "x": 12, - "y": 21 + "y": 29 }, "id": 92, "options": { @@ -6349,7 +6436,7 @@ "h": 8, "w": 6, "x": 18, - "y": 21 + "y": 29 }, "id": 93, "options": { @@ -6437,7 +6524,7 @@ "h": 8, "w": 6, "x": 0, - "y": 29 + "y": 37 }, "id": 94, "options": { @@ -6525,7 +6612,7 @@ "h": 8, "w": 6, "x": 6, - "y": 29 + "y": 37 }, "id": 95, "options": { @@ -6613,7 +6700,7 @@ "h": 8, "w": 6, "x": 12, - "y": 29 + "y": 37 }, "id": 96, "options": { @@ -6701,7 +6788,7 @@ "h": 8, "w": 6, "x": 18, - "y": 29 + "y": 37 }, "id": 97, "options": { @@ -6789,7 +6876,7 @@ "h": 8, "w": 6, "x": 0, - "y": 37 + "y": 45 }, "id": 98, "options": { @@ -6878,7 +6965,7 @@ "h": 8, "w": 6, "x": 6, - "y": 37 + "y": 45 }, "id": 101, "options": { @@ -6967,7 +7054,7 @@ "h": 8, "w": 6, "x": 12, - "y": 37 + "y": 45 }, "id": 102, "options": { @@ -7056,7 +7143,7 @@ "h": 8, "w": 6, "x": 18, - "y": 37 + "y": 45 }, "id": 103, "options": { @@ -7144,7 +7231,7 @@ "h": 8, "w": 6, "x": 0, - "y": 45 + "y": 53 }, "id": 104, "options": { @@ -7233,7 +7320,7 @@ "h": 8, "w": 6, "x": 6, - "y": 45 + "y": 53 }, "id": 105, "options": { @@ -7322,7 +7409,7 @@ "h": 8, "w": 6, "x": 12, - "y": 45 + "y": 53 }, "id": 106, "options": { @@ -7411,7 +7498,7 @@ "h": 8, "w": 6, "x": 18, - "y": 45 + "y": 53 }, "id": 107, "options": { @@ -7499,7 +7586,7 @@ "h": 8, "w": 6, "x": 0, - "y": 53 + "y": 61 }, "id": 108, "options": { @@ -7588,7 +7675,7 @@ "h": 8, "w": 6, "x": 6, - "y": 53 + "y": 61 }, "id": 109, "options": { @@ -7677,7 +7764,7 @@ "h": 8, "w": 6, "x": 12, - "y": 53 + "y": 61 }, "id": 110, "options": { @@ -7766,7 +7853,7 @@ "h": 8, "w": 6, "x": 18, - "y": 53 + "y": 61 }, "id": 111, "options": { @@ -7852,7 +7939,7 @@ "h": 8, "w": 6, "x": 0, - "y": 61 + "y": 69 }, "id": 112, "options": { @@ -7939,7 +8026,7 @@ "h": 8, "w": 6, "x": 6, - "y": 61 + "y": 69 }, "id": 113, "options": { @@ -8026,7 +8113,7 @@ "h": 8, "w": 6, "x": 12, - "y": 61 + "y": 69 }, "id": 114, "options": { @@ -8113,7 +8200,7 @@ "h": 8, "w": 6, "x": 18, - "y": 61 + "y": 69 }, "id": 115, "options": { @@ -8199,7 +8286,7 @@ "h": 8, "w": 6, "x": 0, - "y": 69 + "y": 77 }, "id": 116, "options": { @@ -8286,7 +8373,7 @@ "h": 8, "w": 6, "x": 6, - "y": 69 + "y": 77 }, "id": 117, "options": { @@ -8373,7 +8460,7 @@ "h": 8, "w": 6, "x": 12, - "y": 69 + "y": 77 }, "id": 118, "options": { @@ -8460,7 +8547,7 @@ "h": 8, "w": 6, "x": 18, - "y": 69 + "y": 77 }, "id": 119, "options": { @@ -8546,7 +8633,7 @@ "h": 8, "w": 6, "x": 0, - "y": 77 + "y": 85 }, "id": 120, "options": { @@ -8633,7 +8720,7 @@ "h": 8, "w": 6, "x": 6, - "y": 77 + "y": 85 }, "id": 121, "options": { @@ -8720,7 +8807,7 @@ "h": 8, "w": 6, "x": 12, - "y": 77 + "y": 85 }, "id": 122, "options": { @@ -8807,7 +8894,7 @@ "h": 8, "w": 6, "x": 18, - "y": 77 + "y": 85 }, "id": 123, "options": { @@ -8893,7 +8980,7 @@ "h": 8, "w": 6, "x": 0, - "y": 85 + "y": 93 }, "id": 124, "options": { @@ -8980,7 +9067,7 @@ "h": 8, "w": 6, "x": 6, - "y": 85 + "y": 93 }, "id": 125, "options": { @@ -9067,7 +9154,7 @@ "h": 8, "w": 6, "x": 12, - "y": 85 + "y": 93 }, "id": 126, "options": { @@ -9154,7 +9241,7 @@ "h": 8, "w": 6, "x": 18, - "y": 85 + "y": 93 }, "id": 127, "options": { @@ -9208,7 +9295,7 @@ "h": 1, "w": 24, "x": 0, - "y": 5 + "y": 13 }, "id": 142, "panels": [ @@ -9269,7 +9356,7 @@ "h": 8, "w": 6, "x": 0, - "y": 6 + "y": 14 }, "id": 143, "options": { @@ -9357,7 +9444,7 @@ "h": 8, "w": 6, "x": 6, - "y": 6 + "y": 14 }, "id": 144, "options": { @@ -9445,7 +9532,7 @@ "h": 8, "w": 6, "x": 12, - "y": 6 + "y": 14 }, "id": 145, "options": { @@ -9533,7 +9620,7 @@ "h": 8, "w": 6, "x": 18, - "y": 6 + "y": 14 }, "id": 146, "options": { @@ -9621,7 +9708,7 @@ "h": 8, "w": 6, "x": 0, - "y": 14 + "y": 22 }, "id": 147, "options": { @@ -9709,7 +9796,7 @@ "h": 8, "w": 6, "x": 6, - "y": 14 + "y": 22 }, "id": 148, "options": { @@ -9797,7 +9884,7 @@ "h": 8, "w": 6, "x": 12, - "y": 14 + "y": 22 }, "id": 149, "options": { @@ -9885,7 +9972,7 @@ "h": 8, "w": 6, "x": 18, - "y": 14 + "y": 22 }, "id": 150, "options": { @@ -9973,7 +10060,7 @@ "h": 8, "w": 6, "x": 0, - "y": 22 + "y": 30 }, "id": 151, "options": { @@ -10061,7 +10148,7 @@ "h": 8, "w": 6, "x": 6, - "y": 22 + "y": 30 }, "id": 152, "options": { @@ -10149,7 +10236,7 @@ "h": 8, "w": 6, "x": 12, - "y": 22 + "y": 30 }, "id": 153, "options": { @@ -10237,7 +10324,7 @@ "h": 8, "w": 6, "x": 18, - "y": 22 + "y": 30 }, "id": 154, "options": { @@ -10325,7 +10412,7 @@ "h": 8, "w": 6, "x": 0, - "y": 30 + "y": 38 }, "id": 155, "options": { @@ -10413,7 +10500,7 @@ "h": 8, "w": 6, "x": 6, - "y": 30 + "y": 38 }, "id": 156, "options": { @@ -10501,7 +10588,7 @@ "h": 8, "w": 6, "x": 12, - "y": 30 + "y": 38 }, "id": 157, "options": { @@ -10589,7 +10676,7 @@ "h": 8, "w": 6, "x": 18, - "y": 30 + "y": 38 }, "id": 158, "options": { @@ -10677,7 +10764,7 @@ "h": 8, "w": 6, "x": 0, - "y": 38 + "y": 46 }, "id": 159, "options": { @@ -10765,7 +10852,7 @@ "h": 8, "w": 6, "x": 6, - "y": 38 + "y": 46 }, "id": 160, "options": { @@ -10853,7 +10940,7 @@ "h": 8, "w": 6, "x": 12, - "y": 38 + "y": 46 }, "id": 161, "options": { @@ -10941,7 +11028,7 @@ "h": 8, "w": 6, "x": 18, - "y": 38 + "y": 46 }, "id": 162, "options": { @@ -10995,7 +11082,7 @@ "h": 1, "w": 24, "x": 0, - "y": 6 + "y": 14 }, "id": 20, "panels": [ @@ -11056,7 +11143,7 @@ "h": 8, "w": 8, "x": 0, - "y": 7 + "y": 15 }, "id": 21, "options": { @@ -11174,7 +11261,7 @@ "h": 8, "w": 8, "x": 8, - "y": 7 + "y": 15 }, "id": 22, "options": { @@ -11265,7 +11352,7 @@ "h": 8, "w": 8, "x": 16, - "y": 7 + "y": 15 }, "id": 23, "options": { @@ -11371,7 +11458,7 @@ "h": 8, "w": 8, "x": 0, - "y": 15 + "y": 23 }, "id": 24, "options": { @@ -11492,7 +11579,7 @@ "h": 8, "w": 8, "x": 8, - "y": 15 + "y": 23 }, "id": 25, "options": { @@ -11608,7 +11695,7 @@ "h": 8, "w": 8, "x": 16, - "y": 15 + "y": 23 }, "id": 26, "options": { @@ -11698,7 +11785,7 @@ "h": 8, "w": 8, "x": 0, - "y": 23 + "y": 31 }, "id": 27, "options": { @@ -11788,7 +11875,7 @@ "h": 8, "w": 8, "x": 8, - "y": 23 + "y": 31 }, "id": 175, "options": { @@ -11878,7 +11965,7 @@ "h": 8, "w": 8, "x": 16, - "y": 23 + "y": 31 }, "id": 29, "options": { @@ -11969,7 +12056,7 @@ "h": 8, "w": 8, "x": 0, - "y": 31 + "y": 39 }, "id": 30, "options": { @@ -12062,7 +12149,7 @@ "h": 8, "w": 8, "x": 8, - "y": 31 + "y": 39 }, "id": 31, "options": { @@ -12156,7 +12243,7 @@ "h": 8, "w": 8, "x": 16, - "y": 31 + "y": 39 }, "id": 32, "options": { @@ -12249,7 +12336,7 @@ "h": 8, "w": 8, "x": 0, - "y": 39 + "y": 47 }, "id": 28, "options": { @@ -12339,7 +12426,7 @@ "h": 8, "w": 8, "x": 8, - "y": 39 + "y": 47 }, "id": 173, "options": { @@ -12395,7 +12482,7 @@ "h": 1, "w": 24, "x": 0, - "y": 7 + "y": 15 }, "id": 33, "panels": [ @@ -12426,7 +12513,7 @@ "h": 8, "w": 8, "x": 0, - "y": 16 + "y": 24 }, "id": 34, "options": { @@ -12521,7 +12608,7 @@ "h": 8, "w": 8, "x": 8, - "y": 16 + "y": 24 }, "id": 35, "options": { @@ -12625,7 +12712,7 @@ "h": 8, "w": 8, "x": 16, - "y": 16 + "y": 24 }, "id": 40, "options": { @@ -12717,7 +12804,7 @@ "h": 8, "w": 8, "x": 0, - "y": 24 + "y": 32 }, "id": 41, "options": { @@ -12833,7 +12920,7 @@ "h": 8, "w": 8, "x": 8, - "y": 24 + "y": 32 }, "id": 42, "options": { @@ -12937,7 +13024,7 @@ "h": 8, "w": 8, "x": 16, - "y": 24 + "y": 32 }, "id": 43, "options": { @@ -13051,7 +13138,7 @@ "h": 8, "w": 8, "x": 0, - "y": 32 + "y": 40 }, "id": 44, "options": { @@ -13175,7 +13262,7 @@ "h": 8, "w": 8, "x": 8, - "y": 32 + "y": 40 }, "id": 45, "options": { @@ -13276,7 +13363,7 @@ "h": 8, "w": 8, "x": 16, - "y": 32 + "y": 40 }, "id": 46, "options": { @@ -13379,7 +13466,7 @@ "h": 7, "w": 8, "x": 0, - "y": 40 + "y": 48 }, "id": 47, "options": { @@ -13481,7 +13568,7 @@ "h": 7, "w": 8, "x": 8, - "y": 40 + "y": 48 }, "id": 48, "options": { @@ -13580,7 +13667,7 @@ "h": 7, "w": 8, "x": 16, - "y": 40 + "y": 48 }, "id": 49, "options": { @@ -13680,7 +13767,7 @@ "h": 8, "w": 8, "x": 0, - "y": 47 + "y": 55 }, "id": 50, "options": { @@ -13816,7 +13903,7 @@ "h": 8, "w": 8, "x": 8, - "y": 47 + "y": 55 }, "id": 51, "options": { @@ -13950,7 +14037,7 @@ "h": 8, "w": 8, "x": 16, - "y": 47 + "y": 55 }, "id": 52, "options": { @@ -14041,7 +14128,7 @@ "h": 8, "w": 8, "x": 0, - "y": 55 + "y": 63 }, "id": 53, "options": { @@ -14132,7 +14219,7 @@ "h": 8, "w": 8, "x": 8, - "y": 55 + "y": 63 }, "id": 54, "options": { @@ -14200,7 +14287,7 @@ "h": 1, "w": 24, "x": 0, - "y": 8 + "y": 16 }, "id": 177, "panels": [ @@ -14271,7 +14358,7 @@ "h": 8, "w": 12, "x": 0, - "y": 87 + "y": 95 }, "id": 179, "options": { @@ -14362,7 +14449,7 @@ "h": 8, "w": 12, "x": 12, - "y": 87 + "y": 95 }, "id": 181, "options": { @@ -14453,7 +14540,7 @@ "h": 8, "w": 12, "x": 0, - "y": 95 + "y": 103 }, "id": 183, "options": { @@ -14546,7 +14633,7 @@ "h": 8, "w": 12, "x": 12, - "y": 95 + "y": 103 }, "id": 185, "options": { @@ -14635,7 +14722,7 @@ "h": 8, "w": 8, "x": 0, - "y": 103 + "y": 111 }, "id": 187, "options": { @@ -14728,7 +14815,7 @@ "h": 8, "w": 8, "x": 8, - "y": 103 + "y": 111 }, "id": 189, "options": { @@ -14819,7 +14906,7 @@ "h": 8, "w": 8, "x": 16, - "y": 103 + "y": 111 }, "id": 193, "options": { @@ -14913,7 +15000,7 @@ "h": 8, "w": 12, "x": 0, - "y": 111 + "y": 119 }, "id": 191, "options": { @@ -15003,7 +15090,7 @@ "h": 8, "w": 12, "x": 12, - "y": 111 + "y": 119 }, "id": 195, "options": { @@ -15055,7 +15142,7 @@ "h": 1, "w": 24, "x": 0, - "y": 9 + "y": 17 }, "id": 197, "panels": [], @@ -15102,13 +15189,13 @@ }, "gridPos": { "h": 4, - "w": 4, + "w": 8, "x": 0, - "y": 10 + "y": 18 }, "id": 224, "options": { - "colorMode": "value", + "colorMode": "none", "graphMode": "none", "justifyMode": "auto", "orientation": "auto", @@ -15140,6 +15227,250 @@ "title": "Schema Engine Mode", "type": "stat" }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [ + { + "options": { + "0": { + "index": 0, + "text": "RatisConsensus" + }, + "1": { + "index": 1, + "text": "SimpleConsensus" + } + }, + "type": "value" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 8, + "x": 8, + "y": 18 + }, + "id": 225, + "options": { + "colorMode": "none", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "value" + }, + "pluginVersion": "9.3.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "schema_engine{name=\"schema_region_consensus\",instance=~\"$instance\"}", + "instant": false, + "legendFormat": "{{name}}", + "range": true, + "refId": "A" + } + ], + "title": "Schema Consensus Protocol", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 8, + "x": 16, + "y": 18 + }, + "id": 219, + "options": { + "colorMode": "none", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "9.3.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "schema_engine{name=\"schema_region_number\",instance=~\"$instance\"}", + "instant": false, + "legendFormat": "{{name}}", + "range": true, + "refId": "A" + } + ], + "title": "Schema Region Number", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + } + }, + "mappings": [], + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 4, + "x": 0, + "y": 22 + }, + "id": 235, + "options": { + "displayLabels": [], + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true, + "values": [] + }, + "pieType": "pie", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "9.3.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "sum(quantity{name=\"timeSeries\", instance=~\"$instance\"})-\nsum(quantity{name=\"template_series_cnt\", instance=~\"$instance\"})", + "format": "time_series", + "hide": false, + "instant": false, + "legendFormat": "Normal", + "range": true, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "quantity{name=\"template_series_cnt\", instance=~\"$instance\"}", + "hide": false, + "legendFormat": "Template", + "range": true, + "refId": "B" + } + ], + "title": "Series Type", + "transformations": [ + { + "id": "calculateField", + "options": { + "alias": "normal series", + "binary": { + "left": "{__name__=\"quantity\", cluster=\"defaultCluster\", instance=\"localhost:9093\", job=\"datanode\", name=\"timeSeries\", nodeId=\"-1\", nodeType=\"DATANODE\"}", + "operator": "-", + "reducer": "sum", + "right": "{__name__=\"quantity\", cluster=\"defaultCluster\", instance=\"localhost:9093\", job=\"datanode\", name=\"template_series_num\", nodeId=\"-1\", nodeType=\"DATANODE\"}" + }, + "mode": "binary", + "reduce": { + "reducer": "sum" + }, + "replaceFields": false + } + } + ], + "type": "piechart" + }, { "datasource": { "type": "prometheus", @@ -15168,9 +15499,9 @@ "h": 4, "w": 4, "x": 4, - "y": 10 + "y": 22 }, - "id": 219, + "id": 222, "options": { "colorMode": "value", "graphMode": "area", @@ -15194,14 +15525,14 @@ }, "editorMode": "code", "exemplar": false, - "expr": "schema_engine{name=\"schema_region_number\",instance=~\"$instance\"}", + "expr": "quantity{name=\"timeSeries\",instance=~\"$instance\"}", "instant": false, "legendFormat": "{{name}}", "range": true, "refId": "A" } ], - "title": "Schema Region Number", + "title": "Time Series Number", "type": "stat" }, { @@ -15320,7 +15651,7 @@ "h": 8, "w": 16, "x": 8, - "y": 10 + "y": 22 }, "id": 217, "options": { @@ -15361,21 +15692,7 @@ "color": { "mode": "thresholds" }, - "mappings": [ - { - "options": { - "0": { - "index": 0, - "text": "RatisConsensus" - }, - "1": { - "index": 1, - "text": "SimpleConsensus" - } - }, - "type": "value" - } - ], + "mappings": [], "thresholds": { "mode": "absolute", "steps": [ @@ -15392,13 +15709,13 @@ "gridPos": { "h": 4, "w": 4, - "x": 0, - "y": 14 + "x": 4, + "y": 26 }, - "id": 225, + "id": 236, "options": { "colorMode": "value", - "graphMode": "none", + "graphMode": "area", "justifyMode": "auto", "orientation": "auto", "reduceOptions": { @@ -15419,14 +15736,14 @@ }, "editorMode": "code", "exemplar": false, - "expr": "schema_engine{name=\"schema_region_consensus\",instance=~\"$instance\"}", + "expr": "quantity{name=\"template_series_cnt\",instance=~\"$instance\"}", "instant": false, "legendFormat": "{{name}}", "range": true, "refId": "A" } ], - "title": "Schema Consensus Protocol", + "title": "Template Series Number", "type": "stat" }, { @@ -15434,10 +15751,41 @@ "type": "prometheus", "uid": "${DS_PROMETHEUS}" }, + "description": "", "fieldConfig": { "defaults": { "color": { - "mode": "thresholds" + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } }, "mappings": [], "thresholds": { @@ -15446,35 +15794,35 @@ { "color": "green", "value": null + }, + { + "color": "red", + "value": 80 } ] - }, - "unit": "none" + } }, "overrides": [] }, "gridPos": { - "h": 4, - "w": 4, - "x": 4, - "y": 14 + "h": 7, + "w": 12, + "x": 0, + "y": 30 }, - "id": 222, + "id": 233, "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true }, - "textMode": "value" + "tooltip": { + "mode": "single", + "sort": "none" + } }, - "pluginVersion": "9.3.1", "targets": [ { "datasource": { @@ -15482,23 +15830,20 @@ "uid": "${DS_PROMETHEUS}" }, "editorMode": "code", - "exemplar": false, - "expr": "quantity{name=\"timeSeries\",instance=~\"$instance\"}", - "instant": false, - "legendFormat": "{{name}}", + "expr": "schema_region{name=\"schema_region_series_cnt\",instance=~\"$instance\"}", + "legendFormat": "{{region}}", "range": true, "refId": "A" } ], - "title": "Time Series Number", - "type": "stat" + "title": "Timeseries Count per SchemaRegion", + "type": "timeseries" }, { "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" }, - "description": "", "fieldConfig": { "defaults": { "color": { @@ -15547,17 +15892,18 @@ "value": 80 } ] - } + }, + "unit": "bytes" }, "overrides": [] }, "gridPos": { "h": 7, "w": 12, - "x": 0, - "y": 18 + "x": 12, + "y": 30 }, - "id": 215, + "id": 213, "options": { "legend": { "calcs": [], @@ -15577,13 +15923,13 @@ "uid": "${DS_PROMETHEUS}" }, "editorMode": "code", - "expr": "schema_region{name=\"schema_region_series_cnt\",instance=~\"$instance\"}", + "expr": "schema_region{name=\"schema_region_mem_usage\",instance=~\"$instance\"}", "legendFormat": "{{region}}", "range": true, "refId": "A" } ], - "title": "Timeseries Count per SchemaRegion", + "title": "Memory Usgae per SchemaRegion", "type": "timeseries" }, { @@ -15591,6 +15937,73 @@ "type": "prometheus", "uid": "${DS_PROMETHEUS}" }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 37 + }, + "id": 215, + "options": { + "displayMode": "gradient", + "minVizHeight": 10, + "minVizWidth": 0, + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showUnfilled": true + }, + "pluginVersion": "9.3.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "schema_region{name=\"activated_template_cnt\",instance=~\"$instance\"}", + "legendFormat": "{{region}}", + "range": true, + "refId": "A" + } + ], + "title": "Activated Template Count per SchemaRegion", + "type": "bargauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "description": "", "fieldConfig": { "defaults": { "color": { @@ -15639,8 +16052,7 @@ "value": 80 } ] - }, - "unit": "bytes" + } }, "overrides": [] }, @@ -15648,9 +16060,9 @@ "h": 7, "w": 12, "x": 12, - "y": 18 + "y": 37 }, - "id": 213, + "id": 232, "options": { "legend": { "calcs": [], @@ -15670,13 +16082,13 @@ "uid": "${DS_PROMETHEUS}" }, "editorMode": "code", - "expr": "schema_region{name=\"schema_region_mem_usage\",instance=~\"$instance\"}", + "expr": "schema_region{name=\"template_series_cnt\",instance=~\"$instance\"}", "legendFormat": "{{region}}", "range": true, "refId": "A" } ], - "title": "Memory Usgae per SchemaRegion", + "title": "Template Series Count per SchemaRegion", "type": "timeseries" }, { @@ -15740,7 +16152,7 @@ "h": 7, "w": 6, "x": 0, - "y": 25 + "y": 44 }, "id": 199, "options": { @@ -15836,7 +16248,7 @@ "h": 7, "w": 6, "x": 6, - "y": 25 + "y": 44 }, "id": 203, "options": { @@ -15928,7 +16340,7 @@ "h": 7, "w": 6, "x": 12, - "y": 25 + "y": 44 }, "id": 209, "options": { @@ -16021,7 +16433,7 @@ "h": 7, "w": 6, "x": 18, - "y": 25 + "y": 44 }, "id": 211, "options": { @@ -16113,7 +16525,7 @@ "h": 7, "w": 6, "x": 0, - "y": 32 + "y": 51 }, "id": 201, "options": { @@ -16207,7 +16619,7 @@ "h": 7, "w": 6, "x": 6, - "y": 32 + "y": 51 }, "id": 205, "options": { @@ -16299,7 +16711,7 @@ "h": 7, "w": 6, "x": 12, - "y": 32 + "y": 51 }, "id": 207, "options": { @@ -16391,7 +16803,7 @@ "h": 7, "w": 6, "x": 18, - "y": 32 + "y": 51 }, "id": 220, "options": { @@ -16483,7 +16895,7 @@ "h": 7, "w": 6, "x": 0, - "y": 39 + "y": 58 }, "id": 221, "options": { @@ -16575,7 +16987,7 @@ "h": 7, "w": 6, "x": 6, - "y": 39 + "y": 58 }, "id": 223, "options": { @@ -16668,7 +17080,7 @@ "h": 7, "w": 6, "x": 12, - "y": 39 + "y": 58 }, "id": 229, "options": { @@ -16761,7 +17173,7 @@ "h": 7, "w": 6, "x": 18, - "y": 39 + "y": 58 }, "id": 228, "options": { @@ -16850,8 +17262,8 @@ ] }, "time": { - "from": "now-20m", - "to": "now-10m" + "from": "now-5m", + "to": "now" }, "timepicker": { "refresh_intervals": [ @@ -16866,6 +17278,6 @@ "timezone": "browser", "title": "Apache IoTDB DataNode Dashboard", "uid": "TbEVYRw7A", - "version": 20, + "version": 5, "weekStart": "" } \ No newline at end of file diff --git a/docs/UserGuide/Monitor-Alert/Metric-Tool.md b/docs/UserGuide/Monitor-Alert/Metric-Tool.md index e8145023c1..21f91a2a9c 100644 --- a/docs/UserGuide/Monitor-Alert/Metric-Tool.md +++ b/docs/UserGuide/Monitor-Alert/Metric-Tool.md @@ -422,15 +422,18 @@ carefully evaluated. The current Core-level metrics are as follows: #### 4.2.16 Schema Engine -| Metric | Tags | Type | Description | -| ------------- | ------------------------------------------------------------------ | --------- | -------------------------------------- | -| schema_engine | name="schema_region_total_mem_usage" | AutoGauge | Memory usgae for all SchemaRegion | -| schema_engine | name="schema_region_mem_capacity" | AutoGauge | Memory capacity for all SchemaRegion | -| schema_engine | name="schema_engine_mode" | Gauge | Mode of SchemaEngine | -| schema_engine | name="schema_region_consensus" | Gauge | Consensus protocol of SchemaRegion | -| schema_engine | name="schema_region_number" | AutoGauge | Number of SchemaRegion | -| schema_region | name="schema_region_mem_usage", region="SchemaRegion[{regionId}]" | AutoGauge | Memory usgae for each SchemaRegion | -| schema_region | name="schema_region_series_cnt", region="SchemaRegion[{regionId}]" | AutoGauge | Timeseries count for each SchemaRegion | +| Metric | Tags | Type | Description | +| ------------- | ------------------------------------------------------------ | --------- | -------------------------------------------------- | +| schema_engine | name="schema_region_total_mem_usage" | AutoGauge | Memory usgae for all SchemaRegion | +| schema_engine | name="schema_region_mem_capacity" | AutoGauge | Memory capacity for all SchemaRegion | +| schema_engine | name="schema_engine_mode" | Gauge | Mode of SchemaEngine | +| schema_engine | name="schema_region_consensus" | Gauge | Consensus protocol of SchemaRegion | +| schema_engine | name="schema_region_number" | AutoGauge | Number of SchemaRegion | +| quantity | name="template_series_cnt" | AutoGauge | Number of template series | +| schema_region | name="schema_region_mem_usage", region="SchemaRegion[{regionId}]" | AutoGauge | Memory usgae for each SchemaRegion | +| schema_region | name="schema_region_series_cnt", region="SchemaRegion[{regionId}]" | AutoGauge | Number of total timeseries for each SchemaRegion | +| schema_region | name="activated_template_cnt", region="SchemaRegion[{regionId}]" | AutoGauge | Number of Activated template for each SchemaRegion | +| schema_region | name="template_series_cnt", region="SchemaRegion[{regionId}]" | AutoGauge | Number of template series for each SchemaRegion | #### 4.2.17 Write Performance diff --git a/docs/zh/UserGuide/Monitor-Alert/Metric-Tool.md b/docs/zh/UserGuide/Monitor-Alert/Metric-Tool.md index e09b74ac4b..6e9fdf309c 100644 --- a/docs/zh/UserGuide/Monitor-Alert/Metric-Tool.md +++ b/docs/zh/UserGuide/Monitor-Alert/Metric-Tool.md @@ -401,15 +401,18 @@ Core 级别的监控指标在系统运行中默认开启,每一个 Core 级别 #### 4.2.16 元数据引擎统计 -| Metric | Tags | Type | Description | -| ------------- | ------------------------------------------------------------------ | --------- | ---------------------------------- | -| schema_engine | name="schema_region_total_mem_usage" | AutoGauge | SchemaRegion 全局内存使用量 | -| schema_engine | name="schema_region_mem_capacity" | AutoGauge | SchemaRegion 全局可用内存 | -| schema_engine | name="schema_engine_mode" | Gauge | SchemaEngine 模式 | -| schema_engine | name="schema_region_consensus" | Gauge | 元数据管理引擎共识协议 | -| schema_engine | name="schema_region_number" | AutoGauge | SchemaRegion 个数 | -| schema_region | name="schema_region_mem_usage", region="SchemaRegion[{regionId}]" | AutoGauge | 每个 SchemaRegion 分别的内存使用量 | +| Metric | Tags | Type | Description | +| ------------- | ------------------------------------------------------------ | --------- | ---------------------------------- | +| schema_engine | name="schema_region_total_mem_usage" | AutoGauge | SchemaRegion 全局内存使用量 | +| schema_engine | name="schema_region_mem_capacity" | AutoGauge | SchemaRegion 全局可用内存 | +| schema_engine | name="schema_engine_mode" | Gauge | SchemaEngine 模式 | +| schema_engine | name="schema_region_consensus" | Gauge | 元数据管理引擎共识协议 | +| schema_engine | name="schema_region_number" | AutoGauge | SchemaRegion 个数 | +| quantity | name="template_series_cnt" | AutoGauge | 模板序列数 | +| schema_region | name="schema_region_mem_usage", region="SchemaRegion[{regionId}]" | AutoGauge | 每个 SchemaRegion 分别的内存使用量 | | schema_region | name="schema_region_series_cnt", region="SchemaRegion[{regionId}]" | AutoGauge | 每个 SchemaRegion 分别的时间序列数 | +| schema_region | name="activated_template_cnt", region="SchemaRegion[{regionId}]" | AutoGauge | 每个 SchemaRegion 激活的模板数 | +| schema_region | name="template_series_cnt", region="SchemaRegion[{regionId}]" | AutoGauge | 每个 SchemaRegion 的模板序列数 | ### 4.3. Normal 级别监控指标 diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/metric/SchemaEngineMemMetric.java b/server/src/main/java/org/apache/iotdb/db/metadata/metric/SchemaEngineMemMetric.java index 8d56139e63..54f282fbb2 100644 --- a/server/src/main/java/org/apache/iotdb/db/metadata/metric/SchemaEngineMemMetric.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/metric/SchemaEngineMemMetric.java @@ -39,6 +39,8 @@ public class SchemaEngineMemMetric implements ISchemaEngineMetric { private static final String SCHEMA_CONSENSUS = "schema_region_consensus"; private static final String SCHEMA_ENGINE_MODE = "schema_engine_mode"; + private static final String TEMPLATE_SERIES_CNT = "template_series_cnt"; + private final MemSchemaEngineStatistics engineStatistics; public SchemaEngineMemMetric(MemSchemaEngineStatistics engineStatistics) { @@ -54,6 +56,13 @@ public class SchemaEngineMemMetric implements ISchemaEngineMetric { ISchemaEngineStatistics::getTotalSeriesNumber, Tag.NAME.toString(), TIME_SERES_CNT); + metricService.createAutoGauge( + Metric.QUANTITY.toString(), + MetricLevel.IMPORTANT, + engineStatistics, + ISchemaEngineStatistics::getTemplateSeriesNumber, + Tag.NAME.toString(), + TEMPLATE_SERIES_CNT); metricService.createAutoGauge( Metric.MEM.toString(), MetricLevel.IMPORTANT, @@ -100,7 +109,12 @@ public class SchemaEngineMemMetric implements ISchemaEngineMetric { @Override public void unbindFrom(AbstractMetricService metricService) { metricService.remove( - MetricType.AUTO_GAUGE, Metric.QUANTITY.toString(), Tag.NAME.toString(), "timeSeries"); + MetricType.AUTO_GAUGE, Metric.QUANTITY.toString(), Tag.NAME.toString(), TIME_SERES_CNT); + metricService.remove( + MetricType.AUTO_GAUGE, + Metric.QUANTITY.toString(), + Tag.NAME.toString(), + TEMPLATE_SERIES_CNT); metricService.remove( MetricType.AUTO_GAUGE, Metric.MEM.toString(), diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/metric/SchemaRegionMemMetric.java b/server/src/main/java/org/apache/iotdb/db/metadata/metric/SchemaRegionMemMetric.java index a7475537d4..1fc4f4dd63 100644 --- a/server/src/main/java/org/apache/iotdb/db/metadata/metric/SchemaRegionMemMetric.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/metric/SchemaRegionMemMetric.java @@ -29,6 +29,8 @@ public class SchemaRegionMemMetric implements ISchemaRegionMetric { private static final String MEM_USAGE = "schema_region_mem_usage"; private static final String SERIES_CNT = "schema_region_series_cnt"; + private static final String TEMPLATE_CNT = "activated_template_cnt"; + private static final String TEMPLATE_SERIES_CNT = "template_series_cnt"; private final MemSchemaRegionStatistics regionStatistics; private final String regionTagValue; @@ -58,6 +60,24 @@ public class SchemaRegionMemMetric implements ISchemaRegionMetric { SERIES_CNT, Tag.REGION.toString(), regionTagValue); + metricService.createAutoGauge( + Metric.SCHEMA_REGION.toString(), + MetricLevel.IMPORTANT, + regionStatistics, + MemSchemaRegionStatistics::getTemplateActivatedNumber, + Tag.NAME.toString(), + TEMPLATE_CNT, + Tag.REGION.toString(), + regionTagValue); + metricService.createAutoGauge( + Metric.SCHEMA_REGION.toString(), + MetricLevel.IMPORTANT, + regionStatistics, + MemSchemaRegionStatistics::getTemplateSeriesNumber, + Tag.NAME.toString(), + TEMPLATE_SERIES_CNT, + Tag.REGION.toString(), + regionTagValue); } @Override @@ -76,5 +96,19 @@ public class SchemaRegionMemMetric implements ISchemaRegionMetric { SERIES_CNT, Tag.REGION.toString(), regionTagValue); + metricService.remove( + MetricType.AUTO_GAUGE, + Metric.SCHEMA_REGION.toString(), + Tag.NAME.toString(), + TEMPLATE_CNT, + Tag.REGION.toString(), + regionTagValue); + metricService.remove( + MetricType.AUTO_GAUGE, + Metric.SCHEMA_REGION.toString(), + Tag.NAME.toString(), + TEMPLATE_SERIES_CNT, + Tag.REGION.toString(), + regionTagValue); } } diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGCachedImpl.java b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGCachedImpl.java index 60d70848da..a0644e00cb 100644 --- a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGCachedImpl.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGCachedImpl.java @@ -108,6 +108,7 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG { private final IMNode rootNode; private final Function<IMeasurementMNode, Map<String, String>> tagGetter; private final int levelOfSG; + private final CachedSchemaRegionStatistics regionStatistics; // region MTree initialization, clear and serialization public MTreeBelowSGCachedImpl( @@ -119,6 +120,7 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG { CachedSchemaRegionStatistics regionStatistics) throws MetadataException, IOException { this.tagGetter = tagGetter; + this.regionStatistics = regionStatistics; store = new CachedMTreeStore(storageGroupPath, schemaRegionId, regionStatistics, flushCallback); this.storageGroupMNode = store.getRoot().getAsStorageGroupMNode(); this.storageGroupMNode.setParent(storageGroupMNode.getParent()); @@ -145,21 +147,28 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG { PartialPath storageGroupPath, CachedMTreeStore store, Consumer<IMeasurementMNode> measurementProcess, - Function<IMeasurementMNode, Map<String, String>> tagGetter) + Consumer<IEntityMNode> deviceProcess, + Function<IMeasurementMNode, Map<String, String>> tagGetter, + CachedSchemaRegionStatistics regionStatistics) throws MetadataException { this.store = store; + this.regionStatistics = regionStatistics; this.storageGroupMNode = store.getRoot().getAsStorageGroupMNode(); this.rootNode = store.generatePrefix(storageGroupPath); levelOfSG = storageGroupMNode.getPartialPath().getNodeLength() - 1; this.tagGetter = tagGetter; // recover measurement - try (MeasurementCollector<?> collector = - new MeasurementCollector<Void>( + try (MNodeCollector<?> collector = + new MNodeCollector<Void>( this.rootNode, new PartialPath(storageGroupMNode.getFullPath()), this.store, true) { @Override - protected Void collectMeasurement(IMeasurementMNode node) { - measurementProcess.accept(node); + protected Void collectMNode(IMNode node) { + if (node.isMeasurement()) { + measurementProcess.accept(node.getAsMeasurementMNode()); + } else if (node.isEntity()) { + deviceProcess.accept(node.getAsEntityMNode()); + } return null; } }) { @@ -189,6 +198,7 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG { int schemaRegionId, CachedSchemaRegionStatistics regionStatistics, Consumer<IMeasurementMNode> measurementProcess, + Consumer<IEntityMNode> deviceProcess, Function<IMeasurementMNode, Map<String, String>> tagGetter, Runnable flushCallback) throws IOException, MetadataException { @@ -197,7 +207,9 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG { CachedMTreeStore.loadFromSnapshot( snapshotDir, storageGroupFullPath, schemaRegionId, regionStatistics, flushCallback), measurementProcess, - tagGetter); + deviceProcess, + tagGetter, + regionStatistics); } // endregion @@ -837,6 +849,7 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG { entityMNode.setSchemaTemplateId(template.getId()); store.updateMNode(entityMNode); + regionStatistics.activateTemplate(template.getId()); } finally { unPinPath(cur); } @@ -902,6 +915,7 @@ public class MTreeBelowSGCachedImpl implements IMTreeBelowSG { && node.isPreDeactivateTemplate()) { resultTemplateSetInfo.put( node.getPartialPath(), Collections.singletonList(node.getSchemaTemplateId())); + regionStatistics.deactivateTemplate(node.getSchemaTemplateId()); node.deactivateTemplate(); store.updateMNode(node); } diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGMemoryImpl.java b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGMemoryImpl.java index 7d1c397104..465468e24b 100644 --- a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGMemoryImpl.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/MTreeBelowSGMemoryImpl.java @@ -109,6 +109,7 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG { private final IMNode rootNode; private final Function<IMeasurementMNode, Map<String, String>> tagGetter; private final int levelOfSG; + private final MemSchemaRegionStatistics regionStatistics; // region MTree initialization, clear and serialization public MTreeBelowSGMemoryImpl( @@ -116,6 +117,7 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG { Function<IMeasurementMNode, Map<String, String>> tagGetter, MemSchemaRegionStatistics regionStatistics) { store = new MemMTreeStore(storageGroupPath, true, regionStatistics); + this.regionStatistics = regionStatistics; this.storageGroupMNode = store.getRoot().getAsStorageGroupMNode(); this.rootNode = store.generatePrefix(storageGroupPath); levelOfSG = storageGroupPath.getNodeLength() - 1; @@ -125,8 +127,10 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG { private MTreeBelowSGMemoryImpl( PartialPath storageGroupPath, MemMTreeStore store, - Function<IMeasurementMNode, Map<String, String>> tagGetter) { + Function<IMeasurementMNode, Map<String, String>> tagGetter, + MemSchemaRegionStatistics regionStatistics) { this.store = store; + this.regionStatistics = regionStatistics; this.storageGroupMNode = store.getRoot().getAsStorageGroupMNode(); this.rootNode = store.generatePrefix(storageGroupPath); levelOfSG = storageGroupPath.getNodeLength() - 1; @@ -154,12 +158,15 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG { String storageGroupFullPath, MemSchemaRegionStatistics regionStatistics, Consumer<IMeasurementMNode> measurementProcess, + Consumer<IEntityMNode> deviceProcess, Function<IMeasurementMNode, Map<String, String>> tagGetter) throws IOException, IllegalPathException { return new MTreeBelowSGMemoryImpl( new PartialPath(storageGroupFullPath), - MemMTreeStore.loadFromSnapshot(snapshotDir, measurementProcess, regionStatistics), - tagGetter); + MemMTreeStore.loadFromSnapshot( + snapshotDir, measurementProcess, deviceProcess, regionStatistics), + tagGetter, + regionStatistics); } // endregion @@ -719,6 +726,7 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG { } entityMNode.setUseTemplate(true); entityMNode.setSchemaTemplateId(template.getId()); + regionStatistics.activateTemplate(template.getId()); } @Override @@ -780,6 +788,7 @@ public class MTreeBelowSGMemoryImpl implements IMTreeBelowSG { && node.isPreDeactivateTemplate()) { resultTemplateSetInfo.put( node.getPartialPath(), Collections.singletonList(node.getSchemaTemplateId())); + regionStatistics.deactivateTemplate(node.getSchemaTemplateId()); node.deactivateTemplate(); deleteEmptyInternalMNode(node); } diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/snapshot/MemMTreeSnapshotUtil.java b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/snapshot/MemMTreeSnapshotUtil.java index b650dc710c..af48f0d2ce 100644 --- a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/snapshot/MemMTreeSnapshotUtil.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/snapshot/MemMTreeSnapshotUtil.java @@ -22,6 +22,7 @@ package org.apache.iotdb.db.metadata.mtree.snapshot; import org.apache.iotdb.commons.file.SystemFileFactory; import org.apache.iotdb.db.metadata.MetadataConstant; import org.apache.iotdb.db.metadata.mnode.EntityMNode; +import org.apache.iotdb.db.metadata.mnode.IEntityMNode; import org.apache.iotdb.db.metadata.mnode.IMNode; import org.apache.iotdb.db.metadata.mnode.IMeasurementMNode; import org.apache.iotdb.db.metadata.mnode.InternalMNode; @@ -107,12 +108,13 @@ public class MemMTreeSnapshotUtil { public static IMNode loadSnapshot( File snapshotDir, Consumer<IMeasurementMNode> measurementProcess, + Consumer<IEntityMNode> deviceProcess, MemSchemaRegionStatistics regionStatistics) throws IOException { File snapshot = SystemFileFactory.INSTANCE.getFile(snapshotDir, MetadataConstant.MTREE_SNAPSHOT); try (BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(snapshot))) { - return deserializeFrom(inputStream, measurementProcess, regionStatistics); + return deserializeFrom(inputStream, measurementProcess, deviceProcess, regionStatistics); } catch (Throwable e) { // This method is only invoked during recovery. If failed, the memory usage should be cleared // since the loaded schema will not be used. @@ -157,15 +159,17 @@ public class MemMTreeSnapshotUtil { private static IMNode deserializeFrom( InputStream inputStream, Consumer<IMeasurementMNode> measurementProcess, + Consumer<IEntityMNode> deviceProcess, MemSchemaRegionStatistics regionStatistics) throws IOException { byte version = ReadWriteIOUtils.readByte(inputStream); - return inorderDeserialize(inputStream, measurementProcess, regionStatistics); + return inorderDeserialize(inputStream, measurementProcess, deviceProcess, regionStatistics); } private static IMNode inorderDeserialize( InputStream inputStream, Consumer<IMeasurementMNode> measurementProcess, + Consumer<IEntityMNode> deviceProcess, MemSchemaRegionStatistics regionStatistics) throws IOException { MNodeDeserializer deserializer = new MNodeDeserializer(); @@ -177,6 +181,7 @@ public class MemMTreeSnapshotUtil { deserializer, inputStream, measurementProcess, + deviceProcess, regionStatistics); int childrenNum; IMNode root = ancestors.peek(); @@ -192,6 +197,7 @@ public class MemMTreeSnapshotUtil { deserializer, inputStream, measurementProcess, + deviceProcess, regionStatistics); } } @@ -204,6 +210,7 @@ public class MemMTreeSnapshotUtil { MNodeDeserializer deserializer, InputStream inputStream, Consumer<IMeasurementMNode> measurementProcess, + Consumer<IEntityMNode> deviceProcess, MemSchemaRegionStatistics regionStatistics) throws IOException { byte type = ReadWriteIOUtils.readByte(inputStream); @@ -221,10 +228,12 @@ public class MemMTreeSnapshotUtil { case ENTITY_MNODE_TYPE: childrenNum = ReadWriteIOUtils.readInt(inputStream); node = deserializer.deserializeEntityMNode(inputStream); + deviceProcess.accept(node.getAsEntityMNode()); break; case STORAGE_GROUP_ENTITY_MNODE_TYPE: childrenNum = ReadWriteIOUtils.readInt(inputStream); node = deserializer.deserializeStorageGroupEntityMNode(inputStream); + deviceProcess.accept(node.getAsEntityMNode()); break; case MEASUREMENT_MNODE_TYPE: childrenNum = 0; diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/store/MemMTreeStore.java b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/store/MemMTreeStore.java index 49b92f7861..791eb17e57 100644 --- a/server/src/main/java/org/apache/iotdb/db/metadata/mtree/store/MemMTreeStore.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/mtree/store/MemMTreeStore.java @@ -229,10 +229,12 @@ public class MemMTreeStore implements IMTreeStore { public static MemMTreeStore loadFromSnapshot( File snapshotDir, Consumer<IMeasurementMNode> measurementProcess, + Consumer<IEntityMNode> deviceProcess, MemSchemaRegionStatistics regionStatistics) throws IOException { return new MemMTreeStore( - MemMTreeSnapshotUtil.loadSnapshot(snapshotDir, measurementProcess, regionStatistics), + MemMTreeSnapshotUtil.loadSnapshot( + snapshotDir, measurementProcess, deviceProcess, regionStatistics), regionStatistics); } diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/rescon/ISchemaEngineStatistics.java b/server/src/main/java/org/apache/iotdb/db/metadata/rescon/ISchemaEngineStatistics.java index 5109c7a083..88189f68b1 100644 --- a/server/src/main/java/org/apache/iotdb/db/metadata/rescon/ISchemaEngineStatistics.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/rescon/ISchemaEngineStatistics.java @@ -32,6 +32,8 @@ public interface ISchemaEngineStatistics { int getSchemaRegionNumber(); + long getTemplateSeriesNumber(); + MemSchemaEngineStatistics getAsMemSchemaEngineStatistics(); CachedSchemaEngineStatistics getAsCachedSchemaEngineStatistics(); diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/rescon/ISchemaRegionStatistics.java b/server/src/main/java/org/apache/iotdb/db/metadata/rescon/ISchemaRegionStatistics.java index a03d229b70..6dade84995 100644 --- a/server/src/main/java/org/apache/iotdb/db/metadata/rescon/ISchemaRegionStatistics.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/rescon/ISchemaRegionStatistics.java @@ -28,6 +28,10 @@ public interface ISchemaRegionStatistics { long getSeriesNumber(); + int getTemplateActivatedNumber(); + + long getTemplateSeriesNumber(); + MemSchemaRegionStatistics getAsMemSchemaRegionStatistics(); CachedSchemaRegionStatistics getAsCachedSchemaRegionStatistics(); diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/rescon/MemSchemaEngineStatistics.java b/server/src/main/java/org/apache/iotdb/db/metadata/rescon/MemSchemaEngineStatistics.java index 7fad2d55e5..a683e343dc 100644 --- a/server/src/main/java/org/apache/iotdb/db/metadata/rescon/MemSchemaEngineStatistics.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/rescon/MemSchemaEngineStatistics.java @@ -20,10 +20,13 @@ package org.apache.iotdb.db.metadata.rescon; import org.apache.iotdb.db.conf.IoTDBDescriptor; import org.apache.iotdb.db.metadata.schemaregion.SchemaEngine; +import org.apache.iotdb.db.metadata.template.ClusterTemplateManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicLong; /** This class is used to record the global statistics of SchemaEngine in Memory mode */ @@ -39,6 +42,8 @@ public class MemSchemaEngineStatistics implements ISchemaEngineStatistics { private final AtomicLong totalSeriesNumber = new AtomicLong(0); + private final Map<Integer, Integer> templateUsage = new ConcurrentHashMap<>(); + private volatile boolean allowToCreateNewSeries = true; @Override @@ -82,7 +87,7 @@ public class MemSchemaEngineStatistics implements ISchemaEngineStatistics { @Override public long getTotalSeriesNumber() { - return totalSeriesNumber.get(); + return totalSeriesNumber.get() + getTemplateSeriesNumber(); } @Override @@ -90,6 +95,25 @@ public class MemSchemaEngineStatistics implements ISchemaEngineStatistics { return SchemaEngine.getInstance().getSchemaRegionNumber(); } + @Override + public long getTemplateSeriesNumber() { + ClusterTemplateManager clusterTemplateManager = ClusterTemplateManager.getInstance(); + return templateUsage.entrySet().stream() + .mapToLong( + i -> + (long) clusterTemplateManager.getTemplate(i.getKey()).getMeasurementNumber() + * i.getValue()) + .sum(); + } + + public void activateTemplate(int templateId) { + templateUsage.compute(templateId, (k, v) -> (v == null) ? 1 : v + 1); + } + + public void deactivateTemplate(int templateId, int cnt) { + templateUsage.compute(templateId, (k, v) -> (v == null || v <= cnt) ? null : v - cnt); + } + public void addTimeseries(long addedNum) { totalSeriesNumber.addAndGet(addedNum); } diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/rescon/MemSchemaRegionStatistics.java b/server/src/main/java/org/apache/iotdb/db/metadata/rescon/MemSchemaRegionStatistics.java index 96f1895334..c8747d3b07 100644 --- a/server/src/main/java/org/apache/iotdb/db/metadata/rescon/MemSchemaRegionStatistics.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/rescon/MemSchemaRegionStatistics.java @@ -18,6 +18,10 @@ */ package org.apache.iotdb.db.metadata.rescon; +import org.apache.iotdb.db.metadata.template.ClusterTemplateManager; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicLong; /** This class is used to record statistics within the SchemaRegion in Memory mode */ @@ -27,6 +31,7 @@ public class MemSchemaRegionStatistics implements ISchemaRegionStatistics { private final int schemaRegionId; private final AtomicLong memoryUsage = new AtomicLong(0); private final AtomicLong seriesNumber = new AtomicLong(0); + private final Map<Integer, Integer> templateUsage = new ConcurrentHashMap<>(); private long mLogLength = 0; @@ -52,7 +57,7 @@ public class MemSchemaRegionStatistics implements ISchemaRegionStatistics { @Override public long getSeriesNumber() { - return seriesNumber.get(); + return seriesNumber.get() + getTemplateSeriesNumber(); } public void addTimeseries(long addedNum) { @@ -65,6 +70,32 @@ public class MemSchemaRegionStatistics implements ISchemaRegionStatistics { schemaEngineStatistics.deleteTimeseries(deletedNum); } + @Override + public int getTemplateActivatedNumber() { + return templateUsage.size(); + } + + @Override + public long getTemplateSeriesNumber() { + ClusterTemplateManager clusterTemplateManager = ClusterTemplateManager.getInstance(); + return templateUsage.entrySet().stream() + .mapToLong( + i -> + (long) clusterTemplateManager.getTemplate(i.getKey()).getMeasurementNumber() + * i.getValue()) + .sum(); + } + + public void activateTemplate(int templateId) { + templateUsage.compute(templateId, (k, v) -> (v == null) ? 1 : v + 1); + schemaEngineStatistics.activateTemplate(templateId); + } + + public void deactivateTemplate(int templateId) { + templateUsage.compute(templateId, (k, v) -> (v == null || v == 1) ? null : v - 1); + schemaEngineStatistics.deactivateTemplate(templateId, 1); + } + @Override public long getRegionMemoryUsage() { return memoryUsage.get(); @@ -99,5 +130,8 @@ public class MemSchemaRegionStatistics implements ISchemaRegionStatistics { schemaEngineStatistics.deleteTimeseries(seriesNumber.get()); memoryUsage.getAndSet(0); seriesNumber.getAndSet(0); + templateUsage.forEach( + (templateId, cnt) -> schemaEngineStatistics.deactivateTemplate(templateId, cnt)); + templateUsage.clear(); } } diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java index 59383c6f01..fb9d0e8dc5 100644 --- a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java @@ -476,6 +476,11 @@ public class SchemaRegionMemoryImpl implements ISchemaRegion { schemaRegionId); } }, + deviceMNode -> { + if (deviceMNode.getSchemaTemplateIdWithState() >= 0) { + regionStatistics.activateTemplate(deviceMNode.getSchemaTemplateId()); + } + }, tagManager::readTags); logger.info( "MTree snapshot loading of schemaRegion {} costs {}ms.", diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java index dbf2e59185..7968407c14 100644 --- a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java @@ -516,6 +516,11 @@ public class SchemaRegionSchemaFileImpl implements ISchemaRegion { schemaRegionId); } }, + deviceMNode -> { + if (deviceMNode.getSchemaTemplateIdWithState() >= 0) { + regionStatistics.activateTemplate(deviceMNode.getSchemaTemplateId()); + } + }, tagManager::readTags, this::flushCallback); logger.info( diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/template/ClusterTemplateManager.java b/server/src/main/java/org/apache/iotdb/db/metadata/template/ClusterTemplateManager.java index 1350a07a04..1eb2d28477 100644 --- a/server/src/main/java/org/apache/iotdb/db/metadata/template/ClusterTemplateManager.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/template/ClusterTemplateManager.java @@ -26,6 +26,7 @@ import org.apache.iotdb.commons.consensus.ConfigRegionId; import org.apache.iotdb.commons.exception.IllegalPathException; import org.apache.iotdb.commons.exception.IoTDBException; import org.apache.iotdb.commons.path.PartialPath; +import org.apache.iotdb.commons.utils.TestOnly; import org.apache.iotdb.confignode.rpc.thrift.TCreateSchemaTemplateReq; import org.apache.iotdb.confignode.rpc.thrift.TGetAllTemplatesResp; import org.apache.iotdb.confignode.rpc.thrift.TGetPathsSetTemplatesResp; @@ -365,4 +366,10 @@ public class ClusterTemplateManager implements ITemplateManager { readWriteLock.writeLock().unlock(); } } + + @TestOnly + public void putTemplate(Template template) { + templateIdMap.put(template.getId(), template); + templateNameMap.put(template.getName(), template.getId()); + } } diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/template/Template.java b/server/src/main/java/org/apache/iotdb/db/metadata/template/Template.java index a2a2130cce..1b2a831f84 100644 --- a/server/src/main/java/org/apache/iotdb/db/metadata/template/Template.java +++ b/server/src/main/java/org/apache/iotdb/db/metadata/template/Template.java @@ -170,6 +170,10 @@ public class Template implements Serializable { return isDirectAligned; } + public int getMeasurementNumber() { + return schemaMap.size(); + } + // region construct template tree /** Construct aligned measurements, checks prefix equality, path duplication and conflict */ private void constructTemplateTree(String[] alignedPaths, IMeasurementSchema[] schemas) diff --git a/server/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaStatisticsTest.java b/server/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaStatisticsTest.java index 6e1383275f..c494b55b47 100644 --- a/server/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaStatisticsTest.java +++ b/server/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaStatisticsTest.java @@ -30,11 +30,14 @@ import org.apache.iotdb.db.metadata.mnode.StorageGroupMNode; import org.apache.iotdb.db.metadata.mnode.estimator.BasicMNodSizeEstimator; import org.apache.iotdb.db.metadata.mnode.estimator.IMNodeSizeEstimator; import org.apache.iotdb.db.metadata.mtree.store.disk.memcontrol.CachedMNodeSizeEstimator; +import org.apache.iotdb.db.metadata.plan.schemaregion.impl.write.SchemaRegionWritePlanFactory; import org.apache.iotdb.db.metadata.rescon.CachedSchemaEngineStatistics; import org.apache.iotdb.db.metadata.rescon.CachedSchemaRegionStatistics; import org.apache.iotdb.db.metadata.rescon.ISchemaEngineStatistics; import org.apache.iotdb.db.metadata.schemaregion.ISchemaRegion; import org.apache.iotdb.db.metadata.schemaregion.SchemaEngine; +import org.apache.iotdb.db.metadata.template.ClusterTemplateManager; +import org.apache.iotdb.db.metadata.template.Template; import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType; import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding; @@ -44,6 +47,10 @@ import org.junit.Assert; import org.junit.Test; import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class SchemaStatisticsTest extends AbstractSchemaRegionTest { @@ -248,4 +255,103 @@ public class SchemaStatisticsTest extends AbstractSchemaRegionTest { engineStatistics.getUnpinnedMemorySize()); } } + + @Test + public void testTemplateStatistics() throws Exception { + ISchemaEngineStatistics engineStatistics = + SchemaEngine.getInstance().getSchemaEngineStatistics(); + ISchemaRegion schemaRegion1 = getSchemaRegion("root.sg1", 0); + ISchemaRegion schemaRegion2 = getSchemaRegion("root.sg2", 1); + schemaRegion1.createTimeseries( + SchemaRegionWritePlanFactory.getCreateTimeSeriesPlan( + new PartialPath("root.sg.wf01.wt01.status"), + TSDataType.BOOLEAN, + TSEncoding.PLAIN, + CompressionType.SNAPPY, + null, + null, + null, + null), + -1); + Template template1 = + new Template( + "t1", + Arrays.asList( + Collections.singletonList("s1"), + Collections.singletonList("s2"), + Collections.singletonList("s3")), + Arrays.asList( + Collections.singletonList(TSDataType.DOUBLE), + Collections.singletonList(TSDataType.INT32), + Collections.singletonList(TSDataType.BOOLEAN)), + Arrays.asList( + Collections.singletonList(TSEncoding.RLE), + Collections.singletonList(TSEncoding.RLE), + Collections.singletonList(TSEncoding.RLE)), + Arrays.asList( + Collections.singletonList(CompressionType.SNAPPY), + Collections.singletonList(CompressionType.SNAPPY), + Collections.singletonList(CompressionType.SNAPPY))); + template1.setId(1); + Template template2 = + new Template( + "t2", + Arrays.asList( + Collections.singletonList("temperature"), Collections.singletonList("status")), + Arrays.asList( + Collections.singletonList(TSDataType.DOUBLE), + Collections.singletonList(TSDataType.INT32)), + Arrays.asList( + Collections.singletonList(TSEncoding.RLE), + Collections.singletonList(TSEncoding.RLE)), + Arrays.asList( + Collections.singletonList(CompressionType.SNAPPY), + Collections.singletonList(CompressionType.SNAPPY))); + template2.setId(2); + ClusterTemplateManager.getInstance().putTemplate(template1); + ClusterTemplateManager.getInstance().putTemplate(template2); + for (int i = 0; i < 4; i++) { + schemaRegion1.activateSchemaTemplate( + SchemaRegionWritePlanFactory.getActivateTemplateInClusterPlan( + new PartialPath("root.sg1.d" + i), 2, 1), + template1); + schemaRegion2.activateSchemaTemplate( + SchemaRegionWritePlanFactory.getActivateTemplateInClusterPlan( + new PartialPath("root.sg2.d" + i), 2, 1), + template1); + } + schemaRegion2.activateSchemaTemplate( + SchemaRegionWritePlanFactory.getActivateTemplateInClusterPlan( + new PartialPath("root.sg2.wf01.wt02"), 3, 2), + template2); + + // check template statistic + Assert.assertEquals(26, engineStatistics.getTemplateSeriesNumber()); + Assert.assertEquals(27, engineStatistics.getTotalSeriesNumber()); + Assert.assertEquals(13, schemaRegion1.getSchemaRegionStatistics().getSeriesNumber()); + Assert.assertEquals(12, schemaRegion1.getSchemaRegionStatistics().getTemplateSeriesNumber()); + Assert.assertEquals(14, schemaRegion2.getSchemaRegionStatistics().getSeriesNumber()); + Assert.assertEquals(14, schemaRegion2.getSchemaRegionStatistics().getTemplateSeriesNumber()); + + // deactivate template + // construct schema blacklist with template on root.sg.wf01.wt01 and root.sg.wf02 + Map<PartialPath, List<Integer>> allDeviceTemplateMap = new HashMap<>(); + allDeviceTemplateMap.put(new PartialPath("root.**.d0"), Arrays.asList(1, 2)); + schemaRegion1.constructSchemaBlackListWithTemplate( + SchemaRegionWritePlanFactory.getPreDeactivateTemplatePlan(allDeviceTemplateMap)); + schemaRegion2.constructSchemaBlackListWithTemplate( + SchemaRegionWritePlanFactory.getPreDeactivateTemplatePlan(allDeviceTemplateMap)); + schemaRegion1.deactivateTemplateInBlackList( + SchemaRegionWritePlanFactory.getDeactivateTemplatePlan(allDeviceTemplateMap)); + schemaRegion2.deactivateTemplateInBlackList( + SchemaRegionWritePlanFactory.getDeactivateTemplatePlan(allDeviceTemplateMap)); + + // check template statistic + Assert.assertEquals(20, engineStatistics.getTemplateSeriesNumber()); + Assert.assertEquals(21, engineStatistics.getTotalSeriesNumber()); + Assert.assertEquals(10, schemaRegion1.getSchemaRegionStatistics().getSeriesNumber()); + Assert.assertEquals(9, schemaRegion1.getSchemaRegionStatistics().getTemplateSeriesNumber()); + Assert.assertEquals(11, schemaRegion2.getSchemaRegionStatistics().getSeriesNumber()); + Assert.assertEquals(11, schemaRegion2.getSchemaRegionStatistics().getTemplateSeriesNumber()); + } }
