Skip to content

Commit

Permalink
PMM-13154 Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
artemgavrilov committed Aug 29, 2024
1 parent 8ad8c17 commit 71f4d5f
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 73 deletions.
28 changes: 18 additions & 10 deletions qan-api2/services/analytics/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": {},
Expand Down Expand Up @@ -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]
Expand Down
130 changes: 67 additions & 63 deletions qan-api2/services/analytics/metrics_names.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
24 changes: 24 additions & 0 deletions qan-api2/test_data/GetMetrics_group_by_queryid.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
24 changes: 24 additions & 0 deletions qan-api2/test_data/GetMetrics_sparklines_90_points.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions qan-api2/test_data/GetMetrics_total.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 71f4d5f

Please sign in to comment.