From db8853a87f4abc2c71309ca32dc6c2113e2a4fa7 Mon Sep 17 00:00:00 2001 From: lidezhu <lidezhu@pingcap.com> Date: Thu, 8 Jun 2023 18:08:20 +0800 Subject: [PATCH] add grafana --- dbms/src/Common/CurrentMetrics.cpp | 2 +- dbms/src/Storages/Page/V3/PageDirectory.cpp | 4 +- metrics/grafana/tiflash_summary.json | 230 +++++++++++++++++++- 3 files changed, 224 insertions(+), 12 deletions(-) diff --git a/dbms/src/Common/CurrentMetrics.cpp b/dbms/src/Common/CurrentMetrics.cpp index 66511160c15..9d939a43907 100644 --- a/dbms/src/Common/CurrentMetrics.cpp +++ b/dbms/src/Common/CurrentMetrics.cpp @@ -28,7 +28,7 @@ M(PSMVCCSnapshotsList) \ M(PSMVCCNumDelta) \ M(PSMVCCNumBase) \ - M(PSWriterQueueSize) \ + M(PSPendingWriterSize) \ M(RWLockWaitingReaders) \ M(RWLockWaitingWriters) \ M(RWLockActiveReaders) \ diff --git a/dbms/src/Storages/Page/V3/PageDirectory.cpp b/dbms/src/Storages/Page/V3/PageDirectory.cpp index 42ee99cef11..b84ae0fe49f 100644 --- a/dbms/src/Storages/Page/V3/PageDirectory.cpp +++ b/dbms/src/Storages/Page/V3/PageDirectory.cpp @@ -50,7 +50,7 @@ namespace CurrentMetrics { extern const Metric PSMVCCSnapshotsList; -extern const Metric PSWriterQueueSize; +extern const Metric PSPendingWriterSize; } // namespace CurrentMetrics namespace DB @@ -1481,6 +1481,7 @@ std::unordered_set<String> PageDirectory<Trait>::apply(PageEntriesEdit && edit, // Note that, as read threads use current `sequence` as read_seq, we cannot increase `sequence` // before applying edit to `mvcc_table_directory`. GET_METRIC(tiflash_storage_page_command_count, type_write).Increment(); + CurrentMetrics::Increment pending_writer_size{CurrentMetrics::PSPendingWriterSize}; Writer w; w.edit = &edit; @@ -1492,7 +1493,6 @@ std::unordered_set<String> PageDirectory<Trait>::apply(PageEntriesEdit && edit, writers.push_back(&w); SYNC_FOR("after_PageDirectory::enter_write_group"); - CurrentMetrics::set(CurrentMetrics::PSWriterQueueSize, writers.size()); w.cv.wait(apply_lock, [&] { return w.done || &w == writers.front(); }); GET_METRIC(tiflash_storage_page_write_duration_seconds, type_wait_in_group).Observe(watch.elapsedSeconds()); watch.restart(); diff --git a/metrics/grafana/tiflash_summary.json b/metrics/grafana/tiflash_summary.json index d7afdb8fb52..739049ec79e 100644 --- a/metrics/grafana/tiflash_summary.json +++ b/metrics/grafana/tiflash_summary.json @@ -589,7 +589,7 @@ "shared": true, "sort": 2, "value_type": "cumulative" - }, + }, "type": "graph", "xaxis": { "buckets": null, @@ -597,7 +597,7 @@ "name": null, "show": true, "values": [] - }, + }, "yaxes": [ { "format": "short", @@ -620,8 +620,8 @@ "align": false, "alignLevel": null } - }, - { + }, + { "aliasColors": {}, "bars": false, "dashLength": 10, @@ -633,7 +633,7 @@ "fieldConfig": { "defaults": {}, "overrides": [] - }, + }, "fill": 0, "fillGradient": 0, "grid": {}, @@ -642,7 +642,7 @@ "w": 12, "x": 0, "y": 17 - }, + }, "hiddenSeries": false, "id": 51, "legend": { @@ -658,14 +658,14 @@ "sortDesc": true, "total": false, "values": true - }, + }, "lines": true, "linewidth": 1, "links": [], "nullPointMode": "null", "options": { "alertThreshold": true - }, + }, "percentage": false, "pluginVersion": "7.5.11", "pointradius": 5, @@ -8999,6 +8999,112 @@ "alignLevel": null } }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_TEST-CLUSTER}", + "description": "", + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "fill": 0, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 137 + }, + "hiddenSeries": false, + "id": 232, + "legend": { + "alignAsTable": true, + "avg": false, + "current": true, + "max": true, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null as zero", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.11", + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "yaxis": 2 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "exemplar": true, + "expr": "sum(increase(tiflash_storage_page_command_count{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\", instance=~\"$instance\"}[1m])) by (instance, type)", + "format": "time_series", + "hide": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "{{type}}-{{instance}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "PS Command OPS By Instance", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "ops", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "opm", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, { "aliasColors": {}, "bars": false, @@ -9562,6 +9668,112 @@ "align": false, "alignLevel": null } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "test", + "description": "The num of pending writers in PageStorage", + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "fill": 0, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 162 + }, + "hiddenSeries": false, + "id": 231, + "legend": { + "alignAsTable": true, + "avg": false, + "current": true, + "hideEmpty": false, + "hideZero": false, + "max": true, + "min": false, + "rightSide": true, + "show": true, + "sideWidth": 250, + "sort": "max", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.11", + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "exemplar": true, + "expr": "sum(tiflash_system_current_metric_PSPendingWriterSize{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\", instance=~\"$instance\"}) by (instance)", + "format": "time_series", + "hide": false, + "interval": "", + "intervalFactor": 1, + "legendFormat": "size-{{instance}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "PageStorage Pending Writers Num", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "none", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } } ], "title": "PageStorage", @@ -14859,4 +15071,4 @@ "title": "Test-Cluster-TiFlash-Summary", "uid": "SVbh2xUWk", "version": 1 -} +} \ No newline at end of file