From 71f4d5f72d75f8990fb6795a4f5aa71cf287fa3c Mon Sep 17 00:00:00 2001 From: Artem Gavrilov Date: Thu, 29 Aug 2024 18:31:27 +0200 Subject: [PATCH] PMM-13154 Fixes --- qan-api2/services/analytics/base.go | 28 ++-- qan-api2/services/analytics/metrics_names.go | 130 +++++++++--------- .../GetMetrics_group_by_queryid.json | 24 ++++ .../GetMetrics_sparklines_90_points.json | 24 ++++ qan-api2/test_data/GetMetrics_total.json | 12 ++ 5 files changed, 145 insertions(+), 73 deletions(-) diff --git a/qan-api2/services/analytics/base.go b/qan-api2/services/analytics/base.go index 5d91cf5014..184f8626d8 100644 --- a/qan-api2/services/analytics/base.go +++ b/qan-api2/services/analytics/base.go @@ -77,6 +77,10 @@ var sumColumnNames = map[string]struct{}{ "temp_blks_written": {}, "blk_read_time": {}, "blk_write_time": {}, + "shared_blk_read_time": {}, + "shared_blk_write_time": {}, + "local_blk_read_time": {}, + "local_blk_write_time": {}, "cpu_user_time": {}, "cpu_sys_time": {}, "plans_calls": {}, @@ -191,16 +195,20 @@ func isDimension(name string) bool { // isTimeMetric checks if a metric in the time metrics group. func isTimeMetric(name string) bool { timeColumnNames := map[string]struct{}{ - "query_time": {}, - "lock_time": {}, - "innodb_io_r_wait": {}, - "innodb_rec_lock_wait": {}, - "innodb_queue_wait": {}, - "blk_read_time": {}, - "blk_write_time": {}, - "cpu_user_time": {}, - "cpu_sys_time": {}, - "plan_time": {}, + "query_time": {}, + "lock_time": {}, + "innodb_io_r_wait": {}, + "innodb_rec_lock_wait": {}, + "innodb_queue_wait": {}, + "blk_read_time": {}, + "blk_write_time": {}, + "shared_blk_read_time": {}, + "shared_blk_write_time": {}, + "local_blk_read_time": {}, + "local_blk_write_time": {}, + "cpu_user_time": {}, + "cpu_sys_time": {}, + "plan_time": {}, } _, ok := timeColumnNames[name] diff --git a/qan-api2/services/analytics/metrics_names.go b/qan-api2/services/analytics/metrics_names.go index 4f913d80dd..e5090b64b5 100644 --- a/qan-api2/services/analytics/metrics_names.go +++ b/qan-api2/services/analytics/metrics_names.go @@ -23,69 +23,73 @@ import ( // metricsNames is a map of metrics names and keys. var metricsNames = map[string]string{ - "load": "Load", - "count": "Count", - "latency": "Latency", - "query_time": "Query Time", - "lock_time": "Lock Time", - "rows_sent": "Rows Sent", - "rows_examined": "Rows Examined", - "rows_affected": "Rows Affected", - "rows_read": "Rows Read", - "merge_passes": "Merge Passes", - "innodb_io_r_ops": "Innodb IO R Ops", - "innodb_io_r_bytes": "Innodb IO R Bytes", - "innodb_io_r_wait": "Innodb IO R Wait", - "innodb_rec_lock_wait": "Innodb Rec Lock Wait", - "innodb_queue_wait": "Innodb Queue Wait", - "innodb_pages_distinct": "Innodb Pages Distinct", - "query_length": "Query Length", - "bytes_sent": "Bytes Sent", - "tmp_tables": "Tmp Tables", - "tmp_disk_tables": "Tmp Disk Tables", - "tmp_table_sizes": "Tmp Table Sizes", - "qc_hit": "Query Cache Hit", - "full_scan": "Full Scan", - "full_join": "Full Join", - "tmp_table": "Tmp Table", - "tmp_table_on_disk": "Tmp Table on Disk", - "filesort": "Filesort", - "filesort_on_disk": "Filesort on Disk", - "select_full_range_join": "Select Full Range Join", - "select_range": "Select Range", - "select_range_check": "Select Range Check", - "sort_range": "Sort Range", - "sort_rows": "Sort Rows", - "sort_scan": "Sort Scan", - "no_index_used": "No Index Used", - "no_good_index_used": "No Good Index Used", - "docs_returned": "Docs Returned", - "response_length": "Response Length", - "docs_scanned": "Docs Scanned", - "m_shared_blks_hit": "Shared blocks cache hits", - "m_shared_blks_read": "Shared blocks read", - "m_shared_blks_dirtied": "Shared blocks dirtied", - "m_shared_blks_written": "Shared blocks written", - "m_local_blks_hit": "Local blocks cache hits", - "m_local_blks_read": "Local blocks read", - "m_local_blks_dirtied": "Local blocks dirtied", - "m_local_blks_written": "Local blocks written", - "m_temp_blks_read": "Temp blocks read", - "m_temp_blks_written": "Temp blocks written", - "m_blk_read_time": "Time the statement spent reading blocks", - "m_blk_write_time": "Time the statement spent writing blocks", - "m_cpu_user_time": "Total time user spent in query", - "m_cpu_sys_time": "Total time system spent in query", - "m_plans_calls": "Total number of planned calls", - "m_wal_records": "Total number of WAL (Write-ahead logging) records", - "m_wal_fpi": "Total number of FPI (full page images) in WAL (Write-ahead logging) records", - "m_wal_bytes": "Total bytes of WAL (Write-ahead logging) records", - "m_plan_time": "Total plan time spent in query", - "cmd_type": "Type of SQL command used in the query", - "top_queryid": "Top parent query ID", - "top_query": "Top query plain text", - "application_name": "Name provided by pg_stat_monitor", - "planid": "Plan ID for query", + "load": "Load", + "count": "Count", + "latency": "Latency", + "query_time": "Query Time", + "lock_time": "Lock Time", + "rows_sent": "Rows Sent", + "rows_examined": "Rows Examined", + "rows_affected": "Rows Affected", + "rows_read": "Rows Read", + "merge_passes": "Merge Passes", + "innodb_io_r_ops": "Innodb IO R Ops", + "innodb_io_r_bytes": "Innodb IO R Bytes", + "innodb_io_r_wait": "Innodb IO R Wait", + "innodb_rec_lock_wait": "Innodb Rec Lock Wait", + "innodb_queue_wait": "Innodb Queue Wait", + "innodb_pages_distinct": "Innodb Pages Distinct", + "query_length": "Query Length", + "bytes_sent": "Bytes Sent", + "tmp_tables": "Tmp Tables", + "tmp_disk_tables": "Tmp Disk Tables", + "tmp_table_sizes": "Tmp Table Sizes", + "qc_hit": "Query Cache Hit", + "full_scan": "Full Scan", + "full_join": "Full Join", + "tmp_table": "Tmp Table", + "tmp_table_on_disk": "Tmp Table on Disk", + "filesort": "Filesort", + "filesort_on_disk": "Filesort on Disk", + "select_full_range_join": "Select Full Range Join", + "select_range": "Select Range", + "select_range_check": "Select Range Check", + "sort_range": "Sort Range", + "sort_rows": "Sort Rows", + "sort_scan": "Sort Scan", + "no_index_used": "No Index Used", + "no_good_index_used": "No Good Index Used", + "docs_returned": "Docs Returned", + "response_length": "Response Length", + "docs_scanned": "Docs Scanned", + "m_shared_blks_hit": "Shared blocks cache hits", + "m_shared_blks_read": "Shared blocks read", + "m_shared_blks_dirtied": "Shared blocks dirtied", + "m_shared_blks_written": "Shared blocks written", + "m_local_blks_hit": "Local blocks cache hits", + "m_local_blks_read": "Local blocks read", + "m_local_blks_dirtied": "Local blocks dirtied", + "m_local_blks_written": "Local blocks written", + "m_temp_blks_read": "Temp blocks read", + "m_temp_blks_written": "Temp blocks written", + "m_blk_read_time": "Time the statement spent reading blocks [deprecated]", + "m_blk_write_time": "Time the statement spent writing blocks [deprecated]", + "m_shared_blk_read_time": "Time the statement spent reading shared blocks", + "m_shared_blk_write_time": "Time the statement spent writing shared blocks", + "m_local_blk_read_time": "Time the statement spent reading local_blocks", + "m_local_blk_write_time": "Time the statement spent writing local_blocks", + "m_cpu_user_time": "Total time user spent in query", + "m_cpu_sys_time": "Total time system spent in query", + "m_plans_calls": "Total number of planned calls", + "m_wal_records": "Total number of WAL (Write-ahead logging) records", + "m_wal_fpi": "Total number of FPI (full page images) in WAL (Write-ahead logging) records", + "m_wal_bytes": "Total bytes of WAL (Write-ahead logging) records", + "m_plan_time": "Total plan time spent in query", + "cmd_type": "Type of SQL command used in the query", + "top_queryid": "Top parent query ID", + "top_query": "Top query plain text", + "application_name": "Name provided by pg_stat_monitor", + "planid": "Plan ID for query", } // GetMetricsNames implements rpc to get list of available metrics. diff --git a/qan-api2/test_data/GetMetrics_group_by_queryid.json b/qan-api2/test_data/GetMetrics_group_by_queryid.json index a1aaab24ef..3d7856ba32 100644 --- a/qan-api2/test_data/GetMetrics_group_by_queryid.json +++ b/qan-api2/test_data/GetMetrics_group_by_queryid.json @@ -5,6 +5,18 @@ }, "blk_write_time": { + }, + "shared_blk_read_time": { + + }, + "shared_blk_write_time": { + + }, + "local_blk_read_time": { + + }, + "local_blk_write_time": { + }, "bytes_sent": { "rate": 2.1030555, @@ -3446,6 +3458,18 @@ }, "blk_write_time": { + }, + "shared_blk_read_time": { + + }, + "shared_blk_write_time": { + + }, + "local_blk_read_time": { + + }, + "local_blk_write_time": { + }, "bytes_sent": { "rate": 593.79974, diff --git a/qan-api2/test_data/GetMetrics_sparklines_90_points.json b/qan-api2/test_data/GetMetrics_sparklines_90_points.json index 9132a37970..c64546e030 100644 --- a/qan-api2/test_data/GetMetrics_sparklines_90_points.json +++ b/qan-api2/test_data/GetMetrics_sparklines_90_points.json @@ -5,6 +5,18 @@ }, "blk_write_time": { + }, + "shared_blk_read_time": { + + }, + "shared_blk_write_time": { + + }, + "local_blk_read_time": { + + }, + "local_blk_write_time": { + }, "bytes_sent": { "rate": 2.7203703, @@ -1280,6 +1292,18 @@ }, "blk_write_time": { + }, + "shared_blk_read_time": { + + }, + "shared_blk_write_time": { + + }, + "local_blk_read_time": { + + }, + "local_blk_write_time": { + }, "bytes_sent": { "rate": 604.05927, diff --git a/qan-api2/test_data/GetMetrics_total.json b/qan-api2/test_data/GetMetrics_total.json index 8dff3d1eb4..79459e11f6 100644 --- a/qan-api2/test_data/GetMetrics_total.json +++ b/qan-api2/test_data/GetMetrics_total.json @@ -6634,6 +6634,18 @@ }, "blk_write_time": { + }, + "shared_blk_read_time": { + + }, + "shared_blk_write_time": { + + }, + "local_blk_read_time": { + + }, + "local_blk_write_time": { + }, "bytes_sent": { "rate": 593.79974,