From d615014762e49cfd3d0368a4d264d339e10267ea Mon Sep 17 00:00:00 2001 From: "dementii.priadko" <45518657+DEMNERD@users.noreply.github.com> Date: Mon, 22 Sep 2025 18:03:36 +0300 Subject: [PATCH 01/22] Added pg_index_pilot_config metric --- config/pgwatch-prometheus/metrics.yml | 39 ++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/config/pgwatch-prometheus/metrics.yml b/config/pgwatch-prometheus/metrics.yml index 46b062e..a122750 100644 --- a/config/pgwatch-prometheus/metrics.yml +++ b/config/pgwatch-prometheus/metrics.yml @@ -1962,6 +1962,42 @@ metrics: - is_valid - estimated_tuples - best_ratio + + pg_index_pilot_config: + sqls: + 12: | + select + coalesce(datname, '*') as tag_datname, + coalesce(schemaname, '*') as tag_schemaname, + coalesce(relname, '*') as tag_relname, + coalesce(indexrelname, '*') as tag_indexrelname, + key as tag_config_key, + case + when key = 'index_size_threshold' then + case + when value ~ '^[0-9]+MB$' then (regexp_replace(value, 'MB$', '')::numeric * 1024 * 1024)::bigint + when value ~ '^[0-9]+kB$' then (regexp_replace(value, 'kB$', '')::numeric * 1024)::bigint + when value ~ '^[0-9]+GB$' then (regexp_replace(value, 'GB$', '')::numeric * 1024 * 1024 * 1024)::bigint + else 0 + end + when key = 'minimum_reliable_index_size' then + case + when value ~ '^[0-9]+kB$' then (regexp_replace(value, 'kB$', '')::numeric * 1024)::bigint + when value ~ '^[0-9]+MB$' then (regexp_replace(value, 'MB$', '')::numeric * 1024 * 1024)::bigint + else 0 + end + when key = 'index_rebuild_scale_factor' then value::numeric + when key = 'reindex_history_retention_period' then + case when value ~ 'years?' then regexp_replace(value, ' years?', '')::int else 0 end + when key = 'skip' then case when value::boolean then 1 else 0 end + else 0 + end as config_value_normalized, + value as tag_config_value_raw + from index_pilot.config_settings + order by id; + gauges: + - config_value_normalized + presets: full: @@ -2003,4 +2039,5 @@ presets: pg_vacuum_progress: 30 pg_index_pilot: metrics: - pg_index_pilot: 30 \ No newline at end of file + pg_index_pilot: 30 + pg_index_pilot_config: 7200 \ No newline at end of file From 1f0b846b6035945a943dbba880dfa807488eade2 Mon Sep 17 00:00:00 2001 From: "dementii.priadko" <45518657+DEMNERD@users.noreply.github.com> Date: Mon, 22 Sep 2025 18:45:16 +0300 Subject: [PATCH 02/22] Fixed the metric --- config/pgwatch-prometheus/metrics.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/pgwatch-prometheus/metrics.yml b/config/pgwatch-prometheus/metrics.yml index a122750..f34df26 100644 --- a/config/pgwatch-prometheus/metrics.yml +++ b/config/pgwatch-prometheus/metrics.yml @@ -1993,7 +1993,7 @@ metrics: else 0 end as config_value_normalized, value as tag_config_value_raw - from index_pilot.config_settings + from index_pilot.config order by id; gauges: - config_value_normalized From e80cf4f58b5c0ac6140e289bdd76828bcededcdf Mon Sep 17 00:00:00 2001 From: "dementii.priadko" <45518657+DEMNERD@users.noreply.github.com> Date: Tue, 23 Sep 2025 00:05:04 +0300 Subject: [PATCH 03/22] Updated footers --- .../Dashboard_11_Single_table_analysis.json | 2 +- ...Dashboard_1_Node_performance_overview.json | 2 +- ...Dashboard_2_Aggregated_query_analysis.json | 2 +- .../Dashboard_3_Single_query_analysis.json | 2 +- .../Dashboard_4_Wait_Sampling_Dashboard.json | 2 +- .../dashboards/Dashboard_5_Backup_stats.json | 2 +- .../dashboards/Dashboard_8_Index health.json | 2 +- .../dashboards/Dashboard_9_Table_Stats.json | 3279 +++++++++-------- 8 files changed, 1655 insertions(+), 1638 deletions(-) diff --git a/config/grafana/dashboards/Dashboard_11_Single_table_analysis.json b/config/grafana/dashboards/Dashboard_11_Single_table_analysis.json index d61409f..273b5e1 100644 --- a/config/grafana/dashboards/Dashboard_11_Single_table_analysis.json +++ b/config/grafana/dashboards/Dashboard_11_Single_table_analysis.json @@ -1105,7 +1105,7 @@ "showLineNumbers": false, "showMiniMap": false }, - "content": "

\n Brought to you by Postgres AI\n \"Postgres.AI\"\n

\n", + "content": "

\n Brought to you by PostgresAI\n \"Postgres.AI\"\n

\n", "mode": "html" }, "pluginVersion": "12.0.2", diff --git a/config/grafana/dashboards/Dashboard_1_Node_performance_overview.json b/config/grafana/dashboards/Dashboard_1_Node_performance_overview.json index d97d0e8..c139904 100644 --- a/config/grafana/dashboards/Dashboard_1_Node_performance_overview.json +++ b/config/grafana/dashboards/Dashboard_1_Node_performance_overview.json @@ -4119,7 +4119,7 @@ "showLineNumbers": false, "showMiniMap": false }, - "content": "

\n Brought to you by Postgres AI\n \"Postgres.AI\"\n

\n", + "content": "

\n Brought to you by PostgresAI\n \"Postgres.AI\"\n

\n", "mode": "html" }, "pluginVersion": "12.0.2", diff --git a/config/grafana/dashboards/Dashboard_2_Aggregated_query_analysis.json b/config/grafana/dashboards/Dashboard_2_Aggregated_query_analysis.json index 0d54944..ab91bf3 100644 --- a/config/grafana/dashboards/Dashboard_2_Aggregated_query_analysis.json +++ b/config/grafana/dashboards/Dashboard_2_Aggregated_query_analysis.json @@ -3196,7 +3196,7 @@ "showLineNumbers": false, "showMiniMap": false }, - "content": "

\n Brought to you by Postgres AI\n \"Postgres.AI\"\n

\n", + "content": "

\n Brought to you by PostgresAI\n \"Postgres.AI\"\n

\n", "mode": "html" }, "pluginVersion": "12.0.2", diff --git a/config/grafana/dashboards/Dashboard_3_Single_query_analysis.json b/config/grafana/dashboards/Dashboard_3_Single_query_analysis.json index 1417095..36e8742 100644 --- a/config/grafana/dashboards/Dashboard_3_Single_query_analysis.json +++ b/config/grafana/dashboards/Dashboard_3_Single_query_analysis.json @@ -2131,7 +2131,7 @@ "showLineNumbers": false, "showMiniMap": false }, - "content": "

\n Brought to you by Postgres AI\n \"Postgres.AI\"\n

\n", + "content": "

\n Brought to you by PostgresAI\n \"Postgres.AI\"\n

\n", "mode": "html" }, "pluginVersion": "12.0.2", diff --git a/config/grafana/dashboards/Dashboard_4_Wait_Sampling_Dashboard.json b/config/grafana/dashboards/Dashboard_4_Wait_Sampling_Dashboard.json index 30767a9..93d4490 100644 --- a/config/grafana/dashboards/Dashboard_4_Wait_Sampling_Dashboard.json +++ b/config/grafana/dashboards/Dashboard_4_Wait_Sampling_Dashboard.json @@ -695,7 +695,7 @@ "showLineNumbers": false, "showMiniMap": false }, - "content": "

\n Brought to you by Postgres AI\n \"Postgres.AI\"\n

\n", + "content": "

\n Brought to you by PostgresAI\n \"Postgres.AI\"\n

\n", "mode": "html" }, "pluginVersion": "12.0.2", diff --git a/config/grafana/dashboards/Dashboard_5_Backup_stats.json b/config/grafana/dashboards/Dashboard_5_Backup_stats.json index e0558b5..0102c3d 100644 --- a/config/grafana/dashboards/Dashboard_5_Backup_stats.json +++ b/config/grafana/dashboards/Dashboard_5_Backup_stats.json @@ -390,7 +390,7 @@ "showLineNumbers": false, "showMiniMap": false }, - "content": "

\n Brought to you by Postgres AI\n \"Postgres.AI\"\n

\n", + "content": "

\n Brought to you by PostgresAI\n \"Postgres.AI\"\n

\n", "mode": "html" }, "pluginVersion": "12.0.2", diff --git a/config/grafana/dashboards/Dashboard_8_Index health.json b/config/grafana/dashboards/Dashboard_8_Index health.json index eca3c9b..7de11a3 100644 --- a/config/grafana/dashboards/Dashboard_8_Index health.json +++ b/config/grafana/dashboards/Dashboard_8_Index health.json @@ -618,7 +618,7 @@ "showLineNumbers": false, "showMiniMap": false }, - "content": "

\n Brought to you by Postgres AI\n \"Postgres.AI\"\n

\n", + "content": "

\n Brought to you by PostgresAI\n \"Postgres.AI\"\n

\n", "mode": "html" }, "pluginVersion": "12.0.2", diff --git a/config/grafana/dashboards/Dashboard_9_Table_Stats.json b/config/grafana/dashboards/Dashboard_9_Table_Stats.json index d194fd9..81e5a92 100644 --- a/config/grafana/dashboards/Dashboard_9_Table_Stats.json +++ b/config/grafana/dashboards/Dashboard_9_Table_Stats.json @@ -1,1789 +1,1806 @@ { - "annotations": { - "list": [ - { - "builtIn": 1, - "datasource": { - "type": "grafana", - "uid": "-- Grafana --" - }, - "enable": true, - "hide": true, - "iconColor": "rgba(0, 211, 255, 1)", - "name": "Annotations & Alerts", - "type": "dashboard" - } - ] - }, - "editable": true, - "fiscalYearStartMonth": 0, - "graphTooltip": 1, - "id": 15, - "links": [], - "panels": [ + "annotations": { + "list": [ { + "builtIn": 1, "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" + "type": "grafana", + "uid": "-- Grafana --" }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 1, + "id": 9, + "links": [], + "panels": [ + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 22, + "panels": [], + "title": "Row title", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 1, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "red", - "value": 80 - } - ] + "showPoints": "auto", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "normal" }, - "unit": "bytes" + "thresholdsStyle": { + "mode": "off" + } }, - "overrides": [] - }, - "gridPos": { - "h": 13, - "w": 12, - "x": 0, - "y": 0 - }, - "id": 1, - "options": { - "legend": { - "calcs": [ - "last" - ], - "displayMode": "table", - "placement": "bottom", - "showLegend": true, - "sortBy": "Last", - "sortDesc": true + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] }, - "tooltip": { - "hideZeros": false, - "mode": "single", - "sort": "none" - } + "unit": "bytes" }, - "pluginVersion": "12.0.2", - "targets": [ - { - "disableTextWrap": false, - "editorMode": "code", - "expr": "topk($top_n, pgwatch_pg_class_total_relation_size_bytes{relkind=\"114\", schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"})", - "fullMetaSearch": false, - "includeNullMetadata": true, - "legendFormat": "{{schemaname}}.{{relname}}", - "range": true, - "refId": "A", - "useBackend": false - } - ], - "title": "Top $top_n tables by size", - "type": "timeseries" + "overrides": [] }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" + "gridPos": { + "h": 13, + "w": 12, + "x": 0, + "y": 1 + }, + "id": 1, + "options": { + "legend": { + "calcs": [ + "last" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Last", + "sortDesc": true }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, pgwatch_pg_class_total_relation_size_bytes{relkind=\"114\", schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"})", + "fullMetaSearch": false, + "includeNullMetadata": true, + "legendFormat": "{{schemaname}}.{{relname}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by size", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 1, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "red", - "value": 80 - } - ] + "showPoints": "auto", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" }, - "unit": "Bps" + "thresholdsStyle": { + "mode": "off" + } }, - "overrides": [] - }, - "gridPos": { - "h": 13, - "w": 12, - "x": 12, - "y": 0 - }, - "id": 7, - "options": { - "legend": { - "calcs": [ - "last" - ], - "displayMode": "table", - "placement": "bottom", - "showLegend": true, - "sortBy": "Last", - "sortDesc": true + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] }, - "tooltip": { - "hideZeros": false, - "mode": "single", - "sort": "none" - } + "unit": "Bps" }, - "pluginVersion": "12.0.2", - "targets": [ - { - "disableTextWrap": false, - "editorMode": "code", - "expr": "topk($top_n, irate(pgwatch_pg_class_total_relation_size_bytes{relkind=\"114\", schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", - "fullMetaSearch": false, - "includeNullMetadata": true, - "interval": "20", - "legendFormat": "{{schemaname}}.{{relname}}", - "range": true, - "refId": "A", - "useBackend": false - } - ], - "title": "Top $top_n tables by size change rate", - "type": "timeseries" + "overrides": [] }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" + "gridPos": { + "h": 13, + "w": 12, + "x": 12, + "y": 1 + }, + "id": 7, + "options": { + "legend": { + "calcs": [ + "last" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Last", + "sortDesc": true }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, irate(pgwatch_pg_class_total_relation_size_bytes{relkind=\"114\", schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "20", + "legendFormat": "{{schemaname}}.{{relname}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by size change rate", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 1, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "red", - "value": 80 - } - ] + "showPoints": "auto", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" }, - "unit": "percent" + "thresholdsStyle": { + "mode": "off" + } }, - "overrides": [] - }, - "gridPos": { - "h": 13, - "w": 12, - "x": 0, - "y": 13 - }, - "id": 8, - "options": { - "legend": { - "calcs": [ - "min", - "max", - "mean" - ], - "displayMode": "table", - "placement": "bottom", - "showLegend": true, - "sortBy": "Mean", - "sortDesc": true + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] }, - "tooltip": { - "hideZeros": false, - "mode": "single", - "sort": "none" - } + "unit": "percent" }, - "pluginVersion": "12.0.2", - "targets": [ - { - "disableTextWrap": false, - "editorMode": "code", - "expr": "topk($top_n, pgwatch_pg_table_bloat_bloat_pct{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"})", - "fullMetaSearch": false, - "includeNullMetadata": true, - "legendFormat": "{{schemaname}}.{{tblname}}", - "range": true, - "refId": "A", - "useBackend": false - } - ], - "title": "Top $top_n tables by bloat %", - "type": "timeseries" + "overrides": [] }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" + "gridPos": { + "h": 13, + "w": 12, + "x": 0, + "y": 14 + }, + "id": 8, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, pgwatch_pg_table_bloat_bloat_pct{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"})", + "fullMetaSearch": false, + "includeNullMetadata": true, + "legendFormat": "{{schemaname}}.{{tblname}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by estimated bloat %", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 1, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "red", - "value": 80 - } - ] + "showPoints": "auto", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "normal" }, - "unit": "bytes" + "thresholdsStyle": { + "mode": "off" + } }, - "overrides": [] - }, - "gridPos": { - "h": 13, - "w": 12, - "x": 12, - "y": 13 - }, - "id": 2, - "options": { - "legend": { - "calcs": [ - "last" - ], - "displayMode": "table", - "placement": "bottom", - "showLegend": true, - "sortBy": "Last", - "sortDesc": true + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] }, - "tooltip": { - "hideZeros": false, - "mode": "single", - "sort": "none" - } + "unit": "bytes" }, - "pluginVersion": "12.0.2", - "targets": [ - { - "disableTextWrap": false, - "editorMode": "code", - "expr": "topk($top_n, pgwatch_pg_table_bloat_bloat_size{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"})", - "fullMetaSearch": false, - "includeNullMetadata": true, - "legendFormat": "{{schemaname}}.{{tblname}}", - "range": true, - "refId": "A", - "useBackend": false - } - ], - "title": "Top $top_n tables by bloat size", - "type": "timeseries" + "overrides": [] }, - { - "collapsed": false, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 26 - }, - "id": 11, - "panels": [], - "title": "Tuple stats", - "type": "row" + "gridPos": { + "h": 13, + "w": 12, + "x": 12, + "y": 14 }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" + "id": 2, + "options": { + "legend": { + "calcs": [ + "last" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Last", + "sortDesc": true }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 1, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "ops" + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, pgwatch_pg_table_bloat_bloat_size{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"})", + "fullMetaSearch": false, + "includeNullMetadata": true, + "legendFormat": "{{schemaname}}.{{tblname}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by estimated bloat size", + "type": "timeseries" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 27 + }, + "id": 11, + "panels": [], + "title": "Tuple stats", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" }, - "overrides": [ - { - "matcher": { - "id": "byFrameRefID", - "options": "A" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "dark-green", - "mode": "fixed" - } - } - ] + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false }, - { - "matcher": { - "id": "byFrameRefID", - "options": "B" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "orange", - "mode": "fixed" - } - } - ] + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" }, - { - "matcher": { - "id": "byFrameRefID", - "options": "C" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "yellow", - "mode": "fixed" - } - } - ] + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" }, - { - "matcher": { - "id": "byFrameRefID", - "options": "D" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "dark-red", - "mode": "fixed" - } - } - ] + "thresholdsStyle": { + "mode": "off" } - ] - }, - "gridPos": { - "h": 10, - "w": 24, - "x": 0, - "y": 27 - }, - "id": 12, - "options": { - "legend": { - "calcs": [ - "min", - "max", - "mean" - ], - "displayMode": "table", - "placement": "bottom", - "showLegend": true, - "sortBy": "Max", - "sortDesc": true }, - "tooltip": { - "hideZeros": false, - "mode": "single", - "sort": "none" - } - }, - "pluginVersion": "12.0.2", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "sum(irate(pgwatch_table_stats_n_tup_ins{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", - "fullMetaSearch": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "Inserts", - "range": true, - "refId": "A", - "useBackend": false + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] }, + "unit": "ops" + }, + "overrides": [ { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" + "matcher": { + "id": "byFrameRefID", + "options": "A" }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "sum(irate(pgwatch_table_stats_n_tup_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", - "fullMetaSearch": false, - "hide": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "Updates", - "range": true, - "refId": "B", - "useBackend": false + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-green", + "mode": "fixed" + } + } + ] }, { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" + "matcher": { + "id": "byFrameRefID", + "options": "B" }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "sum(irate(pgwatch_table_stats_n_tup_hot_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", - "fullMetaSearch": false, - "hide": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "HOT Updates", - "range": true, - "refId": "C", - "useBackend": false + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] }, { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" + "matcher": { + "id": "byFrameRefID", + "options": "C" }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "sum(irate(pgwatch_table_stats_n_tup_del{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", - "fullMetaSearch": false, - "hide": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "Deletes", - "range": true, - "refId": "D", - "useBackend": false - } - ], - "title": "Tuple operations (aggregated)", - "transformations": [ - { - "id": "calculateField", - "options": { - "alias": "Non-HOT Updates", - "binary": { - "left": { - "matcher": { - "id": "byName", - "options": "Updates" - } - }, - "operator": "-", - "right": { - "matcher": { - "id": "byName", - "options": "HOT Updates" - } + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "yellow", + "mode": "fixed" } - }, - "mode": "binary", - "reduce": { - "reducer": "sum" } - } + ] }, { - "id": "organize", - "options": { - "excludeByName": { - "Updates": true - }, - "includeByName": {}, - "indexByName": {}, - "renameByName": { - "Hot Updates": "HOT Updates" + "matcher": { + "id": "byFrameRefID", + "options": "D" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } } - } + ] } - ], - "type": "timeseries" + ] }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" + "gridPos": { + "h": 10, + "w": 24, + "x": 0, + "y": 28 + }, + "id": 12, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Max", + "sortDesc": true }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 1, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "percentunit" + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" }, - "overrides": [ - { - "matcher": { - "id": "byFrameRefID", - "options": "A" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "dark-green", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byFrameRefID", - "options": "B" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "orange", - "mode": "fixed" - } + "disableTextWrap": false, + "editorMode": "code", + "expr": "sum(irate(pgwatch_table_stats_n_tup_ins{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "60", + "legendFormat": "Inserts", + "range": true, + "refId": "A", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "sum(irate(pgwatch_table_stats_n_tup_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "interval": "60", + "legendFormat": "Updates", + "range": true, + "refId": "B", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "sum(irate(pgwatch_table_stats_n_tup_hot_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "interval": "60", + "legendFormat": "HOT Updates", + "range": true, + "refId": "C", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "sum(irate(pgwatch_table_stats_n_tup_del{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "interval": "60", + "legendFormat": "Deletes", + "range": true, + "refId": "D", + "useBackend": false + } + ], + "title": "Tuple operations (aggregated)", + "transformations": [ + { + "id": "calculateField", + "options": { + "alias": "Non-HOT Updates", + "binary": { + "left": { + "matcher": { + "id": "byName", + "options": "Updates" } - ] - }, - { - "matcher": { - "id": "byFrameRefID", - "options": "C" }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "yellow", - "mode": "fixed" - } + "operator": "-", + "right": { + "matcher": { + "id": "byName", + "options": "HOT Updates" } - ] + } }, - { - "matcher": { - "id": "byFrameRefID", - "options": "D" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "dark-red", - "mode": "fixed" - } - } - ] + "mode": "binary", + "reduce": { + "reducer": "sum" } - ] - }, - "gridPos": { - "h": 10, - "w": 24, - "x": 0, - "y": 37 - }, - "id": 21, - "options": { - "legend": { - "calcs": [ - "min", - "max", - "mean" - ], - "displayMode": "table", - "placement": "bottom", - "showLegend": true, - "sortBy": "Max", - "sortDesc": true - }, - "tooltip": { - "hideZeros": false, - "mode": "single", - "sort": "none" } }, - "pluginVersion": "12.0.2", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" + { + "id": "organize", + "options": { + "excludeByName": { + "Updates": true }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "sum(irate(pgwatch_table_stats_n_tup_ins{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", - "fullMetaSearch": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "Inserts", - "range": true, - "refId": "A", - "useBackend": false + "includeByName": {}, + "indexByName": {}, + "renameByName": { + "Hot Updates": "HOT Updates" + } + } + } + ], + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "sum(irate(pgwatch_table_stats_n_tup_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", - "fullMetaSearch": false, - "hide": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "Updates", - "range": true, - "refId": "B", - "useBackend": false - }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "sum(irate(pgwatch_table_stats_n_tup_hot_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", - "fullMetaSearch": false, - "hide": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "HOT Updates", - "range": true, - "refId": "C", - "useBackend": false - }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "sum(irate(pgwatch_table_stats_n_tup_del{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", - "fullMetaSearch": false, - "hide": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "Deletes", - "range": true, - "refId": "D", - "useBackend": false - } - ], - "title": "Tuple operations (%) (Aggregated)", - "transformations": [ - { - "id": "calculateField", - "options": { - "alias": "Non-HOT Updates", - "binary": { - "left": { - "matcher": { - "id": "byName", - "options": "Updates" - } - }, - "operator": "-", - "right": { - "matcher": { - "id": "byName", - "options": "HOT Updates" - } - } - }, - "mode": "binary", - "reduce": { - "reducer": "sum" - } + "thresholdsStyle": { + "mode": "off" } }, - { - "id": "calculateField", - "options": { - "mode": "reduceRow", - "reduce": { - "include": [ - "Inserts", - "Deletes", - "Updates" - ], - "reducer": "sum" + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 } - } + ] }, + "unit": "percentunit" + }, + "overrides": [ { - "id": "calculateField", - "options": { - "alias": "Inserts %", - "binary": { - "left": { - "matcher": { - "id": "byName", - "options": "Inserts" - } - }, - "operator": "/", - "right": { - "matcher": { - "id": "byName", - "options": "Total" - } + "matcher": { + "id": "byFrameRefID", + "options": "A" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-green", + "mode": "fixed" } - }, - "mode": "binary", - "reduce": { - "reducer": "sum" } - } + ] }, { - "id": "calculateField", - "options": { - "alias": "Non-HOT-Updates %", - "binary": { - "left": { - "matcher": { - "id": "byName", - "options": "Non-HOT Updates" - } - }, - "operator": "/", - "right": { - "matcher": { - "id": "byName", - "options": "Total" - } + "matcher": { + "id": "byFrameRefID", + "options": "B" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" } - }, - "mode": "binary", - "reduce": { - "reducer": "sum" } - } + ] }, { - "id": "calculateField", - "options": { - "alias": "HOT-Updates", - "binary": { - "left": { - "matcher": { - "id": "byName", - "options": "HOT Updates" - } - }, - "operator": "/", - "right": { - "matcher": { - "id": "byName", - "options": "Total" - } + "matcher": { + "id": "byFrameRefID", + "options": "C" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "yellow", + "mode": "fixed" } - }, - "mode": "binary", - "reduce": { - "reducer": "sum" } - } + ] }, { - "id": "calculateField", - "options": { - "alias": "Deletes %", - "binary": { - "left": { - "matcher": { - "id": "byName", - "options": "Deletes" - } - }, - "operator": "/", - "right": { - "matcher": { - "id": "byName", - "options": "Total" - } + "matcher": { + "id": "byFrameRefID", + "options": "D" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" } - }, - "mode": "binary", - "reduce": { - "reducer": "sum" } - } - }, - { - "id": "organize", - "options": { - "excludeByName": { - "Deletes": true, - "HOT Updates": true, - "Inserts": true, - "Non-HOT Updates": true, - "Total": true, - "Updates": true - }, - "includeByName": {}, - "indexByName": {}, - "renameByName": { - "Hot Updates": "HOT Updates" - } - } + ] } - ], - "type": "timeseries" + ] }, - { - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": 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" - }, - { - "color": "red", - "value": 80 - } - ] - } + "gridPos": { + "h": 10, + "w": 24, + "x": 0, + "y": 38 + }, + "id": 21, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Max", + "sortDesc": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" }, - "overrides": [] + "disableTextWrap": false, + "editorMode": "code", + "expr": "sum(irate(pgwatch_table_stats_n_tup_ins{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "60", + "legendFormat": "Inserts", + "range": true, + "refId": "A", + "useBackend": false }, - "gridPos": { - "h": 10, - "w": 12, - "x": 0, - "y": 47 + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "sum(irate(pgwatch_table_stats_n_tup_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "interval": "60", + "legendFormat": "Updates", + "range": true, + "refId": "B", + "useBackend": false }, - "id": 3, - "options": { - "legend": { - "calcs": [ - "min", - "max", - "mean" - ], - "displayMode": "table", - "placement": "bottom", - "showLegend": true, - "sortBy": "Mean", - "sortDesc": true + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" }, - "tooltip": { - "hideZeros": false, - "mode": "single", - "sort": "none" - } + "disableTextWrap": false, + "editorMode": "code", + "expr": "sum(irate(pgwatch_table_stats_n_tup_hot_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "interval": "60", + "legendFormat": "HOT Updates", + "range": true, + "refId": "C", + "useBackend": false }, - "pluginVersion": "12.0.2", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "sum(irate(pgwatch_table_stats_n_tup_del{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "interval": "60", + "legendFormat": "Deletes", + "range": true, + "refId": "D", + "useBackend": false + } + ], + "title": "Tuple operations (%) (Aggregated)", + "transformations": [ + { + "id": "calculateField", + "options": { + "alias": "Non-HOT Updates", + "binary": { + "left": { + "matcher": { + "id": "byName", + "options": "Updates" + } + }, + "operator": "-", + "right": { + "matcher": { + "id": "byName", + "options": "HOT Updates" + } + } }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "topk($top_n, sum by(schema, table_name, table_full_name) (irate(pgwatch_table_stats_n_tup_ins{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval])))", - "fullMetaSearch": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "{{table_full_name}}", - "range": true, - "refId": "A", - "useBackend": false + "mode": "binary", + "reduce": { + "reducer": "sum" + } } - ], - "title": "Top $top_n tables by inserts/sec", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 1, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" + { + "id": "calculateField", + "options": { + "mode": "reduceRow", + "reduce": { + "include": [ + "Inserts", + "Deletes", + "Updates" + ], + "reducer": "sum" + } + } + }, + { + "id": "calculateField", + "options": { + "alias": "Inserts %", + "binary": { + "left": { + "matcher": { + "id": "byName", + "options": "Inserts" + } }, - "thresholdsStyle": { - "mode": "off" - } - }, - "links": [ - { - "title": "Table details", - "url": "/https/github.com/d/11-single-table-analysis/11-single-table-analysis?orgId=1&var-cluster_name=${cluster_name}&var-node_name=${node_name}&var-db_name=${db_name}&var-schema_name=${__field.labels.schema}&var-table_name=${__field.labels.table_name}" - } - ], - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "red", - "value": 80 + "operator": "/", + "right": { + "matcher": { + "id": "byName", + "options": "Total" } - ] + } }, - "unit": "ops" - }, - "overrides": [] - }, - "gridPos": { - "h": 10, - "w": 12, - "x": 12, - "y": 47 - }, - "id": 4, - "options": { - "legend": { - "calcs": [ - "min", - "max", - "mean" - ], - "displayMode": "table", - "placement": "bottom", - "showLegend": true, - "sortBy": "Mean", - "sortDesc": true - }, - "tooltip": { - "hideZeros": false, - "mode": "single", - "sort": "none" + "mode": "binary", + "reduce": { + "reducer": "sum" + } } }, - "pluginVersion": "12.0.2", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" + { + "id": "calculateField", + "options": { + "alias": "Non-HOT-Updates %", + "binary": { + "left": { + "matcher": { + "id": "byName", + "options": "Non-HOT Updates" + } + }, + "operator": "/", + "right": { + "matcher": { + "id": "byName", + "options": "Total" + } + } }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "topk($top_n, sum by(schema, table_name, table_full_name) (irate(pgwatch_table_stats_n_tup_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval])))", - "fullMetaSearch": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "{{table_full_name}}", - "range": true, - "refId": "A", - "useBackend": false + "mode": "binary", + "reduce": { + "reducer": "sum" + } } - ], - "title": "Top $top_n tables by updates/sec", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 1, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" + { + "id": "calculateField", + "options": { + "alias": "HOT-Updates", + "binary": { + "left": { + "matcher": { + "id": "byName", + "options": "HOT Updates" + } }, - "thresholdsStyle": { - "mode": "off" + "operator": "/", + "right": { + "matcher": { + "id": "byName", + "options": "Total" + } } }, - "links": [ - { - "title": "Table details", - "url": "/https/github.com/d/11-single-table-analysis/11-single-table-analysis?orgId=1&var-cluster_name=${cluster_name}&var-node_name=${node_name}&var-db_name=${db_name}&var-schema_name=${__field.labels.schema}&var-table_name=${__field.labels.table_name}" - } - ], - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "red", - "value": 80 + "mode": "binary", + "reduce": { + "reducer": "sum" + } + } + }, + { + "id": "calculateField", + "options": { + "alias": "Deletes %", + "binary": { + "left": { + "matcher": { + "id": "byName", + "options": "Deletes" + } + }, + "operator": "/", + "right": { + "matcher": { + "id": "byName", + "options": "Total" } - ] + } }, - "unit": "ops" - }, - "overrides": [] - }, - "gridPos": { - "h": 10, - "w": 12, - "x": 0, - "y": 57 - }, - "id": 5, - "options": { - "legend": { - "calcs": [ - "min", - "max", - "mean" - ], - "displayMode": "table", - "placement": "bottom", - "showLegend": true, - "sortBy": "Mean", - "sortDesc": true - }, - "tooltip": { - "hideZeros": false, - "mode": "single", - "sort": "none" + "mode": "binary", + "reduce": { + "reducer": "sum" + } } }, - "pluginVersion": "12.0.2", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" + { + "id": "organize", + "options": { + "excludeByName": { + "Deletes": true, + "HOT Updates": true, + "Inserts": true, + "Non-HOT Updates": true, + "Total": true, + "Updates": true }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "topk($top_n, sum by(schema, table_name, table_full_name) (irate(pgwatch_table_stats_n_tup_del{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval])))", - "fullMetaSearch": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "{{table_full_name}}", - "range": true, - "refId": "A", - "useBackend": false + "includeByName": {}, + "indexByName": {}, + "renameByName": { + "Hot Updates": "HOT Updates" + } } - ], - "title": "Top $top_n tables by deletes/sec", - "type": "timeseries" + } + ], + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 1, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" }, - "links": [ - { - "title": "Table details", - "url": "/https/github.com/d/11-single-table-analysis/11-single-table-analysis?orgId=1&var-cluster_name=${cluster_name}&var-node_name=${node_name}&var-db_name=${db_name}&var-schema_name=${__field.labels.schema}&var-table_name=${__field.labels.table_name}" - } - ], - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "red", - "value": 80 - } - ] + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" }, - "unit": "ops" - }, - "overrides": [] - }, - "gridPos": { - "h": 10, - "w": 12, - "x": 12, - "y": 57 - }, - "id": 6, - "options": { - "legend": { - "calcs": [ - "min", - "max", - "mean" - ], - "displayMode": "table", - "placement": "bottom", - "showLegend": true, - "sortBy": "Mean", - "sortDesc": true + "thresholdsStyle": { + "mode": "off" + } }, - "tooltip": { - "hideZeros": false, - "mode": "single", - "sort": "none" + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] } }, - "pluginVersion": "12.0.2", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "topk($top_n, sum by(schema, table_name, table_full_name) (irate(pgwatch_table_stats_n_tup_hot_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval])))", - "fullMetaSearch": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "{{table_full_name}}", - "range": true, - "refId": "A", - "useBackend": false - } - ], - "title": "Top $top_n tables by HOT updates/sec", - "type": "timeseries" + "overrides": [] }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 48 + }, + "id": 3, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, sum by(schema, table_name, table_full_name) (irate(pgwatch_table_stats_n_tup_ins{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval])))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "60", + "legendFormat": "{{table_full_name}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by inserts/sec", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 1, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" }, - "links": [ - { - "title": "Table details", - "url": "/https/github.com/d/11-single-table-analysis/11-single-table-analysis?orgId=1&var-cluster_name=${cluster_name}&var-node_name=${node_name}&var-db_name=${db_name}&var-schema_name=${__field.labels.schema}&var-table_name=${__field.labels.table_name}" - } - ], - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "red", - "value": 80 - } - ] + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" }, - "unit": "ops" + "thresholdsStyle": { + "mode": "off" + } }, - "overrides": [] - }, - "gridPos": { - "h": 10, - "w": 12, - "x": 0, - "y": 67 - }, - "id": 10, - "options": { - "legend": { - "calcs": [ - "min", - "max", - "mean" - ], - "displayMode": "table", - "placement": "bottom", - "showLegend": true, - "sortBy": "Mean", - "sortDesc": true + "links": [ + { + "title": "Table details", + "url": "/https/github.com/d/11-single-table-analysis/11-single-table-analysis?orgId=1&var-cluster_name=${cluster_name}&var-node_name=${node_name}&var-db_name=${db_name}&var-schema_name=${__field.labels.schema}&var-table_name=${__field.labels.table_name}" + } + ], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] }, - "tooltip": { - "hideZeros": false, - "mode": "single", - "sort": "none" - } + "unit": "ops" }, - "pluginVersion": "12.0.2", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "topk($top_n, sum by(schema, table_name, table_full_name) (irate(pgwatch_table_stats_n_tup_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]) - irate(pgwatch_table_stats_n_tup_hot_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval])))", - "fullMetaSearch": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "{{table_full_name}}", - "range": true, - "refId": "A", - "useBackend": false - } - ], - "title": "Top $top_n tables by Non-HOT updates/sec", - "type": "timeseries" + "overrides": [] }, - { - "fieldConfig": { - "defaults": {}, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 24, - "x": 0, - "y": 77 - }, - "id": 20, - "options": { - "code": { - "language": "plaintext", - "showLineNumbers": false, - "showMiniMap": false - }, - "content": "

\n Brought to you by Postgres AI\n \"Postgres.AI\"\n

\n", - "mode": "html" + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 48 + }, + "id": 4, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true }, - "pluginVersion": "12.0.2", - "title": "", - "type": "text" - } - ], - "preload": false, - "schemaVersion": 41, - "tags": [], - "templating": { - "list": [ + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ { - "current": { - "text": "default", - "value": "default" + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" }, - "definition": "label_values(pgwatch_settings_configured,cluster)", - "label": "Cluster name", - "name": "cluster_name", - "options": [], - "query": { - "qryType": 1, - "query": "label_values(pgwatch_settings_configured,cluster)", - "refId": "PrometheusVariableQueryEditor-VariableQuery" + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, sum by(schema, table_name, table_full_name) (irate(pgwatch_table_stats_n_tup_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval])))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "60", + "legendFormat": "{{table_full_name}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by updates/sec", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" }, - "refresh": 1, - "regex": "", - "type": "query" - }, - { - "current": { - "text": "5.78.159.160", - "value": "5.78.159.160" + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } }, - "definition": "label_values(pgwatch_settings_configured{cluster=\"$cluster_name\"},node_name)", - "label": "Node name", - "name": "node_name", - "options": [], - "query": { - "qryType": 1, - "query": "label_values(pgwatch_settings_configured{cluster=\"$cluster_name\"},node_name)", - "refId": "PrometheusVariableQueryEditor-VariableQuery" + "links": [ + { + "title": "Table details", + "url": "/https/github.com/d/11-single-table-analysis/11-single-table-analysis?orgId=1&var-cluster_name=${cluster_name}&var-node_name=${node_name}&var-db_name=${db_name}&var-schema_name=${__field.labels.schema}&var-table_name=${__field.labels.table_name}" + } + ], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] }, - "refresh": 1, - "regex": "", - "type": "query" + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 58 + }, + "id": 5, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ { - "current": { - "text": "postgres", - "value": "postgres" + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" }, - "definition": "label_values(pgwatch_pg_database_wraparound_age_datfrozenxid{cluster=\"$cluster_name\", node_name=\"$node_name\", datname!=\"template1\"},datname)", - "label": "DB name", - "name": "db_name", - "options": [], - "query": { - "qryType": 1, - "query": "label_values(pgwatch_pg_database_wraparound_age_datfrozenxid{cluster=\"$cluster_name\", node_name=\"$node_name\", datname!=\"template1\"},datname)", - "refId": "PrometheusVariableQueryEditor-VariableQuery" + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, sum by(schema, table_name, table_full_name) (irate(pgwatch_table_stats_n_tup_del{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval])))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "60", + "legendFormat": "{{table_full_name}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by deletes/sec", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" }, - "refresh": 1, - "regex": "", - "type": "query" - }, - { - "current": { - "text": "All", - "value": "$__all" + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } }, - "definition": "label_values(pgwatch_pg_class_relation_size_bytes,schemaname)", - "includeAll": true, - "label": "Schema name", - "name": "schema_name", - "options": [], - "query": { - "qryType": 1, - "query": "label_values(pgwatch_pg_class_relation_size_bytes,schemaname)", - "refId": "PrometheusVariableQueryEditor-VariableQuery" + "links": [ + { + "title": "Table details", + "url": "/https/github.com/d/11-single-table-analysis/11-single-table-analysis?orgId=1&var-cluster_name=${cluster_name}&var-node_name=${node_name}&var-db_name=${db_name}&var-schema_name=${__field.labels.schema}&var-table_name=${__field.labels.table_name}" + } + ], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] }, - "refresh": 1, - "regex": "", - "type": "query" + "unit": "ops" }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 58 + }, + "id": 6, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ { - "current": { - "text": "10", - "value": "10" + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" }, - "label": "Top N tables", - "name": "top_n", - "options": [ - { - "selected": false, - "text": "5", - "value": "5" + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, sum by(schema, table_name, table_full_name) (irate(pgwatch_table_stats_n_tup_hot_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval])))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "60", + "legendFormat": "{{table_full_name}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by HOT updates/sec", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false }, - { - "selected": true, - "text": "10", - "value": "10" + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" }, - { - "selected": false, - "text": "15", - "value": "15" + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [ { - "selected": false, - "text": "20", - "value": "20" + "title": "Table details", + "url": "/https/github.com/d/11-single-table-analysis/11-single-table-analysis?orgId=1&var-cluster_name=${cluster_name}&var-node_name=${node_name}&var-db_name=${db_name}&var-schema_name=${__field.labels.schema}&var-table_name=${__field.labels.table_name}" } ], - "query": "5,10,15,20", - "type": "custom" + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 68 + }, + "id": 10, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" } - ] - }, - "time": { - "from": "now-12h", - "to": "now" + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, sum by(schema, table_name, table_full_name) (irate(pgwatch_table_stats_n_tup_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]) - irate(pgwatch_table_stats_n_tup_hot_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval])))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "60", + "legendFormat": "{{table_full_name}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by Non-HOT updates/sec", + "type": "timeseries" }, - "timepicker": {}, - "timezone": "utc", - "title": "09. Top tables overview", - "uid": "92657f2a-985b-4d1a-99ed-2fac6e0c53e2", - "version": 10 - } \ No newline at end of file + { + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 24, + "x": 0, + "y": 78 + }, + "id": 20, + "options": { + "code": { + "language": "plaintext", + "showLineNumbers": false, + "showMiniMap": false + }, + "content": "

\n Brought to you by PostgresAI\n \"Postgres.AI\"\n

\n", + "mode": "html" + }, + "pluginVersion": "12.0.2", + "title": "", + "type": "text" + } + ], + "preload": false, + "schemaVersion": 41, + "tags": [], + "templating": { + "list": [ + { + "current": { + "text": "default", + "value": "default" + }, + "definition": "label_values(pgwatch_settings_configured,cluster)", + "label": "Cluster name", + "name": "cluster_name", + "options": [], + "query": { + "qryType": 1, + "query": "label_values(pgwatch_settings_configured,cluster)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 1, + "regex": "", + "type": "query" + }, + { + "current": { + "text": "postgres_ai", + "value": "postgres_ai" + }, + "definition": "label_values(pgwatch_settings_configured{cluster=\"$cluster_name\"},node_name)", + "label": "Node name", + "name": "node_name", + "options": [], + "query": { + "qryType": 1, + "query": "label_values(pgwatch_settings_configured{cluster=\"$cluster_name\"},node_name)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 1, + "regex": "", + "type": "query" + }, + { + "current": { + "text": "workloaddb", + "value": "workloaddb" + }, + "definition": "label_values(pgwatch_pg_database_wraparound_age_datfrozenxid{cluster=\"$cluster_name\", node_name=\"$node_name\", datname!=\"template1\"},datname)", + "label": "DB name", + "name": "db_name", + "options": [], + "query": { + "qryType": 1, + "query": "label_values(pgwatch_pg_database_wraparound_age_datfrozenxid{cluster=\"$cluster_name\", node_name=\"$node_name\", datname!=\"template1\"},datname)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 1, + "regex": "", + "type": "query" + }, + { + "current": { + "text": "All", + "value": "$__all" + }, + "definition": "label_values(pgwatch_pg_class_relation_size_bytes,schemaname)", + "includeAll": true, + "label": "Schema name", + "name": "schema_name", + "options": [], + "query": { + "qryType": 1, + "query": "label_values(pgwatch_pg_class_relation_size_bytes,schemaname)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 1, + "regex": "", + "type": "query" + }, + { + "current": { + "text": "10", + "value": "10" + }, + "label": "Top N tables", + "name": "top_n", + "options": [ + { + "selected": false, + "text": "5", + "value": "5" + }, + { + "selected": true, + "text": "10", + "value": "10" + }, + { + "selected": false, + "text": "15", + "value": "15" + }, + { + "selected": false, + "text": "20", + "value": "20" + } + ], + "query": "5,10,15,20", + "type": "custom" + } + ] + }, + "time": { + "from": "now-12h", + "to": "now" + }, + "timepicker": {}, + "timezone": "utc", + "title": "09. Top tables overview", + "uid": "92657f2a-985b-4d1a-99ed-2fac6e0c53e2", + "version": 54 +} \ No newline at end of file From 91f689718277d840a840e31d231a834e5ed013aa Mon Sep 17 00:00:00 2001 From: "dementii.priadko" <45518657+DEMNERD@users.noreply.github.com> Date: Tue, 23 Sep 2025 00:06:00 +0300 Subject: [PATCH 04/22] Updated table stats --- .../dashboards/Dashboard_9_Table_Stats.json | 685 +----------------- 1 file changed, 23 insertions(+), 662 deletions(-) diff --git a/config/grafana/dashboards/Dashboard_9_Table_Stats.json b/config/grafana/dashboards/Dashboard_9_Table_Stats.json index 81e5a92..b572d94 100644 --- a/config/grafana/dashboards/Dashboard_9_Table_Stats.json +++ b/config/grafana/dashboards/Dashboard_9_Table_Stats.json @@ -21,19 +21,6 @@ "id": 9, "links": [], "panels": [ - { - "collapsed": false, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 0 - }, - "id": 22, - "panels": [], - "title": "Row title", - "type": "row" - }, { "datasource": { "type": "prometheus", @@ -98,7 +85,7 @@ "h": 13, "w": 12, "x": 0, - "y": 1 + "y": 0 }, "id": 1, "options": { @@ -199,7 +186,7 @@ "h": 13, "w": 12, "x": 12, - "y": 1 + "y": 0 }, "id": 7, "options": { @@ -237,6 +224,19 @@ "title": "Top $top_n tables by size change rate", "type": "timeseries" }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 13 + }, + "id": 22, + "panels": [], + "title": "Bloat stats", + "type": "row" + }, { "datasource": { "type": "prometheus", @@ -454,645 +454,6 @@ "title": "Tuple stats", "type": "row" }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 1, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "ops" - }, - "overrides": [ - { - "matcher": { - "id": "byFrameRefID", - "options": "A" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "dark-green", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byFrameRefID", - "options": "B" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "orange", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byFrameRefID", - "options": "C" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "yellow", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byFrameRefID", - "options": "D" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "dark-red", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 10, - "w": 24, - "x": 0, - "y": 28 - }, - "id": 12, - "options": { - "legend": { - "calcs": [ - "min", - "max", - "mean" - ], - "displayMode": "table", - "placement": "bottom", - "showLegend": true, - "sortBy": "Max", - "sortDesc": true - }, - "tooltip": { - "hideZeros": false, - "mode": "single", - "sort": "none" - } - }, - "pluginVersion": "12.0.2", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "sum(irate(pgwatch_table_stats_n_tup_ins{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", - "fullMetaSearch": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "Inserts", - "range": true, - "refId": "A", - "useBackend": false - }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "sum(irate(pgwatch_table_stats_n_tup_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", - "fullMetaSearch": false, - "hide": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "Updates", - "range": true, - "refId": "B", - "useBackend": false - }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "sum(irate(pgwatch_table_stats_n_tup_hot_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", - "fullMetaSearch": false, - "hide": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "HOT Updates", - "range": true, - "refId": "C", - "useBackend": false - }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "sum(irate(pgwatch_table_stats_n_tup_del{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", - "fullMetaSearch": false, - "hide": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "Deletes", - "range": true, - "refId": "D", - "useBackend": false - } - ], - "title": "Tuple operations (aggregated)", - "transformations": [ - { - "id": "calculateField", - "options": { - "alias": "Non-HOT Updates", - "binary": { - "left": { - "matcher": { - "id": "byName", - "options": "Updates" - } - }, - "operator": "-", - "right": { - "matcher": { - "id": "byName", - "options": "HOT Updates" - } - } - }, - "mode": "binary", - "reduce": { - "reducer": "sum" - } - } - }, - { - "id": "organize", - "options": { - "excludeByName": { - "Updates": true - }, - "includeByName": {}, - "indexByName": {}, - "renameByName": { - "Hot Updates": "HOT Updates" - } - } - } - ], - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 1, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "percentunit" - }, - "overrides": [ - { - "matcher": { - "id": "byFrameRefID", - "options": "A" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "dark-green", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byFrameRefID", - "options": "B" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "orange", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byFrameRefID", - "options": "C" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "yellow", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byFrameRefID", - "options": "D" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "dark-red", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 10, - "w": 24, - "x": 0, - "y": 38 - }, - "id": 21, - "options": { - "legend": { - "calcs": [ - "min", - "max", - "mean" - ], - "displayMode": "table", - "placement": "bottom", - "showLegend": true, - "sortBy": "Max", - "sortDesc": true - }, - "tooltip": { - "hideZeros": false, - "mode": "single", - "sort": "none" - } - }, - "pluginVersion": "12.0.2", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "sum(irate(pgwatch_table_stats_n_tup_ins{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", - "fullMetaSearch": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "Inserts", - "range": true, - "refId": "A", - "useBackend": false - }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "sum(irate(pgwatch_table_stats_n_tup_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", - "fullMetaSearch": false, - "hide": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "Updates", - "range": true, - "refId": "B", - "useBackend": false - }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "sum(irate(pgwatch_table_stats_n_tup_hot_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", - "fullMetaSearch": false, - "hide": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "HOT Updates", - "range": true, - "refId": "C", - "useBackend": false - }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "sum(irate(pgwatch_table_stats_n_tup_del{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval]))", - "fullMetaSearch": false, - "hide": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "Deletes", - "range": true, - "refId": "D", - "useBackend": false - } - ], - "title": "Tuple operations (%) (Aggregated)", - "transformations": [ - { - "id": "calculateField", - "options": { - "alias": "Non-HOT Updates", - "binary": { - "left": { - "matcher": { - "id": "byName", - "options": "Updates" - } - }, - "operator": "-", - "right": { - "matcher": { - "id": "byName", - "options": "HOT Updates" - } - } - }, - "mode": "binary", - "reduce": { - "reducer": "sum" - } - } - }, - { - "id": "calculateField", - "options": { - "mode": "reduceRow", - "reduce": { - "include": [ - "Inserts", - "Deletes", - "Updates" - ], - "reducer": "sum" - } - } - }, - { - "id": "calculateField", - "options": { - "alias": "Inserts %", - "binary": { - "left": { - "matcher": { - "id": "byName", - "options": "Inserts" - } - }, - "operator": "/", - "right": { - "matcher": { - "id": "byName", - "options": "Total" - } - } - }, - "mode": "binary", - "reduce": { - "reducer": "sum" - } - } - }, - { - "id": "calculateField", - "options": { - "alias": "Non-HOT-Updates %", - "binary": { - "left": { - "matcher": { - "id": "byName", - "options": "Non-HOT Updates" - } - }, - "operator": "/", - "right": { - "matcher": { - "id": "byName", - "options": "Total" - } - } - }, - "mode": "binary", - "reduce": { - "reducer": "sum" - } - } - }, - { - "id": "calculateField", - "options": { - "alias": "HOT-Updates", - "binary": { - "left": { - "matcher": { - "id": "byName", - "options": "HOT Updates" - } - }, - "operator": "/", - "right": { - "matcher": { - "id": "byName", - "options": "Total" - } - } - }, - "mode": "binary", - "reduce": { - "reducer": "sum" - } - } - }, - { - "id": "calculateField", - "options": { - "alias": "Deletes %", - "binary": { - "left": { - "matcher": { - "id": "byName", - "options": "Deletes" - } - }, - "operator": "/", - "right": { - "matcher": { - "id": "byName", - "options": "Total" - } - } - }, - "mode": "binary", - "reduce": { - "reducer": "sum" - } - } - }, - { - "id": "organize", - "options": { - "excludeByName": { - "Deletes": true, - "HOT Updates": true, - "Inserts": true, - "Non-HOT Updates": true, - "Total": true, - "Updates": true - }, - "includeByName": {}, - "indexByName": {}, - "renameByName": { - "Hot Updates": "HOT Updates" - } - } - } - ], - "type": "timeseries" - }, { "datasource": { "type": "prometheus", @@ -1156,7 +517,7 @@ "h": 10, "w": 12, "x": 0, - "y": 48 + "y": 28 }, "id": 3, "options": { @@ -1270,7 +631,7 @@ "h": 10, "w": 12, "x": 12, - "y": 48 + "y": 28 }, "id": 4, "options": { @@ -1384,7 +745,7 @@ "h": 10, "w": 12, "x": 0, - "y": 58 + "y": 38 }, "id": 5, "options": { @@ -1498,7 +859,7 @@ "h": 10, "w": 12, "x": 12, - "y": 58 + "y": 38 }, "id": 6, "options": { @@ -1612,7 +973,7 @@ "h": 10, "w": 12, "x": 0, - "y": 68 + "y": 48 }, "id": 10, "options": { @@ -1665,7 +1026,7 @@ "h": 3, "w": 24, "x": 0, - "y": 78 + "y": 58 }, "id": 20, "options": { @@ -1674,7 +1035,7 @@ "showLineNumbers": false, "showMiniMap": false }, - "content": "

\n Brought to you by PostgresAI\n \"Postgres.AI\"\n

\n", + "content": "

\n Brought to you by Postgres AI\n \"Postgres.AI\"\n

\n", "mode": "html" }, "pluginVersion": "12.0.2", @@ -1802,5 +1163,5 @@ "timezone": "utc", "title": "09. Top tables overview", "uid": "92657f2a-985b-4d1a-99ed-2fac6e0c53e2", - "version": 54 + "version": 58 } \ No newline at end of file From b981f287be7ddaa7316308950a41658d41bf3008 Mon Sep 17 00:00:00 2001 From: "dementii.priadko" <45518657+DEMNERD@users.noreply.github.com> Date: Tue, 23 Sep 2025 00:44:33 +0300 Subject: [PATCH 05/22] Changed value in metric to float --- config/pgwatch-prometheus/metrics.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/pgwatch-prometheus/metrics.yml b/config/pgwatch-prometheus/metrics.yml index f34df26..c32549e 100644 --- a/config/pgwatch-prometheus/metrics.yml +++ b/config/pgwatch-prometheus/metrics.yml @@ -1975,18 +1975,18 @@ metrics: case when key = 'index_size_threshold' then case - when value ~ '^[0-9]+MB$' then (regexp_replace(value, 'MB$', '')::numeric * 1024 * 1024)::bigint - when value ~ '^[0-9]+kB$' then (regexp_replace(value, 'kB$', '')::numeric * 1024)::bigint - when value ~ '^[0-9]+GB$' then (regexp_replace(value, 'GB$', '')::numeric * 1024 * 1024 * 1024)::bigint + when value ~ '^[0-9]+MB$' then (regexp_replace(value, 'MB$', '')::numeric * 1024 * 1024)::float + when value ~ '^[0-9]+kB$' then (regexp_replace(value, 'kB$', '')::numeric * 1024)::float + when value ~ '^[0-9]+GB$' then (regexp_replace(value, 'GB$', '')::numeric * 1024 * 1024 * 1024)::float else 0 end when key = 'minimum_reliable_index_size' then case - when value ~ '^[0-9]+kB$' then (regexp_replace(value, 'kB$', '')::numeric * 1024)::bigint - when value ~ '^[0-9]+MB$' then (regexp_replace(value, 'MB$', '')::numeric * 1024 * 1024)::bigint + when value ~ '^[0-9]+kB$' then (regexp_replace(value, 'kB$', '')::numeric * 1024)::float + when value ~ '^[0-9]+MB$' then (regexp_replace(value, 'MB$', '')::numeric * 1024 * 1024)::float else 0 end - when key = 'index_rebuild_scale_factor' then value::numeric + when key = 'index_rebuild_scale_factor' then value::float when key = 'reindex_history_retention_period' then case when value ~ 'years?' then regexp_replace(value, ' years?', '')::int else 0 end when key = 'skip' then case when value::boolean then 1 else 0 end From 45ff5d1679f23246f95f0cd56cfdf1237ee2ded0 Mon Sep 17 00:00:00 2001 From: "dementii.priadko" <45518657+DEMNERD@users.noreply.github.com> Date: Wed, 24 Sep 2025 15:59:27 +0300 Subject: [PATCH 06/22] Reordered dashboards --- ...th.json => Dashboard_10_Index health.json} | 2 +- ...> Dashboard_11_Single_index_analysis.json} | 2 +- ...tats.json => Dashboard_8_Table_Stats.json} | 163 +++--------------- ...=> Dashboard_9_Single_table_analysis.json} | 10 +- 4 files changed, 38 insertions(+), 139 deletions(-) rename config/grafana/dashboards/{Dashboard_8_Index health.json => Dashboard_10_Index health.json} (99%) rename config/grafana/dashboards/{Dashboard_10_Single_index_analysis.json => Dashboard_11_Single_index_analysis.json} (99%) rename config/grafana/dashboards/{Dashboard_9_Table_Stats.json => Dashboard_8_Table_Stats.json} (85%) rename config/grafana/dashboards/{Dashboard_11_Single_table_analysis.json => Dashboard_9_Single_table_analysis.json} (99%) diff --git a/config/grafana/dashboards/Dashboard_8_Index health.json b/config/grafana/dashboards/Dashboard_10_Index health.json similarity index 99% rename from config/grafana/dashboards/Dashboard_8_Index health.json rename to config/grafana/dashboards/Dashboard_10_Index health.json index 7de11a3..ed0325e 100644 --- a/config/grafana/dashboards/Dashboard_8_Index health.json +++ b/config/grafana/dashboards/Dashboard_10_Index health.json @@ -719,7 +719,7 @@ }, "timepicker": {}, "timezone": "utc", - "title": "08. Index health -- \"Metrics are collected (part of health check); dashboard – TODO\"", + "title": "10. Aggregated index analysis", "uid": "db3b37d1-1540-4f7e-95c9-4082f2ca349e", "version": 11 } \ No newline at end of file diff --git a/config/grafana/dashboards/Dashboard_10_Single_index_analysis.json b/config/grafana/dashboards/Dashboard_11_Single_index_analysis.json similarity index 99% rename from config/grafana/dashboards/Dashboard_10_Single_index_analysis.json rename to config/grafana/dashboards/Dashboard_11_Single_index_analysis.json index 5b221e2..fe9b309 100644 --- a/config/grafana/dashboards/Dashboard_10_Single_index_analysis.json +++ b/config/grafana/dashboards/Dashboard_11_Single_index_analysis.json @@ -224,7 +224,7 @@ }, "timepicker": {}, "timezone": "browser", - "title": "10. Single index analysis", + "title": "11. Single index analysis", "uid": "aa0128c5-c5a0-4418-a99e-c941af10426e", "version": 6 } \ No newline at end of file diff --git a/config/grafana/dashboards/Dashboard_9_Table_Stats.json b/config/grafana/dashboards/Dashboard_8_Table_Stats.json similarity index 85% rename from config/grafana/dashboards/Dashboard_9_Table_Stats.json rename to config/grafana/dashboards/Dashboard_8_Table_Stats.json index b572d94..2a75c91 100644 --- a/config/grafana/dashboards/Dashboard_9_Table_Stats.json +++ b/config/grafana/dashboards/Dashboard_8_Table_Stats.json @@ -37,6 +37,7 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", + "axisSoftMin": 0, "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", @@ -178,7 +179,7 @@ } ] }, - "unit": "Bps" + "unit": "bytes" }, "overrides": [] }, @@ -221,7 +222,7 @@ "useBackend": false } ], - "title": "Top $top_n tables by size change rate", + "title": "Top $top_n tables by size change rate (absolute)", "type": "timeseries" }, { @@ -234,7 +235,7 @@ }, "id": 22, "panels": [], - "title": "Bloat stats", + "title": "Estimated bloat stats", "type": "row" }, { @@ -253,6 +254,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", + "axisSoftMax": 100, + "axisSoftMin": 0, "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", @@ -337,7 +340,7 @@ "useBackend": false } ], - "title": "Top $top_n tables by estimated bloat %", + "title": "Top $top_n tables by estimated heap bloat %", "type": "timeseries" }, { @@ -356,6 +359,7 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", + "axisSoftMin": 0, "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", @@ -410,7 +414,9 @@ "options": { "legend": { "calcs": [ - "last" + "min", + "max", + "mean" ], "displayMode": "table", "placement": "bottom", @@ -438,7 +444,7 @@ "useBackend": false } ], - "title": "Top $top_n tables by estimated bloat size", + "title": "Top $top_n tables by estimated heap bloat size", "type": "timeseries" }, { @@ -558,121 +564,7 @@ "useBackend": false } ], - "title": "Top $top_n tables by inserts/sec", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 1, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "links": [ - { - "title": "Table details", - "url": "/https/github.com/d/11-single-table-analysis/11-single-table-analysis?orgId=1&var-cluster_name=${cluster_name}&var-node_name=${node_name}&var-db_name=${db_name}&var-schema_name=${__field.labels.schema}&var-table_name=${__field.labels.table_name}" - } - ], - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "ops" - }, - "overrides": [] - }, - "gridPos": { - "h": 10, - "w": 12, - "x": 12, - "y": 28 - }, - "id": 4, - "options": { - "legend": { - "calcs": [ - "min", - "max", - "mean" - ], - "displayMode": "table", - "placement": "bottom", - "showLegend": true, - "sortBy": "Mean", - "sortDesc": true - }, - "tooltip": { - "hideZeros": false, - "mode": "single", - "sort": "none" - } - }, - "pluginVersion": "12.0.2", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "topk($top_n, sum by(schema, table_name, table_full_name) (irate(pgwatch_table_stats_n_tup_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\"}[$__rate_interval])))", - "fullMetaSearch": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "{{table_full_name}}", - "range": true, - "refId": "A", - "useBackend": false - } - ], - "title": "Top $top_n tables by updates/sec", + "title": "Top $top_n tables by tuples inserts per second", "type": "timeseries" }, { @@ -721,7 +613,7 @@ "links": [ { "title": "Table details", - "url": "/https/github.com/d/11-single-table-analysis/11-single-table-analysis?orgId=1&var-cluster_name=${cluster_name}&var-node_name=${node_name}&var-db_name=${db_name}&var-schema_name=${__field.labels.schema}&var-table_name=${__field.labels.table_name}" + "url": "/https/github.com/d/9-single-table-analysis/9-single-table-analysis?orgId=1&var-cluster_name=${cluster_name}&var-node_name=${node_name}&var-db_name=${db_name}&var-schema_name=${__field.labels.schema}&var-table_name=${__field.labels.table_name}" } ], "mappings": [], @@ -744,8 +636,8 @@ "gridPos": { "h": 10, "w": 12, - "x": 0, - "y": 38 + "x": 12, + "y": 28 }, "id": 5, "options": { @@ -786,7 +678,7 @@ "useBackend": false } ], - "title": "Top $top_n tables by deletes/sec", + "title": "Top $top_n tables by tuple deletes per second", "type": "timeseries" }, { @@ -805,6 +697,7 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", + "axisSoftMin": 0, "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", @@ -835,7 +728,7 @@ "links": [ { "title": "Table details", - "url": "/https/github.com/d/11-single-table-analysis/11-single-table-analysis?orgId=1&var-cluster_name=${cluster_name}&var-node_name=${node_name}&var-db_name=${db_name}&var-schema_name=${__field.labels.schema}&var-table_name=${__field.labels.table_name}" + "url": "/https/github.com/d/9-single-table-analysis/9-single-table-analysis?orgId=1&var-cluster_name=${cluster_name}&var-node_name=${node_name}&var-db_name=${db_name}&var-schema_name=${__field.labels.schema}&var-table_name=${__field.labels.table_name}" } ], "mappings": [], @@ -858,7 +751,7 @@ "gridPos": { "h": 10, "w": 12, - "x": 12, + "x": 0, "y": 38 }, "id": 6, @@ -900,7 +793,7 @@ "useBackend": false } ], - "title": "Top $top_n tables by HOT updates/sec", + "title": "Top $top_n tables by tuple HOT updates per second", "type": "timeseries" }, { @@ -949,7 +842,7 @@ "links": [ { "title": "Table details", - "url": "/https/github.com/d/11-single-table-analysis/11-single-table-analysis?orgId=1&var-cluster_name=${cluster_name}&var-node_name=${node_name}&var-db_name=${db_name}&var-schema_name=${__field.labels.schema}&var-table_name=${__field.labels.table_name}" + "url": "/https/github.com/d/9-single-table-analysis/9-single-table-analysis?orgId=1&var-cluster_name=${cluster_name}&var-node_name=${node_name}&var-db_name=${db_name}&var-schema_name=${__field.labels.schema}&var-table_name=${__field.labels.table_name}" } ], "mappings": [], @@ -972,8 +865,8 @@ "gridPos": { "h": 10, "w": 12, - "x": 0, - "y": 48 + "x": 12, + "y": 38 }, "id": 10, "options": { @@ -1014,7 +907,7 @@ "useBackend": false } ], - "title": "Top $top_n tables by Non-HOT updates/sec", + "title": "Top $top_n tables by tuple non-HOT updates per second", "type": "timeseries" }, { @@ -1026,7 +919,7 @@ "h": 3, "w": 24, "x": 0, - "y": 58 + "y": 48 }, "id": 20, "options": { @@ -1161,7 +1054,7 @@ }, "timepicker": {}, "timezone": "utc", - "title": "09. Top tables overview", + "title": "08. Aggregated tables analysis", "uid": "92657f2a-985b-4d1a-99ed-2fac6e0c53e2", - "version": 58 + "version": 76 } \ No newline at end of file diff --git a/config/grafana/dashboards/Dashboard_11_Single_table_analysis.json b/config/grafana/dashboards/Dashboard_9_Single_table_analysis.json similarity index 99% rename from config/grafana/dashboards/Dashboard_11_Single_table_analysis.json rename to config/grafana/dashboards/Dashboard_9_Single_table_analysis.json index 273b5e1..8124421 100644 --- a/config/grafana/dashboards/Dashboard_11_Single_table_analysis.json +++ b/config/grafana/dashboards/Dashboard_9_Single_table_analysis.json @@ -38,6 +38,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -135,6 +136,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -246,6 +248,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -349,6 +352,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -465,6 +469,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -725,6 +730,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1216,7 +1222,7 @@ }, "timepicker": {}, "timezone": "utc", - "title": "11. Single table analysis", - "uid": "11-single-table-analysis", + "title": "9. Single table analysis", + "uid": "9-single-table-analysis", "version": 5 } \ No newline at end of file From 3e2a7936e9b7c0a954d607fb321dba8896194fdb Mon Sep 17 00:00:00 2001 From: "dementii.priadko" <45518657+DEMNERD@users.noreply.github.com> Date: Wed, 24 Sep 2025 16:04:33 +0300 Subject: [PATCH 07/22] Renamed dashboard 9 to dashboard 09 --- .../grafana/dashboards/Dashboard_9_Single_table_analysis.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/grafana/dashboards/Dashboard_9_Single_table_analysis.json b/config/grafana/dashboards/Dashboard_9_Single_table_analysis.json index 8124421..6ada4c8 100644 --- a/config/grafana/dashboards/Dashboard_9_Single_table_analysis.json +++ b/config/grafana/dashboards/Dashboard_9_Single_table_analysis.json @@ -1222,7 +1222,7 @@ }, "timepicker": {}, "timezone": "utc", - "title": "9. Single table analysis", + "title": "09. Single table analysis", "uid": "9-single-table-analysis", "version": 5 } \ No newline at end of file From 05d791b1a90756d65cf7266dd86c911bdd11b9b0 Mon Sep 17 00:00:00 2001 From: "dementii.priadko" <45518657+DEMNERD@users.noreply.github.com> Date: Wed, 24 Sep 2025 19:27:11 +0300 Subject: [PATCH 08/22] Added pg_index_pilot rebuild threshold to single index analysis, modified names on single table analysis --- .../Dashboard_11_Single_index_analysis.json | 120 ++++++++++++++++-- .../Dashboard_9_Single_table_analysis.json | 27 ++-- 2 files changed, 124 insertions(+), 23 deletions(-) diff --git a/config/grafana/dashboards/Dashboard_11_Single_index_analysis.json b/config/grafana/dashboards/Dashboard_11_Single_index_analysis.json index fe9b309..4147164 100644 --- a/config/grafana/dashboards/Dashboard_11_Single_index_analysis.json +++ b/config/grafana/dashboards/Dashboard_11_Single_index_analysis.json @@ -18,7 +18,7 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, - "id": 10, + "id": 14, "links": [], "panels": [ { @@ -37,6 +37,7 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", + "axisSoftMin": 0, "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", @@ -82,7 +83,7 @@ { "matcher": { "id": "byName", - "options": "Baseline Boguk ratio" + "options": "Boguk ratio (index size / live tuples), baseline" }, "properties": [ { @@ -107,7 +108,7 @@ { "matcher": { "id": "byName", - "options": "Boguk ratio" + "options": "Boguk ratio (index size / live tuples), current" }, "properties": [ { @@ -118,6 +119,43 @@ } } ] + }, + { + "matcher": { + "id": "byName", + "options": "index_rebuild_scale_factor" + }, + "properties": [ + { + "id": "custom.lineWidth", + "value": 0 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "pg_index_pilot rebuild threshold " + }, + "properties": [ + { + "id": "custom.lineStyle", + "value": { + "dash": [ + 10, + 10 + ], + "fill": "dash" + } + }, + { + "id": "color", + "value": { + "fixedColor": "dark-orange", + "mode": "fixed" + } + } + ] } ] }, @@ -130,7 +168,11 @@ "id": 1, "options": { "legend": { - "calcs": [], + "calcs": [ + "min", + "max", + "mean" + ], "displayMode": "table", "placement": "bottom", "showLegend": true @@ -154,7 +196,7 @@ "fullMetaSearch": false, "includeNullMetadata": true, "interval": "", - "legendFormat": "Current Boguk ratio", + "legendFormat": "Boguk ratio (index size / live tuples), current", "range": true, "refId": "A", "useBackend": false @@ -168,12 +210,52 @@ "expr": "pgwatch_pg_index_pilot_best_ratio{indexrelname=\"$index_name\", schemaname=\"$schema_name\"}", "hide": false, "instant": false, - "legendFormat": "Baseline Boguk ratio", + "legendFormat": "Boguk ratio (index size / live tuples), baseline", "range": true, "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "editorMode": "code", + "expr": "max by () (\n last_over_time(pgwatch_pg_index_pilot_config_config_value_normalized{config_key=\"index_rebuild_scale_factor\", schemaname=~\"$schema_name\", indexrelname=~\"$index_name\", datname=~\"$datname\"}[1w]) * 8 or\n last_over_time(pgwatch_pg_index_pilot_config_config_value_normalized{config_key=\"index_rebuild_scale_factor\", schemaname=~\"$schema_name\", indexrelname=~\"$index_name\", datname=\"*\"}[1w]) * 7 or\n last_over_time(pgwatch_pg_index_pilot_config_config_value_normalized{config_key=\"index_rebuild_scale_factor\", schemaname=~\"$schema_name\", indexrelname=\"*\", datname=~\"$datname\"}[1w]) * 6 or\n last_over_time(pgwatch_pg_index_pilot_config_config_value_normalized{config_key=\"index_rebuild_scale_factor\", schemaname=\"*\", indexrelname=~\"$index_name\", datname=~\"$datname\"}[1w]) * 5 or\n last_over_time(pgwatch_pg_index_pilot_config_config_value_normalized{config_key=\"index_rebuild_scale_factor\", schemaname=\"*\", indexrelname=\"*\", datname=~\"$datname\"}[1w]) * 4 or\n last_over_time(pgwatch_pg_index_pilot_config_config_value_normalized{config_key=\"index_rebuild_scale_factor\", schemaname=~\"$schema_name\", indexrelname=\"*\", datname=\"*\"}[1w]) * 3 or\n last_over_time(pgwatch_pg_index_pilot_config_config_value_normalized{config_key=\"index_rebuild_scale_factor\", schemaname=\"*\", indexrelname=~\"$index_name\", datname=\"*\"}[1w]) * 2 or\n last_over_time(pgwatch_pg_index_pilot_config_config_value_normalized{config_key=\"index_rebuild_scale_factor\", schemaname=\"*\", indexrelname=\"*\", datname=\"*\"}[1w]) * 1\n) / \nmax by () (\n 8 * (last_over_time(pgwatch_pg_index_pilot_config_config_value_normalized{config_key=\"index_rebuild_scale_factor\", schemaname=~\"$schema_name\", indexrelname=~\"$index_name\", datname=~\"$datname\"}[1w]) * 0 + 1) or\n 7 * (last_over_time(pgwatch_pg_index_pilot_config_config_value_normalized{config_key=\"index_rebuild_scale_factor\", schemaname=~\"$schema_name\", indexrelname=~\"$index_name\", datname=\"*\"}[1w]) * 0 + 1) or\n 6 * (last_over_time(pgwatch_pg_index_pilot_config_config_value_normalized{config_key=\"index_rebuild_scale_factor\", schemaname=~\"$schema_name\", indexrelname=\"*\", datname=~\"$datname\"}[1w]) * 0 + 1) or\n 5 * (last_over_time(pgwatch_pg_index_pilot_config_config_value_normalized{config_key=\"index_rebuild_scale_factor\", schemaname=\"*\", indexrelname=~\"$index_name\", datname=~\"$datname\"}[1w]) * 0 + 1) or\n 4 * (last_over_time(pgwatch_pg_index_pilot_config_config_value_normalized{config_key=\"index_rebuild_scale_factor\", schemaname=\"*\", indexrelname=\"*\", datname=~\"$datname\"}[1w]) * 0 + 1) or\n 3 * (last_over_time(pgwatch_pg_index_pilot_config_config_value_normalized{config_key=\"index_rebuild_scale_factor\", schemaname=~\"$schema_name\", indexrelname=\"*\", datname=\"*\"}[1w]) * 0 + 1) or\n 2 * (last_over_time(pgwatch_pg_index_pilot_config_config_value_normalized{config_key=\"index_rebuild_scale_factor\", schemaname=\"*\", indexrelname=~\"$index_name\", datname=\"*\"}[1w]) * 0 + 1) or\n 1 * (last_over_time(pgwatch_pg_index_pilot_config_config_value_normalized{config_key=\"index_rebuild_scale_factor\", schemaname=\"*\", indexrelname=\"*\", datname=\"*\"}[1w]) * 0 + 1)\n)", + "hide": false, + "instant": false, + "legendFormat": "index_rebuild_scale_factor", + "range": true, + "refId": "C" } ], "title": "", + "transformations": [ + { + "id": "calculateField", + "options": { + "alias": "pg_index_pilot rebuild threshold ", + "binary": { + "left": { + "matcher": { + "id": "byName", + "options": "Boguk ratio (index size / live tuples), baseline" + } + }, + "operator": "*", + "right": { + "matcher": { + "id": "byName", + "options": "index_rebuild_scale_factor" + } + } + }, + "mode": "binary", + "reduce": { + "reducer": "sum" + } + } + } + ], "type": "timeseries" } ], @@ -182,6 +264,24 @@ "tags": [], "templating": { "list": [ + { + "current": { + "text": "workloaddb", + "value": "workloaddb" + }, + "definition": "label_values(pgwatch_pg_index_pilot_best_ratio,datname)", + "label": "DB name", + "name": "datname", + "options": [], + "query": { + "qryType": 1, + "query": "label_values(pgwatch_pg_index_pilot_best_ratio,datname)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 1, + "regex": "", + "type": "query" + }, { "current": { "text": "test_pilot", @@ -201,8 +301,8 @@ }, { "current": { - "text": "", - "value": "" + "text": "items_email_idx", + "value": "items_email_idx" }, "definition": "label_values(pgwatch_pg_index_pilot_estimated_tuples{schemaname=\"$schema_name\"},indexrelname)", "name": "index_name", @@ -219,12 +319,12 @@ ] }, "time": { - "from": "now-1h", + "from": "now-12h", "to": "now" }, "timepicker": {}, "timezone": "browser", "title": "11. Single index analysis", "uid": "aa0128c5-c5a0-4418-a99e-c941af10426e", - "version": 6 + "version": 4 } \ No newline at end of file diff --git a/config/grafana/dashboards/Dashboard_9_Single_table_analysis.json b/config/grafana/dashboards/Dashboard_9_Single_table_analysis.json index 6ada4c8..09dcfbd 100644 --- a/config/grafana/dashboards/Dashboard_9_Single_table_analysis.json +++ b/config/grafana/dashboards/Dashboard_9_Single_table_analysis.json @@ -18,7 +18,7 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 1, - "id": 12, + "id": 16, "links": [], "panels": [ { @@ -37,8 +37,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -116,7 +116,7 @@ "useBackend": false } ], - "title": "Table size", + "title": "Total table size", "type": "timeseries" }, { @@ -135,8 +135,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -215,7 +215,7 @@ "useBackend": false } ], - "title": "Table size change rate", + "title": "Table size change rate (absolute)", "type": "timeseries" }, { @@ -247,8 +247,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -314,7 +314,7 @@ }, "tooltip": { "hideZeros": false, - "mode": "single", + "mode": "multi", "sort": "none" } }, @@ -351,8 +351,9 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, + "axisSoftMax": 100, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -468,8 +469,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -596,7 +597,7 @@ }, "tooltip": { "hideZeros": false, - "mode": "single", + "mode": "multi", "sort": "none" } }, @@ -729,8 +730,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -857,7 +858,7 @@ }, "tooltip": { "hideZeros": false, - "mode": "single", + "mode": "multi", "sort": "none" } }, @@ -1224,5 +1225,5 @@ "timezone": "utc", "title": "09. Single table analysis", "uid": "9-single-table-analysis", - "version": 5 + "version": 8 } \ No newline at end of file From 8f616adf17ddddafe77511b8856762f433882195 Mon Sep 17 00:00:00 2001 From: "dementii.priadko" <45518657+DEMNERD@users.noreply.github.com> Date: Thu, 25 Sep 2025 16:28:33 +0300 Subject: [PATCH 09/22] Added softmin for all dashboards --- .../dashboards/Dashboard_10_Index health.json | 3 ++ .../Dashboard_11_Single_index_analysis.json | 1 + ...Dashboard_1_Node_performance_overview.json | 34 +++++++++++++++++++ ...Dashboard_2_Aggregated_query_analysis.json | 23 +++++++++++++ .../Dashboard_3_Single_query_analysis.json | 16 +++++++++ .../Dashboard_4_Wait_Sampling_Dashboard.json | 3 ++ .../dashboards/Dashboard_5_Backup_stats.json | 3 ++ .../Dashboard_7_Autovacuum_and_bloat.json | 1 + 8 files changed, 84 insertions(+) diff --git a/config/grafana/dashboards/Dashboard_10_Index health.json b/config/grafana/dashboards/Dashboard_10_Index health.json index ed0325e..27a0035 100644 --- a/config/grafana/dashboards/Dashboard_10_Index health.json +++ b/config/grafana/dashboards/Dashboard_10_Index health.json @@ -257,6 +257,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -377,6 +378,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -497,6 +499,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, diff --git a/config/grafana/dashboards/Dashboard_11_Single_index_analysis.json b/config/grafana/dashboards/Dashboard_11_Single_index_analysis.json index 4147164..48e5e89 100644 --- a/config/grafana/dashboards/Dashboard_11_Single_index_analysis.json +++ b/config/grafana/dashboards/Dashboard_11_Single_index_analysis.json @@ -39,6 +39,7 @@ "axisPlacement": "auto", "axisSoftMin": 0, "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, diff --git a/config/grafana/dashboards/Dashboard_1_Node_performance_overview.json b/config/grafana/dashboards/Dashboard_1_Node_performance_overview.json index c139904..c51116e 100644 --- a/config/grafana/dashboards/Dashboard_1_Node_performance_overview.json +++ b/config/grafana/dashboards/Dashboard_1_Node_performance_overview.json @@ -51,6 +51,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.5, "drawStyle": "bars", "fillOpacity": 40, @@ -338,6 +339,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -554,6 +556,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -786,6 +789,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -888,6 +892,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1027,6 +1032,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -1115,6 +1121,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1259,6 +1266,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1357,6 +1365,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1459,6 +1468,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1556,6 +1566,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1653,6 +1664,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1764,6 +1776,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1875,6 +1888,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1977,6 +1991,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2079,6 +2094,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2181,6 +2197,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2283,6 +2300,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2386,6 +2404,7 @@ "axisPlacement": "auto", "axisSoftMin": 0, "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2488,6 +2507,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2591,6 +2611,7 @@ "axisPlacement": "auto", "axisSoftMin": 0, "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2693,6 +2714,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2788,6 +2810,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2890,6 +2913,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2992,6 +3016,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -3095,6 +3120,7 @@ "axisPlacement": "auto", "axisSoftMin": 0, "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -3197,6 +3223,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -3312,6 +3339,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -3427,6 +3455,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.5, "drawStyle": "bars", "fillOpacity": 100, @@ -3566,6 +3595,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -3664,6 +3694,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -3760,6 +3791,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -3856,6 +3888,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -3988,6 +4021,7 @@ "axisSoftMax": 7, "axisSoftMin": 1, "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "points", "fillOpacity": 0, diff --git a/config/grafana/dashboards/Dashboard_2_Aggregated_query_analysis.json b/config/grafana/dashboards/Dashboard_2_Aggregated_query_analysis.json index ab91bf3..6f44cd5 100644 --- a/config/grafana/dashboards/Dashboard_2_Aggregated_query_analysis.json +++ b/config/grafana/dashboards/Dashboard_2_Aggregated_query_analysis.json @@ -467,6 +467,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -586,6 +587,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -704,6 +706,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -824,6 +827,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -942,6 +946,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -1062,6 +1067,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1181,6 +1187,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -1300,6 +1307,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1418,6 +1426,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -1538,6 +1547,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1656,6 +1666,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -1776,6 +1787,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1894,6 +1906,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -2014,6 +2027,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2132,6 +2146,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -2252,6 +2267,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2370,6 +2386,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -2488,6 +2505,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2606,6 +2624,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -2723,6 +2742,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2841,6 +2861,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -2959,6 +2980,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -3077,6 +3099,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, diff --git a/config/grafana/dashboards/Dashboard_3_Single_query_analysis.json b/config/grafana/dashboards/Dashboard_3_Single_query_analysis.json index 36e8742..4dc2fab 100644 --- a/config/grafana/dashboards/Dashboard_3_Single_query_analysis.json +++ b/config/grafana/dashboards/Dashboard_3_Single_query_analysis.json @@ -119,6 +119,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.5, "drawStyle": "bars", "fillOpacity": 40, @@ -355,6 +356,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -474,6 +476,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -592,6 +595,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -712,6 +716,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -831,6 +836,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -950,6 +956,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1068,6 +1075,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1188,6 +1196,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1306,6 +1315,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1424,6 +1434,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1541,6 +1552,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1658,6 +1670,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1776,6 +1789,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1894,6 +1908,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2012,6 +2027,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, diff --git a/config/grafana/dashboards/Dashboard_4_Wait_Sampling_Dashboard.json b/config/grafana/dashboards/Dashboard_4_Wait_Sampling_Dashboard.json index 93d4490..ededee7 100644 --- a/config/grafana/dashboards/Dashboard_4_Wait_Sampling_Dashboard.json +++ b/config/grafana/dashboards/Dashboard_4_Wait_Sampling_Dashboard.json @@ -38,6 +38,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.5, "drawStyle": "bars", "fillOpacity": 40, @@ -268,6 +269,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.5, "drawStyle": "bars", "fillOpacity": 40, @@ -472,6 +474,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.5, "drawStyle": "bars", "fillOpacity": 100, diff --git a/config/grafana/dashboards/Dashboard_5_Backup_stats.json b/config/grafana/dashboards/Dashboard_5_Backup_stats.json index 0102c3d..71b8457 100644 --- a/config/grafana/dashboards/Dashboard_5_Backup_stats.json +++ b/config/grafana/dashboards/Dashboard_5_Backup_stats.json @@ -38,6 +38,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "bars", "fillOpacity": 100, @@ -192,6 +193,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -287,6 +289,7 @@ "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, diff --git a/config/grafana/dashboards/Dashboard_7_Autovacuum_and_bloat.json b/config/grafana/dashboards/Dashboard_7_Autovacuum_and_bloat.json index 21b981e..70e1226 100644 --- a/config/grafana/dashboards/Dashboard_7_Autovacuum_and_bloat.json +++ b/config/grafana/dashboards/Dashboard_7_Autovacuum_and_bloat.json @@ -40,6 +40,7 @@ "axisSoftMax": 7, "axisSoftMin": 1, "barAlignment": 0, + "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "points", "fillOpacity": 0, From b93278e00cbdc4ac681ce61a0bdca079cad9690b Mon Sep 17 00:00:00 2001 From: "dementii.priadko" <45518657+DEMNERD@users.noreply.github.com> Date: Thu, 25 Sep 2025 16:43:14 +0300 Subject: [PATCH 10/22] Removed duplicates of softMin --- .../dashboards/Dashboard_1_Node_performance_overview.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/grafana/dashboards/Dashboard_1_Node_performance_overview.json b/config/grafana/dashboards/Dashboard_1_Node_performance_overview.json index c51116e..8a6b0f4 100644 --- a/config/grafana/dashboards/Dashboard_1_Node_performance_overview.json +++ b/config/grafana/dashboards/Dashboard_1_Node_performance_overview.json @@ -2404,7 +2404,6 @@ "axisPlacement": "auto", "axisSoftMin": 0, "barAlignment": 0, - "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2611,7 +2610,6 @@ "axisPlacement": "auto", "axisSoftMin": 0, "barAlignment": 0, - "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -3120,7 +3118,6 @@ "axisPlacement": "auto", "axisSoftMin": 0, "barAlignment": 0, - "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -4021,7 +4018,6 @@ "axisSoftMax": 7, "axisSoftMin": 1, "barAlignment": 0, - "axisSoftMin": 0, "barWidthFactor": 0.6, "drawStyle": "points", "fillOpacity": 0, From d88f9d7c8ee76c1940a209aa05a75eb3c54b0a9f Mon Sep 17 00:00:00 2001 From: "dementii.priadko" <45518657+DEMNERD@users.noreply.github.com> Date: Thu, 25 Sep 2025 22:09:22 +0300 Subject: [PATCH 11/22] Added table_size_detailed metric --- config/pgwatch-prometheus/metrics.yml | 93 +++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/config/pgwatch-prometheus/metrics.yml b/config/pgwatch-prometheus/metrics.yml index c32549e..31722b0 100644 --- a/config/pgwatch-prometheus/metrics.yml +++ b/config/pgwatch-prometheus/metrics.yml @@ -1315,6 +1315,98 @@ metrics: - is_na - reltuples statement_timeout_seconds: 300 + table_size_detailed: + description: > + This metric provides comprehensive table size analysis including the actual table size (main data fork only), + TOAST table size, index size, free space map (FSM) size, and visibility map (VM) size. + It helps administrators understand detailed storage breakdown for each table component. + sqls: + 11: |- + with table_sizes as ( + select + (extract(epoch from now()) * 1e9)::int8 as epoch_ns, + current_database() as tag_datname, + n.nspname as tag_schema, + c.relname as tag_table_name, + n.nspname || '.' || c.relname as tag_table_full_name, + c.oid as table_oid, + c.reltoastrelid, + -- Main table size components (bytes) + pg_relation_size(c.oid, 'main') as table_main_size_b, + pg_relation_size(c.oid, 'fsm') as table_fsm_size_b, + pg_relation_size(c.oid, 'vm') as table_vm_size_b, + pg_indexes_size(c.oid) as table_indexes_size_b, + -- TOAST table components (if exists) + case + when c.reltoastrelid != 0 then pg_relation_size(c.reltoastrelid, 'main') + else 0::int8 + end as toast_main_size_b, + case + when c.reltoastrelid != 0 then pg_relation_size(c.reltoastrelid, 'fsm') + else 0::int8 + end as toast_fsm_size_b, + case + when c.reltoastrelid != 0 then pg_relation_size(c.reltoastrelid, 'vm') + else 0::int8 + end as toast_vm_size_b, + case + when c.reltoastrelid != 0 then pg_indexes_size(c.reltoastrelid) + else 0::int8 + end as toast_indexes_size_b, + -- Calculated totals for reference + pg_table_size(c.oid) as table_total_size_b, + pg_total_relation_size(c.oid) as relation_total_size_b, + -- Size cardinality for grouping (logarithmic scale) + abs(greatest(ceil(log((pg_total_relation_size(c.oid) + 1) / 10 ^ 6)), 0))::text as tag_size_cardinality_mb + from pg_class c + join pg_namespace n on n.oid = c.relnamespace + where c.relkind in ('r', 'p') -- regular tables and partitioned tables + and n.nspname not in ('information_schema', 'pg_catalog', 'pg_toast') + and not exists ( + select 1 from pg_locks + where relation = c.oid and mode = 'AccessExclusiveLock' + ) + order by pg_total_relation_size(c.oid) desc + ) + select /* pgwatch_generated */ + epoch_ns, + tag_datname, + tag_schema, + tag_table_name, + tag_table_full_name, + tag_size_cardinality_mb, + table_main_size_b, + table_fsm_size_b, + table_vm_size_b, + table_indexes_size_b, + toast_main_size_b, + toast_fsm_size_b, + toast_vm_size_b, + toast_indexes_size_b, + table_total_size_b, + relation_total_size_b, + -- Additional calculated metrics + (table_main_size_b + toast_main_size_b) as actual_data_size_b, + (table_fsm_size_b + table_vm_size_b + toast_fsm_size_b + toast_vm_size_b) as metadata_size_b, + (table_indexes_size_b + toast_indexes_size_b) as total_indexes_size_b + from table_sizes + where table_main_size_b > 0 -- only include tables with actual data + order by relation_total_size_b desc + gauges: + - table_main_size_b + - table_fsm_size_b + - table_vm_size_b + - table_indexes_size_b + - toast_main_size_b + - toast_fsm_size_b + - toast_vm_size_b + - toast_indexes_size_b + - table_total_size_b + - relation_total_size_b + - actual_data_size_b + - metadata_size_b + - total_indexes_size_b + statement_timeout_seconds: 300 pg_invalid_indexes: description: > This metric identifies invalid indexes in the database. @@ -2030,6 +2122,7 @@ presets: pg_database_wraparound: 30 pg_xlog_position: 30 pg_table_bloat: 7200 + table_size_detailed: 300 pg_btree_bloat: 7200 pg_invalid_indexes: 7200 redundant_indexes: 10800 From eece21f36461770b9551c605d67b4a4408051288 Mon Sep 17 00:00:00 2001 From: "dementii.priadko" <45518657+DEMNERD@users.noreply.github.com> Date: Thu, 25 Sep 2025 22:25:30 +0300 Subject: [PATCH 12/22] Added total_toast_size_b metric --- config/pgwatch-prometheus/metrics.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/pgwatch-prometheus/metrics.yml b/config/pgwatch-prometheus/metrics.yml index 31722b0..dca375e 100644 --- a/config/pgwatch-prometheus/metrics.yml +++ b/config/pgwatch-prometheus/metrics.yml @@ -1388,7 +1388,8 @@ metrics: -- Additional calculated metrics (table_main_size_b + toast_main_size_b) as actual_data_size_b, (table_fsm_size_b + table_vm_size_b + toast_fsm_size_b + toast_vm_size_b) as metadata_size_b, - (table_indexes_size_b + toast_indexes_size_b) as total_indexes_size_b + (table_indexes_size_b + toast_indexes_size_b) as total_indexes_size_b, + (toast_main_size_b + toast_fsm_size_b + toast_vm_size_b + toast_indexes_size_b) as total_toast_size_b from table_sizes where table_main_size_b > 0 -- only include tables with actual data order by relation_total_size_b desc @@ -1406,6 +1407,7 @@ metrics: - actual_data_size_b - metadata_size_b - total_indexes_size_b + - total_toast_size_b statement_timeout_seconds: 300 pg_invalid_indexes: description: > From f636efb25db1f424d833c876628dc0e32e714460 Mon Sep 17 00:00:00 2001 From: "dementii.priadko" <45518657+DEMNERD@users.noreply.github.com> Date: Thu, 25 Sep 2025 22:31:25 +0300 Subject: [PATCH 13/22] Made table_size_detailed more often --- config/pgwatch-prometheus/metrics.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/pgwatch-prometheus/metrics.yml b/config/pgwatch-prometheus/metrics.yml index dca375e..aad1110 100644 --- a/config/pgwatch-prometheus/metrics.yml +++ b/config/pgwatch-prometheus/metrics.yml @@ -2124,7 +2124,7 @@ presets: pg_database_wraparound: 30 pg_xlog_position: 30 pg_table_bloat: 7200 - table_size_detailed: 300 + table_size_detailed: 30 pg_btree_bloat: 7200 pg_invalid_indexes: 7200 redundant_indexes: 10800 From 0c17f81b55032eb9660437e4e6debe286f0960cf Mon Sep 17 00:00:00 2001 From: "dementii.priadko" <45518657+DEMNERD@users.noreply.github.com> Date: Fri, 26 Sep 2025 02:17:31 +0300 Subject: [PATCH 14/22] Updated table stats backend, modified table_size_detailed query --- config/pgwatch-prometheus/metrics.yml | 68 +++++++++---------------- flask-backend/app.py | 71 ++++++++++++++++++++++----- 2 files changed, 80 insertions(+), 59 deletions(-) diff --git a/config/pgwatch-prometheus/metrics.yml b/config/pgwatch-prometheus/metrics.yml index aad1110..0c1433e 100644 --- a/config/pgwatch-prometheus/metrics.yml +++ b/config/pgwatch-prometheus/metrics.yml @@ -285,7 +285,7 @@ metrics: from pg_locks where - pid != pg_backend_pid() + pid <> pg_backend_pid() and database = (select oid from pg_database where datname = current_database()) limit 5000 ) @@ -368,7 +368,7 @@ metrics: category as tag_category, vartype as tag_vartype, case when setting ~ '^-?[0-9]+$' then setting::bigint else null end as numeric_value, - case when source != 'default' then 0 else 1 end as is_default, + case when source <> 'default' then 0 else 1 end as is_default, 1 as configured from pg_settings gauges: @@ -390,7 +390,7 @@ metrics: from pg_class c join pg_namespace n on n.oid = c.relnamespace where relkind in ('p', 'r') - and relpersistence != 't' + and relpersistence <> 't' and not n.nspname like any (array[E'pg\\_%', 'information_schema', E'\\_timescaledb%']) and not exists(select * from pg_inherits where inhrelid = c.oid) and exists(select * from pg_inherits where inhparent = c.oid) @@ -414,7 +414,7 @@ metrics: pg_table_size(relid) as table_size_b, abs(greatest(ceil(log((pg_table_size(relid) + 1) / 10 ^ 6)), 0))::text as tag_table_size_cardinality_mb, -- i.e. 0=<1MB, 1=<10MB, 2=<100MB,.. pg_total_relation_size(relid) as total_relation_size_b, - case when reltoastrelid != 0 then pg_total_relation_size(reltoastrelid) else 0::int8 end as toast_size_b, + case when reltoastrelid <> 0 then pg_total_relation_size(reltoastrelid) else 0::int8 end as toast_size_b, (extract(epoch from now() - greatest(last_vacuum, last_autovacuum)))::int8 as seconds_since_last_vacuum, (extract(epoch from now() - greatest(last_analyze, last_autoanalyze)))::int8 as seconds_since_last_analyze, case when 'autovacuum_enabled=off' = ANY (c.reloptions) then 1 else 0 end as no_autovacuum, @@ -432,14 +432,14 @@ metrics: autovacuum_count, analyze_count, autoanalyze_count, - case when c.relkind != 'p' then age(c.relfrozenxid) else 0 end as tx_freeze_age + case when c.relkind <> 'p' then age(c.relfrozenxid) else 0 end as tx_freeze_age from pg_stat_user_tables ut join pg_class c on c.oid = ut.relid where -- leaving out fully locked tables as pg_relation_size also wants a lock and would wait not exists(select 1 from pg_locks where relation = relid and mode = 'AccessExclusiveLock') - and c.relpersistence != 't' -- and temp tables + and c.relpersistence <> 't' -- and temp tables ) select /* pgwatch_generated */ @@ -526,7 +526,7 @@ metrics: from pg_class c join pg_namespace n on n.oid = c.relnamespace where relkind in ('p', 'r') - and relpersistence != 't' + and relpersistence <> 't' and not n.nspname like any (array[E'pg\\_%', 'information_schema', E'\\_timescaledb%']) and not exists(select * from pg_inherits where inhrelid = c.oid) and exists(select * from pg_inherits where inhparent = c.oid) @@ -550,7 +550,7 @@ metrics: pg_table_size(relid) as table_size_b, abs(greatest(ceil(log((pg_table_size(relid) + 1) / 10 ^ 6)), 0))::text as tag_table_size_cardinality_mb, -- i.e. 0=<1MB, 1=<10MB, 2=<100MB,.. pg_total_relation_size(relid) as total_relation_size_b, - case when c.reltoastrelid != 0 then pg_total_relation_size(c.reltoastrelid) else 0::int8 end as toast_size_b, + case when c.reltoastrelid <> 0 then pg_total_relation_size(c.reltoastrelid) else 0::int8 end as toast_size_b, (extract(epoch from now() - greatest(last_vacuum, last_autovacuum)))::int8 as seconds_since_last_vacuum, (extract(epoch from now() - greatest(last_analyze, last_autoanalyze)))::int8 as seconds_since_last_analyze, case when 'autovacuum_enabled=off' = ANY (c.reloptions) then 1 else 0 end as no_autovacuum, @@ -568,7 +568,7 @@ metrics: autovacuum_count, analyze_count, autoanalyze_count, - case when c.relkind != 'p' then age(c.relfrozenxid) else 0 end as tx_freeze_age, + case when c.relkind <> 'p' then age(c.relfrozenxid) else 0 end as tx_freeze_age, extract(epoch from now() - last_seq_scan)::int8 as last_seq_scan_s from pg_stat_user_tables ut join pg_class c on c.oid = ut.relid @@ -578,7 +578,7 @@ metrics: where -- leaving out fully locked tables as pg_relation_size also wants a lock and would wait not exists (select 1 from pg_locks where relation = relid and mode = 'AccessExclusiveLock') - and c.relpersistence != 't' -- and temp tables + and c.relpersistence <> 't' -- and temp tables order by case when c.relkind = 'p' then 1e9::int else coalesce(c.relpages, 0) + coalesce(t.relpages, 0) + coalesce(tir.relpages, 0) end desc limit 1500 /* NB! When changing the bottom final LIMIT also adjust this limit. Should be at least 5x bigger as approx sizes depend a lot on vacuum frequency. The general idea is to reduce filesystem "stat"-ing on tables that won't make it to final output anyways based on approximate size */ @@ -1328,7 +1328,6 @@ metrics: current_database() as tag_datname, n.nspname as tag_schema, c.relname as tag_table_name, - n.nspname || '.' || c.relname as tag_table_full_name, c.oid as table_oid, c.reltoastrelid, -- Main table size components (bytes) @@ -1336,32 +1335,17 @@ metrics: pg_relation_size(c.oid, 'fsm') as table_fsm_size_b, pg_relation_size(c.oid, 'vm') as table_vm_size_b, pg_indexes_size(c.oid) as table_indexes_size_b, - -- TOAST table components (if exists) - case - when c.reltoastrelid != 0 then pg_relation_size(c.reltoastrelid, 'main') - else 0::int8 - end as toast_main_size_b, - case - when c.reltoastrelid != 0 then pg_relation_size(c.reltoastrelid, 'fsm') - else 0::int8 - end as toast_fsm_size_b, - case - when c.reltoastrelid != 0 then pg_relation_size(c.reltoastrelid, 'vm') - else 0::int8 - end as toast_vm_size_b, - case - when c.reltoastrelid != 0 then pg_indexes_size(c.reltoastrelid) - else 0::int8 - end as toast_indexes_size_b, - -- Calculated totals for reference - pg_table_size(c.oid) as table_total_size_b, - pg_total_relation_size(c.oid) as relation_total_size_b, - -- Size cardinality for grouping (logarithmic scale) + pg_relation_size(c.reltoastrelid, 'main') as toast_main_size_b, + pg_relation_size(c.reltoastrelid, 'fsm') as toast_fsm_size_b, + pg_relation_size(c.reltoastrelid, 'vm') as toast_vm_size_b, + pg_indexes_size(c.reltoastrelid) as toast_indexes_size_b, + pg_total_relation_size(c.reltoastrelid) as toast_total_size_b, + pg_total_relation_size(c.oid) as total_relation_size_b, abs(greatest(ceil(log((pg_total_relation_size(c.oid) + 1) / 10 ^ 6)), 0))::text as tag_size_cardinality_mb from pg_class c join pg_namespace n on n.oid = c.relnamespace - where c.relkind in ('r', 'p') -- regular tables and partitioned tables - and n.nspname not in ('information_schema', 'pg_catalog', 'pg_toast') + where c.relkind in ('r', 'p', 'm') -- regular tables, partitioned tables, materialized views + and n.nspname not in ('information_schema', 'pg_toast') and not exists ( select 1 from pg_locks where relation = c.oid and mode = 'AccessExclusiveLock' @@ -1373,7 +1357,6 @@ metrics: tag_datname, tag_schema, tag_table_name, - tag_table_full_name, tag_size_cardinality_mb, table_main_size_b, table_fsm_size_b, @@ -1383,16 +1366,10 @@ metrics: toast_fsm_size_b, toast_vm_size_b, toast_indexes_size_b, - table_total_size_b, - relation_total_size_b, - -- Additional calculated metrics - (table_main_size_b + toast_main_size_b) as actual_data_size_b, - (table_fsm_size_b + table_vm_size_b + toast_fsm_size_b + toast_vm_size_b) as metadata_size_b, - (table_indexes_size_b + toast_indexes_size_b) as total_indexes_size_b, + total_relation_size_b, (toast_main_size_b + toast_fsm_size_b + toast_vm_size_b + toast_indexes_size_b) as total_toast_size_b from table_sizes - where table_main_size_b > 0 -- only include tables with actual data - order by relation_total_size_b desc + where total_relation_size_b > 0 gauges: - table_main_size_b - table_fsm_size_b @@ -1402,13 +1379,12 @@ metrics: - toast_fsm_size_b - toast_vm_size_b - toast_indexes_size_b - - table_total_size_b - - relation_total_size_b + - total_relation_size_b - actual_data_size_b - metadata_size_b - total_indexes_size_b - total_toast_size_b - statement_timeout_seconds: 300 + statement_timeout_seconds: 15 pg_invalid_indexes: description: > This metric identifies invalid indexes in the database. diff --git a/flask-backend/app.py b/flask-backend/app.py index 4279530..45ba5c2 100644 --- a/flask-backend/app.py +++ b/flask-backend/app.py @@ -484,10 +484,11 @@ def get_btree_bloat_csv(): logger.error(f"Error processing btree bloat request: {e}") return jsonify({"error": str(e)}), 500 -@app.route('/table_bloat/csv', methods=['GET']) -def get_table_bloat_csv(): +@app.route('/table_info/csv', methods=['GET']) +def get_table_info_csv(): """ - Get the most recent pg_table_bloat metrics as a CSV table. + Get comprehensive table information including bloat metrics and detailed size information as a CSV table. + Combines pg_table_bloat and table_size_detailed metrics for complete table analysis. """ try: # Get query parameters @@ -513,7 +514,9 @@ def get_table_bloat_csv(): filter_str = '{' + ','.join(filters) + '}' if filters else '' # Metrics to fetch with last_over_time to get only the most recent value + # Include both bloat metrics and detailed size metrics metric_queries = [ + # Bloat metrics f'last_over_time(pgwatch_pg_table_bloat_real_size_mib{filter_str}[1d])', f'last_over_time(pgwatch_pg_table_bloat_extra_size{filter_str}[1d])', f'last_over_time(pgwatch_pg_table_bloat_extra_pct{filter_str}[1d])', @@ -521,6 +524,17 @@ def get_table_bloat_csv(): f'last_over_time(pgwatch_pg_table_bloat_bloat_size{filter_str}[1d])', f'last_over_time(pgwatch_pg_table_bloat_bloat_pct{filter_str}[1d])', f'last_over_time(pgwatch_pg_table_bloat_is_na{filter_str}[1d])', + # Detailed size metrics + f'last_over_time(pgwatch_table_size_detailed_table_main_size_b{filter_str}[1d])', + f'last_over_time(pgwatch_table_size_detailed_table_fsm_size_b{filter_str}[1d])', + f'last_over_time(pgwatch_table_size_detailed_table_vm_size_b{filter_str}[1d])', + f'last_over_time(pgwatch_table_size_detailed_table_indexes_size_b{filter_str}[1d])', + f'last_over_time(pgwatch_table_size_detailed_toast_main_size_b{filter_str}[1d])', + f'last_over_time(pgwatch_table_size_detailed_toast_fsm_size_b{filter_str}[1d])', + f'last_over_time(pgwatch_table_size_detailed_toast_vm_size_b{filter_str}[1d])', + f'last_over_time(pgwatch_table_size_detailed_toast_indexes_size_b{filter_str}[1d])', + f'last_over_time(pgwatch_table_size_detailed_total_relation_size_b{filter_str}[1d])', + f'last_over_time(pgwatch_table_size_detailed_total_toast_size_b{filter_str}[1d])', ] prom = get_prometheus_client() @@ -542,20 +556,45 @@ def get_table_bloat_csv(): 'schemaname': metric_labels.get('schemaname', ''), 'tblname': metric_labels.get('tblname', ''), } + value = float(entry['value'][1]) + + # Bloat metrics if 'real_size_mib' in query: - metric_results[key]['real_size_mib'] = float(entry['value'][1]) + metric_results[key]['real_size_mib'] = value elif 'extra_size' in query and 'extra_pct' not in query: - metric_results[key]['extra_size'] = float(entry['value'][1]) + metric_results[key]['extra_size'] = value elif 'extra_pct' in query: - metric_results[key]['extra_pct'] = float(entry['value'][1]) + metric_results[key]['extra_pct'] = value elif 'fillfactor' in query: - metric_results[key]['fillfactor'] = float(entry['value'][1]) + metric_results[key]['fillfactor'] = value elif 'bloat_size' in query: - metric_results[key]['bloat_size'] = float(entry['value'][1]) + metric_results[key]['bloat_size'] = value elif 'bloat_pct' in query: - metric_results[key]['bloat_pct'] = float(entry['value'][1]) + metric_results[key]['bloat_pct'] = value elif 'is_na' in query: - metric_results[key]['is_na'] = int(float(entry['value'][1])) + metric_results[key]['is_na'] = int(value) + + # Size metrics (convert bytes to MiB for consistency) + elif 'table_main_size_b' in query: + metric_results[key]['table_main_size_mib'] = value / (1024 * 1024) + elif 'table_fsm_size_b' in query: + metric_results[key]['table_fsm_size_mib'] = value / (1024 * 1024) + elif 'table_vm_size_b' in query: + metric_results[key]['table_vm_size_mib'] = value / (1024 * 1024) + elif 'table_indexes_size_b' in query: + metric_results[key]['table_indexes_size_mib'] = value / (1024 * 1024) + elif 'toast_main_size_b' in query: + metric_results[key]['toast_main_size_mib'] = value / (1024 * 1024) + elif 'toast_fsm_size_b' in query: + metric_results[key]['toast_fsm_size_mib'] = value / (1024 * 1024) + elif 'toast_vm_size_b' in query: + metric_results[key]['toast_vm_size_mib'] = value / (1024 * 1024) + elif 'toast_indexes_size_b' in query: + metric_results[key]['toast_indexes_size_mib'] = value / (1024 * 1024) + elif 'total_relation_size_b' in query: + metric_results[key]['total_relation_size_mib'] = value / (1024 * 1024) + elif 'total_toast_size_b' in query: + metric_results[key]['total_toast_size_mib'] = value / (1024 * 1024) except Exception as e: logger.warning(f"Failed to query: {query}, error: {e}") continue @@ -564,8 +603,14 @@ def get_table_bloat_csv(): output = io.StringIO() fieldnames = [ 'database', 'schemaname', 'tblname', + # Bloat metrics 'real_size_mib', 'extra_size', 'extra_pct', 'fillfactor', - 'bloat_size', 'bloat_pct', 'is_na' + 'bloat_size', 'bloat_pct', 'is_na', + # Size metrics (all in MiB) + 'table_main_size_mib', 'table_fsm_size_mib', 'table_vm_size_mib', + 'table_indexes_size_mib', 'toast_main_size_mib', 'toast_fsm_size_mib', + 'toast_vm_size_mib', 'toast_indexes_size_mib', 'total_relation_size_mib', + 'total_toast_size_mib' ] writer = csv.DictWriter(output, fieldnames=fieldnames) writer.writeheader() @@ -578,11 +623,11 @@ def get_table_bloat_csv(): # Create response response = make_response(csv_content) response.headers['Content-Type'] = 'text/csv' - response.headers['Content-Disposition'] = 'attachment; filename=table_bloat_latest.csv' + response.headers['Content-Disposition'] = 'attachment; filename=table_info_latest.csv' return response except Exception as e: - logger.error(f"Error processing table bloat request: {e}") + logger.error(f"Error processing table info request: {e}") return jsonify({"error": str(e)}), 500 if __name__ == '__main__': From 78dfd22d87e14a3c5d0ac4cc9a66beac414e4c0a Mon Sep 17 00:00:00 2001 From: "dementii.priadko" <45518657+DEMNERD@users.noreply.github.com> Date: Fri, 26 Sep 2025 02:18:07 +0300 Subject: [PATCH 15/22] Modified dashboards 1 and 8 (added table + tuple stats) --- ...Dashboard_1_Node_performance_overview.json | 274 ++++++- .../dashboards/Dashboard_8_Table_Stats.json | 671 +++++++++++++++++- 2 files changed, 882 insertions(+), 63 deletions(-) diff --git a/config/grafana/dashboards/Dashboard_1_Node_performance_overview.json b/config/grafana/dashboards/Dashboard_1_Node_performance_overview.json index 8a6b0f4..bf5bc20 100644 --- a/config/grafana/dashboards/Dashboard_1_Node_performance_overview.json +++ b/config/grafana/dashboards/Dashboard_1_Node_performance_overview.json @@ -18,7 +18,7 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 1, - "id": 8, + "id": 10, "links": [], "panels": [ { @@ -50,8 +50,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.5, "drawStyle": "bars", "fillOpacity": 40, @@ -338,8 +338,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -555,8 +555,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -788,8 +788,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -891,8 +891,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1031,8 +1031,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -1120,8 +1120,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1265,8 +1265,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1364,8 +1364,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1467,8 +1467,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1565,8 +1565,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1663,8 +1663,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1775,8 +1775,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1887,8 +1887,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -1990,8 +1990,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2093,8 +2093,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2196,8 +2196,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2299,8 +2299,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2505,8 +2505,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2711,8 +2711,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2807,8 +2807,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -2910,8 +2910,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -3013,8 +3013,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -3219,8 +3219,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -3335,8 +3335,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -3451,8 +3451,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.5, "drawStyle": "bars", "fillOpacity": 100, @@ -3591,8 +3591,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -3690,8 +3690,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 100, @@ -3787,8 +3787,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -3884,8 +3884,8 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", - "barAlignment": 0, "axisSoftMin": 0, + "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, @@ -3999,6 +3999,202 @@ "title": "bgwriter and checkpointer", "type": "timeseries" }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Total" + }, + "properties": [ + { + "id": "custom.stacking", + "value": { + "group": "A", + "mode": "none" + } + }, + { + "id": "custom.fillOpacity", + "value": 0 + } + ] + } + ] + }, + "gridPos": { + "h": 14, + "w": 24, + "x": 0, + "y": 159 + }, + "id": 44, + "options": { + "legend": { + "calcs": [ + "last" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Last", + "sortDesc": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "sum(pgwatch_table_size_detailed_total_toast_size_b{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"})", + "fullMetaSearch": false, + "includeNullMetadata": true, + "legendFormat": "TOAST", + "range": true, + "refId": "A", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "sum(pgwatch_table_size_detailed_table_main_size_b{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"})", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "Tables (w/o TOAST)", + "range": true, + "refId": "B", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "sum(pgwatch_table_size_detailed_table_indexes_size_b{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"})", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "Indexes", + "range": true, + "refId": "C", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "sum(pgwatch_table_size_detailed_table_vm_size_b{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"})", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "Visibility maps", + "range": true, + "refId": "D", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "sum(pgwatch_table_size_detailed_table_fsm_size_b{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"})", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "Free space maps", + "range": true, + "refId": "E", + "useBackend": false + } + ], + "title": "DB logical size distribution", + "transformations": [ + { + "id": "calculateField", + "options": {} + } + ], + "type": "timeseries" + }, { "datasource": { "type": "prometheus", @@ -4095,7 +4291,7 @@ "h": 11, "w": 24, "x": 0, - "y": 159 + "y": 173 }, "id": 42, "options": { @@ -4140,7 +4336,7 @@ "h": 3, "w": 24, "x": 0, - "y": 170 + "y": 184 }, "id": 40, "options": { @@ -4182,8 +4378,8 @@ }, { "current": { - "text": "prod-db", - "value": "prod-db" + "text": "postgres_ai", + "value": "postgres_ai" }, "definition": "label_values(pgwatch_settings_configured{cluster=\"$cluster_name\"},node_name)", "label": "Node name", @@ -4200,8 +4396,8 @@ }, { "current": { - "text": "postgres", - "value": "postgres" + "text": "workloaddb", + "value": "workloaddb" }, "definition": "label_values(pgwatch_pg_database_wraparound_age_datfrozenxid{cluster=\"$cluster_name\", node_name=\"$node_name\", datname!=\"template1\"},datname)", "label": "DB name", @@ -4219,12 +4415,12 @@ ] }, "time": { - "from": "now-2d", + "from": "now-30m", "to": "now" }, "timepicker": {}, "timezone": "utc", "title": "01. Single node performance overview (high-level)", "uid": "f90500a0-a12e-4081-a2f0-07ed96f27915", - "version": 7 + "version": 13 } \ No newline at end of file diff --git a/config/grafana/dashboards/Dashboard_8_Table_Stats.json b/config/grafana/dashboards/Dashboard_8_Table_Stats.json index 2a75c91..c9066f3 100644 --- a/config/grafana/dashboards/Dashboard_8_Table_Stats.json +++ b/config/grafana/dashboards/Dashboard_8_Table_Stats.json @@ -18,9 +18,428 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 1, - "id": 9, + "id": 15, "links": [], "panels": [ + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 27, + "panels": [], + "title": "Size Stats", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 13, + "w": 12, + "x": 0, + "y": 1 + }, + "id": 1, + "options": { + "legend": { + "calcs": [ + "last" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, pgwatch_pg_class_total_relation_size_bytes{relkind=\"114\", schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"})", + "fullMetaSearch": false, + "includeNullMetadata": true, + "legendFormat": "{{schemaname}}.{{relname}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by total size", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 13, + "w": 12, + "x": 12, + "y": 1 + }, + "id": 7, + "options": { + "legend": { + "calcs": [ + "last" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Last", + "sortDesc": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, irate(pgwatch_pg_class_total_relation_size_bytes{relkind=\"114\", schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "20", + "legendFormat": "{{schemaname}}.{{relname}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by size change rate (absolute)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 13, + "w": 12, + "x": 0, + "y": 14 + }, + "id": 23, + "options": { + "legend": { + "calcs": [ + "last" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Last", + "sortDesc": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "pgwatch_table_size_detailed_table_main_size_b{schema=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}", + "fullMetaSearch": false, + "includeNullMetadata": true, + "legendFormat": "{{schema}}.{{table_name}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by table (w/o TOAST) size", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 13, + "w": 12, + "x": 12, + "y": 14 + }, + "id": 24, + "options": { + "legend": { + "calcs": [ + "last" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Last", + "sortDesc": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, irate(pgwatch_table_size_detailed_table_main_size_b{schema=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "20", + "legendFormat": "{{schema}}.{{table_name}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by table (w/o TOAST) size change rate (absolute)", + "type": "timeseries" + }, { "datasource": { "type": "prometheus", @@ -86,9 +505,9 @@ "h": 13, "w": 12, "x": 0, - "y": 0 + "y": 27 }, - "id": 1, + "id": 28, "options": { "legend": { "calcs": [ @@ -111,16 +530,16 @@ { "disableTextWrap": false, "editorMode": "code", - "expr": "topk($top_n, pgwatch_pg_class_total_relation_size_bytes{relkind=\"114\", schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"})", + "expr": "pgwatch_table_size_detailed_toast_indexes_size_b{schema=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}", "fullMetaSearch": false, "includeNullMetadata": true, - "legendFormat": "{{schemaname}}.{{relname}}", + "legendFormat": "{{schema}}.{{table_name}}", "range": true, "refId": "A", "useBackend": false } ], - "title": "Top $top_n tables by size", + "title": "Top $top_n tables by TOAST size", "type": "timeseries" }, { @@ -187,9 +606,9 @@ "h": 13, "w": 12, "x": 12, - "y": 0 + "y": 27 }, - "id": 7, + "id": 29, "options": { "legend": { "calcs": [ @@ -212,17 +631,221 @@ { "disableTextWrap": false, "editorMode": "code", - "expr": "topk($top_n, irate(pgwatch_pg_class_total_relation_size_bytes{relkind=\"114\", schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "expr": "topk($top_n, irate(pgwatch_table_size_detailed_total_toast_size_b{schema=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", "fullMetaSearch": false, "includeNullMetadata": true, "interval": "20", - "legendFormat": "{{schemaname}}.{{relname}}", + "legendFormat": "{{schema}}.{{table_name}}", "range": true, "refId": "A", "useBackend": false } ], - "title": "Top $top_n tables by size change rate (absolute)", + "title": "Top $top_n tables by TOAST size change rate (absolute)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 13, + "w": 12, + "x": 0, + "y": 40 + }, + "id": 25, + "options": { + "legend": { + "calcs": [ + "last" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Last", + "sortDesc": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, pgwatch_table_size_detailed_table_indexes_size_b\n{schema=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"})", + "fullMetaSearch": false, + "includeNullMetadata": true, + "legendFormat": "{{schema}}.{{table_name}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by index size", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 13, + "w": 12, + "x": 12, + "y": 40 + }, + "id": 26, + "options": { + "legend": { + "calcs": [ + "last" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Last", + "sortDesc": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, irate(pgwatch_table_size_detailed_table_indexes_size_b{schema=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "20", + "legendFormat": "{{schema}}.{{table_name}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by index size change rate (absolute)", "type": "timeseries" }, { @@ -231,7 +854,7 @@ "h": 1, "w": 24, "x": 0, - "y": 13 + "y": 53 }, "id": 22, "panels": [], @@ -304,7 +927,7 @@ "h": 13, "w": 12, "x": 0, - "y": 14 + "y": 54 }, "id": 8, "options": { @@ -408,7 +1031,7 @@ "h": 13, "w": 12, "x": 12, - "y": 14 + "y": 54 }, "id": 2, "options": { @@ -453,7 +1076,7 @@ "h": 1, "w": 24, "x": 0, - "y": 27 + "y": 67 }, "id": 11, "panels": [], @@ -489,7 +1112,7 @@ "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, - "pointSize": 5, + "pointSize": 1, "scaleDistribution": { "type": "linear" }, @@ -523,7 +1146,7 @@ "h": 10, "w": 12, "x": 0, - "y": 28 + "y": 68 }, "id": 3, "options": { @@ -637,7 +1260,7 @@ "h": 10, "w": 12, "x": 12, - "y": 28 + "y": 68 }, "id": 5, "options": { @@ -752,7 +1375,7 @@ "h": 10, "w": 12, "x": 0, - "y": 38 + "y": 78 }, "id": 6, "options": { @@ -866,7 +1489,7 @@ "h": 10, "w": 12, "x": 12, - "y": 38 + "y": 78 }, "id": 10, "options": { @@ -919,7 +1542,7 @@ "h": 3, "w": 24, "x": 0, - "y": 48 + "y": 88 }, "id": 20, "options": { @@ -997,8 +1620,8 @@ }, { "current": { - "text": "All", - "value": "$__all" + "text": "test_pilot", + "value": "test_pilot" }, "definition": "label_values(pgwatch_pg_class_relation_size_bytes,schemaname)", "includeAll": true, @@ -1056,5 +1679,5 @@ "timezone": "utc", "title": "08. Aggregated tables analysis", "uid": "92657f2a-985b-4d1a-99ed-2fac6e0c53e2", - "version": 76 + "version": 19 } \ No newline at end of file From 859d202415ccd9551d0533cef996664ed2f59a75 Mon Sep 17 00:00:00 2001 From: "dementii.priadko" <45518657+DEMNERD@users.noreply.github.com> Date: Fri, 26 Sep 2025 02:59:47 +0300 Subject: [PATCH 16/22] Added pg_statio_all_tables metric --- config/pgwatch-prometheus/metrics.yml | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/config/pgwatch-prometheus/metrics.yml b/config/pgwatch-prometheus/metrics.yml index 0c1433e..350db30 100644 --- a/config/pgwatch-prometheus/metrics.yml +++ b/config/pgwatch-prometheus/metrics.yml @@ -2068,6 +2068,34 @@ metrics: gauges: - config_value_normalized + pg_statio_all_tables: + description: > + Retrieves table-level I/O statistics from the PostgreSQL `pg_statio_all_tables` view, providing insights into I/O operations for all tables. + It returns block-level read and hit statistics for heap, index, TOAST, and TOAST index operations broken down by schema and table. + This metric helps administrators monitor table-level I/O performance and identify which tables are generating the most I/O activity. + Compatible with all PostgreSQL versions. + sqls: + 11: |- + select /* pgwatch_generated */ + (extract(epoch from now()) * 1e9)::int8 as epoch_ns, + current_database() as tag_datname, + schemaname as tag_schemaname, + relname as tag_relname, + heap_blks_read, + heap_blks_hit, + idx_blks_read, + idx_blks_hit, + toast_blks_read, + toast_blks_hit, + tidx_blks_read, + tidx_blks_hit + from + pg_statio_all_tables + where + heap_blks_read > 0 or idx_blks_read > 0 or toast_blks_read > 0 or tidx_blks_read > 0 + gauges: + - '*' + presets: full: @@ -2092,6 +2120,7 @@ presets: pg_stat_user_indexes: 30 pg_stat_statements: 30 pg_stat_replication: 30 + pg_statio_all_tables: 30 pg_total_relation_size: 30 pg_blocked: 30 pg_long_running_transactions: 30 From fad356a3293684c12c4915baf1083de43da715ca Mon Sep 17 00:00:00 2001 From: "dementii.priadko" <45518657+DEMNERD@users.noreply.github.com> Date: Fri, 26 Sep 2025 03:10:08 +0300 Subject: [PATCH 17/22] Added io stats to the backend --- flask-backend/app.py | 70 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 4 deletions(-) diff --git a/flask-backend/app.py b/flask-backend/app.py index 45ba5c2..9580158 100644 --- a/flask-backend/app.py +++ b/flask-backend/app.py @@ -487,8 +487,8 @@ def get_btree_bloat_csv(): @app.route('/table_info/csv', methods=['GET']) def get_table_info_csv(): """ - Get comprehensive table information including bloat metrics and detailed size information as a CSV table. - Combines pg_table_bloat and table_size_detailed metrics for complete table analysis. + Get comprehensive table information including bloat metrics, detailed size information, and I/O statistics as a CSV table. + Combines pg_table_bloat, table_size_detailed, and pg_statio_all_tables metrics for complete table analysis. """ try: # Get query parameters @@ -514,7 +514,7 @@ def get_table_info_csv(): filter_str = '{' + ','.join(filters) + '}' if filters else '' # Metrics to fetch with last_over_time to get only the most recent value - # Include both bloat metrics and detailed size metrics + # Include bloat metrics, detailed size metrics, and I/O metrics metric_queries = [ # Bloat metrics f'last_over_time(pgwatch_pg_table_bloat_real_size_mib{filter_str}[1d])', @@ -535,6 +535,15 @@ def get_table_info_csv(): f'last_over_time(pgwatch_table_size_detailed_toast_indexes_size_b{filter_str}[1d])', f'last_over_time(pgwatch_table_size_detailed_total_relation_size_b{filter_str}[1d])', f'last_over_time(pgwatch_table_size_detailed_total_toast_size_b{filter_str}[1d])', + # I/O metrics + f'last_over_time(pgwatch_pg_statio_all_tables_heap_blks_read{filter_str}[1d])', + f'last_over_time(pgwatch_pg_statio_all_tables_heap_blks_hit{filter_str}[1d])', + f'last_over_time(pgwatch_pg_statio_all_tables_idx_blks_read{filter_str}[1d])', + f'last_over_time(pgwatch_pg_statio_all_tables_idx_blks_hit{filter_str}[1d])', + f'last_over_time(pgwatch_pg_statio_all_tables_toast_blks_read{filter_str}[1d])', + f'last_over_time(pgwatch_pg_statio_all_tables_toast_blks_hit{filter_str}[1d])', + f'last_over_time(pgwatch_pg_statio_all_tables_tidx_blks_read{filter_str}[1d])', + f'last_over_time(pgwatch_pg_statio_all_tables_tidx_blks_hit{filter_str}[1d])', ] prom = get_prometheus_client() @@ -595,10 +604,58 @@ def get_table_info_csv(): metric_results[key]['total_relation_size_mib'] = value / (1024 * 1024) elif 'total_toast_size_b' in query: metric_results[key]['total_toast_size_mib'] = value / (1024 * 1024) + + # I/O metrics + elif 'heap_blks_read' in query: + metric_results[key]['heap_blks_read'] = int(value) + elif 'heap_blks_hit' in query: + metric_results[key]['heap_blks_hit'] = int(value) + elif 'idx_blks_read' in query: + metric_results[key]['idx_blks_read'] = int(value) + elif 'idx_blks_hit' in query: + metric_results[key]['idx_blks_hit'] = int(value) + elif 'toast_blks_read' in query: + metric_results[key]['toast_blks_read'] = int(value) + elif 'toast_blks_hit' in query: + metric_results[key]['toast_blks_hit'] = int(value) + elif 'tidx_blks_read' in query: + metric_results[key]['tidx_blks_read'] = int(value) + elif 'tidx_blks_hit' in query: + metric_results[key]['tidx_blks_hit'] = int(value) except Exception as e: logger.warning(f"Failed to query: {query}, error: {e}") continue + # Calculate I/O hit ratios + for key, row in metric_results.items(): + # Heap hit ratio + heap_total = row.get('heap_blks_read', 0) + row.get('heap_blks_hit', 0) + if heap_total > 0: + row['heap_hit_ratio'] = round(row.get('heap_blks_hit', 0) / heap_total * 100, 2) + else: + row['heap_hit_ratio'] = 0.0 + + # Index hit ratio + idx_total = row.get('idx_blks_read', 0) + row.get('idx_blks_hit', 0) + if idx_total > 0: + row['idx_hit_ratio'] = round(row.get('idx_blks_hit', 0) / idx_total * 100, 2) + else: + row['idx_hit_ratio'] = 0.0 + + # TOAST hit ratio + toast_total = row.get('toast_blks_read', 0) + row.get('toast_blks_hit', 0) + if toast_total > 0: + row['toast_hit_ratio'] = round(row.get('toast_blks_hit', 0) / toast_total * 100, 2) + else: + row['toast_hit_ratio'] = 0.0 + + # TOAST index hit ratio + tidx_total = row.get('tidx_blks_read', 0) + row.get('tidx_blks_hit', 0) + if tidx_total > 0: + row['tidx_hit_ratio'] = round(row.get('tidx_blks_hit', 0) / tidx_total * 100, 2) + else: + row['tidx_hit_ratio'] = 0.0 + # Prepare CSV output output = io.StringIO() fieldnames = [ @@ -610,7 +667,12 @@ def get_table_info_csv(): 'table_main_size_mib', 'table_fsm_size_mib', 'table_vm_size_mib', 'table_indexes_size_mib', 'toast_main_size_mib', 'toast_fsm_size_mib', 'toast_vm_size_mib', 'toast_indexes_size_mib', 'total_relation_size_mib', - 'total_toast_size_mib' + 'total_toast_size_mib', + # I/O metrics + 'heap_blks_read', 'heap_blks_hit', 'heap_hit_ratio', + 'idx_blks_read', 'idx_blks_hit', 'idx_hit_ratio', + 'toast_blks_read', 'toast_blks_hit', 'toast_hit_ratio', + 'tidx_blks_read', 'tidx_blks_hit', 'tidx_hit_ratio' ] writer = csv.DictWriter(output, fieldnames=fieldnames) writer.writeheader() From 3305f92f02ca01498ae21a31e98bd608ab6371d8 Mon Sep 17 00:00:00 2001 From: "dementii.priadko" <45518657+DEMNERD@users.noreply.github.com> Date: Fri, 26 Sep 2025 04:39:46 +0300 Subject: [PATCH 18/22] Removed an unnecessary when clause from pg_statio_all_tables metric --- config/pgwatch-prometheus/metrics.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/config/pgwatch-prometheus/metrics.yml b/config/pgwatch-prometheus/metrics.yml index 350db30..52654f4 100644 --- a/config/pgwatch-prometheus/metrics.yml +++ b/config/pgwatch-prometheus/metrics.yml @@ -2091,8 +2091,6 @@ metrics: tidx_blks_hit from pg_statio_all_tables - where - heap_blks_read > 0 or idx_blks_read > 0 or toast_blks_read > 0 or tidx_blks_read > 0 gauges: - '*' From 1be4ad4567a77f43bb8cb31dc76ebdaecd181ca6 Mon Sep 17 00:00:00 2001 From: "dementii.priadko" <45518657+DEMNERD@users.noreply.github.com> Date: Fri, 26 Sep 2025 18:48:51 +0300 Subject: [PATCH 19/22] Added IO stats for the table analysis --- .../dashboards/Dashboard_8_Table_Stats.json | 1057 ++++++++++++++++- .../Dashboard_9_Single_table_analysis.json | 564 ++++++++- 2 files changed, 1576 insertions(+), 45 deletions(-) diff --git a/config/grafana/dashboards/Dashboard_8_Table_Stats.json b/config/grafana/dashboards/Dashboard_8_Table_Stats.json index c9066f3..eacfe01 100644 --- a/config/grafana/dashboards/Dashboard_8_Table_Stats.json +++ b/config/grafana/dashboards/Dashboard_8_Table_Stats.json @@ -31,7 +31,7 @@ }, "id": 27, "panels": [], - "title": "Size Stats", + "title": "Size stats", "type": "row" }, { @@ -1533,6 +1533,1053 @@ "title": "Top $top_n tables by tuple non-HOT updates per second", "type": "timeseries" }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 88 + }, + "id": 30, + "panels": [], + "title": "IO stats", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 13, + "w": 24, + "x": 0, + "y": 89 + }, + "id": 31, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, irate(pgwatch_pg_statio_all_tables_heap_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \nirate(pgwatch_pg_statio_all_tables_idx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \nirate(pgwatch_pg_statio_all_tables_toast_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \nirate(pgwatch_pg_statio_all_tables_tidx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "20", + "legendFormat": "{{schemaname}}.{{relname}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by block hits", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 13, + "w": 24, + "x": 0, + "y": 102 + }, + "id": 37, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, irate(pgwatch_pg_statio_all_tables_heap_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \nirate(pgwatch_pg_statio_all_tables_idx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \nirate(pgwatch_pg_statio_all_tables_toast_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \nirate(pgwatch_pg_statio_all_tables_tidx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "20", + "legendFormat": "{{schemaname}}.{{relname}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by block reads", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 13, + "w": 24, + "x": 0, + "y": 115 + }, + "id": 36, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, irate(pgwatch_pg_statio_all_tables_heap_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "20", + "legendFormat": "{{schemaname}}.{{relname}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by heap block hits", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 13, + "w": 24, + "x": 0, + "y": 128 + }, + "id": 32, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, irate(pgwatch_pg_statio_all_tables_heap_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "20", + "legendFormat": "{{schemaname}}.{{relname}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by heap block reads", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 13, + "w": 24, + "x": 0, + "y": 141 + }, + "id": 33, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, irate(pgwatch_pg_statio_all_tables_idx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "20", + "legendFormat": "{{schemaname}}.{{relname}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by index block hits", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 13, + "w": 24, + "x": 0, + "y": 154 + }, + "id": 34, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, irate(pgwatch_pg_statio_all_tables_idx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "20", + "legendFormat": "{{schemaname}}.{{relname}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by index block reads", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 13, + "w": 24, + "x": 0, + "y": 167 + }, + "id": 38, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, irate(pgwatch_pg_statio_all_tables_toast_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "20", + "legendFormat": "{{schemaname}}.{{relname}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by TOAST block hits", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 13, + "w": 24, + "x": 0, + "y": 180 + }, + "id": 39, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, irate(pgwatch_pg_statio_all_tables_toast_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "20", + "legendFormat": "{{schemaname}}.{{relname}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by TOAST block reads", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 13, + "w": 24, + "x": 0, + "y": 193 + }, + "id": 40, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, irate(pgwatch_pg_stat_user_tables_seq_scan{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "20", + "legendFormat": "{{schemaname}}.{{relname}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by sequential scans", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 13, + "w": 24, + "x": 0, + "y": 206 + }, + "id": 41, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, irate(pgwatch_pg_stat_user_tables_idx_scan{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "20", + "legendFormat": "{{schemaname}}.{{relname}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by index scans", + "type": "timeseries" + }, { "fieldConfig": { "defaults": {}, @@ -1542,7 +2589,7 @@ "h": 3, "w": 24, "x": 0, - "y": 88 + "y": 219 }, "id": 20, "options": { @@ -1672,12 +2719,12 @@ ] }, "time": { - "from": "now-12h", + "from": "now-3h", "to": "now" }, "timepicker": {}, "timezone": "utc", - "title": "08. Aggregated tables analysis", + "title": "08. Aggregated table analysis", "uid": "92657f2a-985b-4d1a-99ed-2fac6e0c53e2", - "version": 19 + "version": 46 } \ No newline at end of file diff --git a/config/grafana/dashboards/Dashboard_9_Single_table_analysis.json b/config/grafana/dashboards/Dashboard_9_Single_table_analysis.json index 09dcfbd..65183e5 100644 --- a/config/grafana/dashboards/Dashboard_9_Single_table_analysis.json +++ b/config/grafana/dashboards/Dashboard_9_Single_table_analysis.json @@ -41,7 +41,7 @@ "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", - "fillOpacity": 0, + "fillOpacity": 100, "gradientMode": "none", "hideFrom": { "legend": false, @@ -59,7 +59,7 @@ "spanNulls": true, "stacking": { "group": "A", - "mode": "none" + "mode": "normal" }, "thresholdsStyle": { "mode": "off" @@ -80,25 +80,49 @@ }, "unit": "bytes" }, - "overrides": [] + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Total" + }, + "properties": [ + { + "id": "custom.stacking", + "value": { + "group": "A", + "mode": "none" + } + }, + { + "id": "custom.fillOpacity", + "value": 0 + } + ] + } + ] }, "gridPos": { - "h": 13, + "h": 14, "w": 24, "x": 0, "y": 0 }, - "id": 34, + "id": 38, "options": { "legend": { - "calcs": [], - "displayMode": "list", + "calcs": [ + "last" + ], + "displayMode": "table", "placement": "bottom", - "showLegend": true + "showLegend": true, + "sortBy": "Last", + "sortDesc": true }, "tooltip": { "hideZeros": false, - "mode": "single", + "mode": "multi", "sort": "none" } }, @@ -106,17 +130,91 @@ "targets": [ { "disableTextWrap": false, - "editorMode": "builder", - "expr": "pgwatch_pg_class_total_relation_size_bytes{relkind=\"114\", schemaname=\"$schema_name\", relname=\"$table_name\"}", + "editorMode": "code", + "expr": "pgwatch_table_size_detailed_total_toast_size_b{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=\"$schema_name\", table_name=\"$table_name\"}", "fullMetaSearch": false, "includeNullMetadata": true, - "legendFormat": "{{schemaname}}.{{relname}}", + "legendFormat": "TOAST", "range": true, "refId": "A", "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "sum(pgwatch_table_size_detailed_table_main_size_b{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=\"$schema_name\", table_name=\"$table_name\"})", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "Table (w/o TOAST)", + "range": true, + "refId": "B", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "sum(pgwatch_table_size_detailed_table_indexes_size_b{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=\"$schema_name\", table_name=\"$table_name\"})", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "Indexes", + "range": true, + "refId": "C", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "sum(pgwatch_table_size_detailed_table_vm_size_b{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=\"$schema_name\", table_name=\"$table_name\"})", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "Visibility map", + "range": true, + "refId": "D", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "sum(pgwatch_table_size_detailed_table_fsm_size_b{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=\"$schema_name\", table_name=\"$table_name\"})", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "Free space map", + "range": true, + "refId": "E", + "useBackend": false + } + ], + "title": "Table logical size distribution", + "transformations": [ + { + "id": "calculateField", + "options": {} } ], - "title": "Total table size", "type": "timeseries" }, { @@ -176,21 +274,226 @@ } ] }, - "unit": "Bps" + "unit": "binBps" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Total" + }, + "properties": [ + { + "id": "custom.stacking", + "value": { + "group": "A", + "mode": "none" + } + }, + { + "id": "custom.fillOpacity", + "value": 0 + } + ] + } + ] + }, + "gridPos": { + "h": 14, + "w": 24, + "x": 0, + "y": 14 + }, + "id": 39, + "options": { + "legend": { + "calcs": [ + "last" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Last", + "sortDesc": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "irate(pgwatch_table_size_detailed_total_toast_size_b{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=\"$schema_name\", table_name=\"$table_name\"}[$__rate_interval])", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "20", + "legendFormat": "TOAST", + "range": true, + "refId": "A", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "irate(pgwatch_table_size_detailed_table_main_size_b{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=\"$schema_name\", table_name=\"$table_name\"}[$__rate_interval])", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "interval": "20", + "legendFormat": "Table (w/o TOAST)", + "range": true, + "refId": "B", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "irate(pgwatch_table_size_detailed_table_indexes_size_b{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=\"$schema_name\", table_name=\"$table_name\"}[$__rate_interval])", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "interval": "20", + "legendFormat": "Indexes", + "range": true, + "refId": "C", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "irate(pgwatch_table_size_detailed_table_vm_size_b{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=\"$schema_name\", table_name=\"$table_name\"}[$__rate_interval])", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "interval": "20", + "legendFormat": "Visibility map", + "range": true, + "refId": "D", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "irate(pgwatch_table_size_detailed_table_fsm_size_b{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=\"$schema_name\", table_name=\"$table_name\"}[$__rate_interval])", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "interval": "20", + "legendFormat": "Free space map", + "range": true, + "refId": "E", + "useBackend": false + } + ], + "title": "Table logical size distribution changes (absolute)", + "transformations": [ + { + "id": "calculateField", + "options": {} + } + ], + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ops" }, "overrides": [] }, "gridPos": { - "h": 13, + "h": 14, "w": 24, "x": 0, - "y": 13 + "y": 28 }, - "id": 36, + "id": 40, "options": { "legend": { - "calcs": [], - "displayMode": "list", + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", "placement": "bottom", "showLegend": true }, @@ -205,17 +508,198 @@ { "disableTextWrap": false, "editorMode": "code", - "expr": "irate(pgwatch_pg_class_total_relation_size_bytes{relkind=\"114\", schemaname=\"$schema_name\", relname=\"$table_name\"}[$__rate_interval])", + "expr": "irate(pgwatch_pg_statio_all_tables_heap_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", "fullMetaSearch": false, "includeNullMetadata": true, "interval": "20", - "legendFormat": "{{schemaname}}.{{relname}}", + "legendFormat": "Heap", "range": true, "refId": "A", "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "editorMode": "code", + "expr": "irate(pgwatch_pg_statio_all_tables_tidx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", + "hide": false, + "instant": false, + "legendFormat": "tidx", + "range": true, + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "editorMode": "code", + "expr": "irate(pgwatch_pg_statio_all_tables_toast_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", + "hide": false, + "instant": false, + "legendFormat": "TOAST", + "range": true, + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "editorMode": "code", + "expr": "irate(pgwatch_pg_statio_all_tables_idx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", + "hide": false, + "instant": false, + "legendFormat": "Index", + "range": true, + "refId": "D" } ], - "title": "Table size change rate (absolute)", + "title": "Block hits distribution", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 14, + "w": 24, + "x": 0, + "y": 42 + }, + "id": 41, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "irate(pgwatch_pg_statio_all_tables_heap_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "20", + "legendFormat": "Heap", + "range": true, + "refId": "A", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "editorMode": "code", + "expr": "irate(pgwatch_pg_statio_all_tables_tidx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", + "hide": false, + "instant": false, + "legendFormat": "tidx", + "range": true, + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "editorMode": "code", + "expr": "irate(pgwatch_pg_statio_all_tables_toast_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", + "hide": false, + "instant": false, + "legendFormat": "TOAST", + "range": true, + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "editorMode": "code", + "expr": "irate(pgwatch_pg_statio_all_tables_idx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", + "hide": false, + "instant": false, + "legendFormat": "Index", + "range": true, + "refId": "D" + } + ], + "title": "Block reads distribution", "type": "timeseries" }, { @@ -224,7 +708,7 @@ "h": 1, "w": 24, "x": 0, - "y": 26 + "y": 56 }, "id": 31, "panels": [], @@ -296,7 +780,7 @@ "h": 13, "w": 24, "x": 0, - "y": 27 + "y": 57 }, "id": 32, "options": { @@ -401,7 +885,7 @@ "h": 13, "w": 24, "x": 0, - "y": 40 + "y": 70 }, "id": 33, "options": { @@ -446,7 +930,7 @@ "h": 1, "w": 24, "x": 0, - "y": 53 + "y": 83 }, "id": 30, "panels": [], @@ -579,7 +1063,7 @@ "h": 10, "w": 24, "x": 0, - "y": 54 + "y": 84 }, "id": 21, "options": { @@ -776,8 +1260,8 @@ "overrides": [ { "matcher": { - "id": "byFrameRefID", - "options": "A" + "id": "byName", + "options": "Inserts %" }, "properties": [ { @@ -791,14 +1275,14 @@ }, { "matcher": { - "id": "byFrameRefID", - "options": "B" + "id": "byName", + "options": "Non-HOT-Updates %" }, "properties": [ { "id": "color", "value": { - "fixedColor": "orange", + "fixedColor": "yellow", "mode": "fixed" } } @@ -806,14 +1290,14 @@ }, { "matcher": { - "id": "byFrameRefID", - "options": "C" + "id": "byName", + "options": "HOT-Updates" }, "properties": [ { "id": "color", "value": { - "fixedColor": "yellow", + "fixedColor": "orange", "mode": "fixed" } } @@ -821,8 +1305,8 @@ }, { "matcher": { - "id": "byFrameRefID", - "options": "D" + "id": "byName", + "options": "Deletes %" }, "properties": [ { @@ -840,7 +1324,7 @@ "h": 10, "w": 24, "x": 0, - "y": 64 + "y": 94 }, "id": 37, "options": { @@ -1103,7 +1587,7 @@ "h": 3, "w": 24, "x": 0, - "y": 74 + "y": 104 }, "id": 20, "options": { @@ -1225,5 +1709,5 @@ "timezone": "utc", "title": "09. Single table analysis", "uid": "9-single-table-analysis", - "version": 8 + "version": 19 } \ No newline at end of file From ae88ea3ec1afb4bdf921885e58e01f48fe18b58c Mon Sep 17 00:00:00 2001 From: "dementii.priadko" <45518657+DEMNERD@users.noreply.github.com> Date: Fri, 26 Sep 2025 18:52:11 +0300 Subject: [PATCH 20/22] Updated block hits/reads distribution graphs --- .../dashboards/Dashboard_9_Single_table_analysis.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/config/grafana/dashboards/Dashboard_9_Single_table_analysis.json b/config/grafana/dashboards/Dashboard_9_Single_table_analysis.json index 65183e5..b241dce 100644 --- a/config/grafana/dashboards/Dashboard_9_Single_table_analysis.json +++ b/config/grafana/dashboards/Dashboard_9_Single_table_analysis.json @@ -526,6 +526,7 @@ "expr": "irate(pgwatch_pg_statio_all_tables_tidx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", "hide": false, "instant": false, + "interval": "20", "legendFormat": "tidx", "range": true, "refId": "B" @@ -539,6 +540,7 @@ "expr": "irate(pgwatch_pg_statio_all_tables_toast_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", "hide": false, "instant": false, + "interval": "20", "legendFormat": "TOAST", "range": true, "refId": "C" @@ -552,6 +554,7 @@ "expr": "irate(pgwatch_pg_statio_all_tables_idx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", "hide": false, "instant": false, + "interval": "20", "legendFormat": "Index", "range": true, "refId": "D" @@ -668,6 +671,7 @@ "expr": "irate(pgwatch_pg_statio_all_tables_tidx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", "hide": false, "instant": false, + "interval": "20", "legendFormat": "tidx", "range": true, "refId": "B" @@ -681,6 +685,7 @@ "expr": "irate(pgwatch_pg_statio_all_tables_toast_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", "hide": false, "instant": false, + "interval": "20", "legendFormat": "TOAST", "range": true, "refId": "C" @@ -694,6 +699,7 @@ "expr": "irate(pgwatch_pg_statio_all_tables_idx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", "hide": false, "instant": false, + "interval": "20", "legendFormat": "Index", "range": true, "refId": "D" @@ -1702,12 +1708,12 @@ ] }, "time": { - "from": "now-12h", + "from": "now-3h", "to": "now" }, "timepicker": {}, "timezone": "utc", "title": "09. Single table analysis", "uid": "9-single-table-analysis", - "version": 19 + "version": 21 } \ No newline at end of file From 2b7404b5b8d64e5d11be4d92a5ded713d94b2d79 Mon Sep 17 00:00:00 2001 From: "dementii.priadko" <45518657+DEMNERD@users.noreply.github.com> Date: Fri, 26 Sep 2025 19:34:28 +0300 Subject: [PATCH 21/22] Added stacking to dashboard 8 --- .../dashboards/Dashboard_8_Table_Stats.json | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/config/grafana/dashboards/Dashboard_8_Table_Stats.json b/config/grafana/dashboards/Dashboard_8_Table_Stats.json index eacfe01..cef795b 100644 --- a/config/grafana/dashboards/Dashboard_8_Table_Stats.json +++ b/config/grafana/dashboards/Dashboard_8_Table_Stats.json @@ -1566,7 +1566,7 @@ "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", - "fillOpacity": 0, + "fillOpacity": 100, "gradientMode": "none", "hideFrom": { "legend": false, @@ -1584,7 +1584,7 @@ "spanNulls": false, "stacking": { "group": "A", - "mode": "none" + "mode": "normal" }, "thresholdsStyle": { "mode": "off" @@ -1669,7 +1669,7 @@ "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", - "fillOpacity": 0, + "fillOpacity": 100, "gradientMode": "none", "hideFrom": { "legend": false, @@ -1772,7 +1772,7 @@ "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", - "fillOpacity": 0, + "fillOpacity": 100, "gradientMode": "none", "hideFrom": { "legend": false, @@ -1790,7 +1790,7 @@ "spanNulls": false, "stacking": { "group": "A", - "mode": "none" + "mode": "normal" }, "thresholdsStyle": { "mode": "off" @@ -1875,7 +1875,7 @@ "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", - "fillOpacity": 0, + "fillOpacity": 100, "gradientMode": "none", "hideFrom": { "legend": false, @@ -1893,7 +1893,7 @@ "spanNulls": false, "stacking": { "group": "A", - "mode": "none" + "mode": "normal" }, "thresholdsStyle": { "mode": "off" @@ -1978,7 +1978,7 @@ "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", - "fillOpacity": 0, + "fillOpacity": 100, "gradientMode": "none", "hideFrom": { "legend": false, @@ -1996,7 +1996,7 @@ "spanNulls": false, "stacking": { "group": "A", - "mode": "none" + "mode": "normal" }, "thresholdsStyle": { "mode": "off" @@ -2081,7 +2081,7 @@ "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", - "fillOpacity": 0, + "fillOpacity": 100, "gradientMode": "none", "hideFrom": { "legend": false, @@ -2099,7 +2099,7 @@ "spanNulls": false, "stacking": { "group": "A", - "mode": "none" + "mode": "normal" }, "thresholdsStyle": { "mode": "off" @@ -2184,7 +2184,7 @@ "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", - "fillOpacity": 0, + "fillOpacity": 100, "gradientMode": "none", "hideFrom": { "legend": false, @@ -2202,7 +2202,7 @@ "spanNulls": false, "stacking": { "group": "A", - "mode": "none" + "mode": "normal" }, "thresholdsStyle": { "mode": "off" @@ -2287,7 +2287,7 @@ "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", - "fillOpacity": 0, + "fillOpacity": 100, "gradientMode": "none", "hideFrom": { "legend": false, @@ -2305,7 +2305,7 @@ "spanNulls": false, "stacking": { "group": "A", - "mode": "none" + "mode": "normal" }, "thresholdsStyle": { "mode": "off" @@ -2390,7 +2390,7 @@ "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", - "fillOpacity": 0, + "fillOpacity": 100, "gradientMode": "none", "hideFrom": { "legend": false, @@ -2408,7 +2408,7 @@ "spanNulls": false, "stacking": { "group": "A", - "mode": "none" + "mode": "normal" }, "thresholdsStyle": { "mode": "off" @@ -2495,7 +2495,7 @@ "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", - "fillOpacity": 0, + "fillOpacity": 100, "gradientMode": "none", "hideFrom": { "legend": false, @@ -2513,7 +2513,7 @@ "spanNulls": false, "stacking": { "group": "A", - "mode": "none" + "mode": "normal" }, "thresholdsStyle": { "mode": "off" @@ -2726,5 +2726,5 @@ "timezone": "utc", "title": "08. Aggregated table analysis", "uid": "92657f2a-985b-4d1a-99ed-2fac6e0c53e2", - "version": 46 + "version": 56 } \ No newline at end of file From 83780260d08acaea1e6ff233e68ac68afb3b5efc Mon Sep 17 00:00:00 2001 From: "dementii.priadko" <45518657+DEMNERD@users.noreply.github.com> Date: Fri, 26 Sep 2025 23:58:40 +0300 Subject: [PATCH 22/22] Minor tweaks of dashboards 1, 8 and 9 --- ...Dashboard_1_Node_performance_overview.json | 543 +++++-- .../dashboards/Dashboard_8_Table_Stats.json | 352 +++- .../Dashboard_9_Single_table_analysis.json | 1415 ++++++++++------- 3 files changed, 1555 insertions(+), 755 deletions(-) diff --git a/config/grafana/dashboards/Dashboard_1_Node_performance_overview.json b/config/grafana/dashboards/Dashboard_1_Node_performance_overview.json index bf5bc20..9037e5f 100644 --- a/config/grafana/dashboards/Dashboard_1_Node_performance_overview.json +++ b/config/grafana/dashboards/Dashboard_1_Node_performance_overview.json @@ -3435,6 +3435,267 @@ "title": "temp_bytes_read vs temp_bytes_written per call (pg_stat_statements)", "type": "timeseries" }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ops" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Inserts" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-green", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Deletes" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "HOT updates" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Non-HOT updates" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "yellow", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 13, + "w": 24, + "x": 0, + "y": 133 + }, + "id": 45, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Max", + "sortDesc": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "sum by (node_name, dbname, cluster) (irate(pgwatch_table_stats_n_tup_ins{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "60", + "legendFormat": "Inserts", + "range": true, + "refId": "A", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "sum by (node_name, dbname, cluster) (irate(pgwatch_table_stats_n_tup_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "interval": "60", + "legendFormat": "Updates", + "range": true, + "refId": "B", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "sum by (node_name, dbname, cluster) (irate(pgwatch_table_stats_n_tup_hot_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "interval": "60", + "legendFormat": "HOT updates", + "range": true, + "refId": "C", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "sum by (node_name, dbname, cluster) (irate(pgwatch_table_stats_n_tup_del{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "interval": "60", + "legendFormat": "Deletes", + "range": true, + "refId": "D", + "useBackend": false + } + ], + "title": "Tuple operations", + "transformations": [ + { + "id": "calculateField", + "options": { + "alias": "Non-HOT updates", + "binary": { + "left": { + "matcher": { + "id": "byName", + "options": "Updates" + } + }, + "operator": "-", + "right": { + "matcher": { + "id": "byName", + "options": "HOT updates" + } + } + }, + "mode": "binary", + "reduce": { + "reducer": "sum" + } + } + }, + { + "id": "organize", + "options": { + "excludeByName": { + "Updates": true + }, + "includeByName": {}, + "indexByName": {}, + "renameByName": { + "Hot Updates": "HOT Updates" + } + } + } + ], + "type": "timeseries" + }, { "datasource": { "type": "prometheus", @@ -3503,7 +3764,7 @@ "h": 8, "w": 12, "x": 0, - "y": 133 + "y": 146 }, "id": 32, "options": { @@ -3640,7 +3901,7 @@ "h": 8, "w": 12, "x": 12, - "y": 133 + "y": 146 }, "id": 33, "options": { @@ -3738,7 +3999,7 @@ "h": 8, "w": 12, "x": 0, - "y": 141 + "y": 154 }, "id": 34, "options": { @@ -3835,7 +4096,7 @@ "h": 8, "w": 12, "x": 12, - "y": 141 + "y": 154 }, "id": 35, "options": { @@ -3933,7 +4194,7 @@ "h": 10, "w": 24, "x": 0, - "y": 149 + "y": 162 }, "id": 41, "options": { @@ -3999,6 +4260,138 @@ "title": "bgwriter and checkpointer", "type": "timeseries" }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMax": 7, + "axisSoftMin": 1, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "points", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "decimals": 0, + "mappings": [ + { + "options": { + "1": { + "index": 0, + "text": "Initial" + }, + "2": { + "index": 1, + "text": "Scanning heap" + }, + "3": { + "index": 2, + "text": "Vacuuming indexes" + }, + "4": { + "index": 3, + "text": "Vacuuming heap" + }, + "5": { + "index": 4, + "text": "Cleaning up indexes" + }, + "6": { + "index": 5, + "text": "Truncating heap" + }, + "7": { + "index": 6, + "text": "Final cleanup" + } + }, + "type": "value" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 24, + "x": 0, + "y": 172 + }, + "id": 42, + "options": { + "legend": { + "calcs": [ + "lastNotNull" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "(\n group by (schema_name, table_name, vacuum_mode) (\n pgwatch_pg_vacuum_progress_index_vacuum_count{phase=\"7\"}) * 0 + 7 or \n group by (schema_name, table_name, vacuum_mode) (\n pgwatch_pg_vacuum_progress_index_vacuum_count{phase=\"6\"}) * 0 + 6 or\n group by (schema_name, table_name, vacuum_mode) (\n pgwatch_pg_vacuum_progress_index_vacuum_count{phase=\"5\"}) * 0 + 5 or \n group by (schema_name, table_name, vacuum_mode) (\n pgwatch_pg_vacuum_progress_index_vacuum_count{phase=\"4\"}) * 0 + 4 or \n group by (schema_name, table_name, vacuum_mode) (\n pgwatch_pg_vacuum_progress_index_vacuum_count{phase=\"3\"}) * 0 + 3 or \n group by (schema_name, table_name, vacuum_mode) (\n pgwatch_pg_vacuum_progress_index_vacuum_count{phase=\"2\"}) * 0 + 2 or \n group by (schema_name, table_name, vacuum_mode) (\n pgwatch_pg_vacuum_progress_index_vacuum_count{phase=\"1\"}) * 0 + 1\n)", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "", + "legendFormat": "{{schema_name}}.{{table_name}} - {{vacuum_mode}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Vacuum timeline", + "type": "timeseries" + }, { "datasource": { "type": "prometheus", @@ -4084,7 +4477,7 @@ "h": 14, "w": 24, "x": 0, - "y": 159 + "y": 183 }, "id": 44, "options": { @@ -4195,138 +4588,6 @@ ], "type": "timeseries" }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "axisSoftMax": 7, - "axisSoftMin": 1, - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "points", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "decimals": 0, - "mappings": [ - { - "options": { - "1": { - "index": 0, - "text": "Initial" - }, - "2": { - "index": 1, - "text": "Scanning heap" - }, - "3": { - "index": 2, - "text": "Vacuuming indexes" - }, - "4": { - "index": 3, - "text": "Vacuuming heap" - }, - "5": { - "index": 4, - "text": "Cleaning up indexes" - }, - "6": { - "index": 5, - "text": "Truncating heap" - }, - "7": { - "index": 6, - "text": "Final cleanup" - } - }, - "type": "value" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 11, - "w": 24, - "x": 0, - "y": 173 - }, - "id": 42, - "options": { - "legend": { - "calcs": [ - "lastNotNull" - ], - "displayMode": "table", - "placement": "bottom", - "showLegend": true - }, - "tooltip": { - "hideZeros": false, - "mode": "multi", - "sort": "none" - } - }, - "pluginVersion": "12.0.2", - "targets": [ - { - "disableTextWrap": false, - "editorMode": "code", - "expr": "(\n group by (schema_name, table_name, vacuum_mode) (\n pgwatch_pg_vacuum_progress_index_vacuum_count{phase=\"7\"}) * 0 + 7 or \n group by (schema_name, table_name, vacuum_mode) (\n pgwatch_pg_vacuum_progress_index_vacuum_count{phase=\"6\"}) * 0 + 6 or\n group by (schema_name, table_name, vacuum_mode) (\n pgwatch_pg_vacuum_progress_index_vacuum_count{phase=\"5\"}) * 0 + 5 or \n group by (schema_name, table_name, vacuum_mode) (\n pgwatch_pg_vacuum_progress_index_vacuum_count{phase=\"4\"}) * 0 + 4 or \n group by (schema_name, table_name, vacuum_mode) (\n pgwatch_pg_vacuum_progress_index_vacuum_count{phase=\"3\"}) * 0 + 3 or \n group by (schema_name, table_name, vacuum_mode) (\n pgwatch_pg_vacuum_progress_index_vacuum_count{phase=\"2\"}) * 0 + 2 or \n group by (schema_name, table_name, vacuum_mode) (\n pgwatch_pg_vacuum_progress_index_vacuum_count{phase=\"1\"}) * 0 + 1\n)", - "fullMetaSearch": false, - "includeNullMetadata": true, - "interval": "", - "legendFormat": "{{schema_name}}.{{table_name}} - {{vacuum_mode}}", - "range": true, - "refId": "A", - "useBackend": false - } - ], - "title": "Vacuum timeline", - "type": "timeseries" - }, { "fieldConfig": { "defaults": {}, @@ -4336,7 +4597,7 @@ "h": 3, "w": 24, "x": 0, - "y": 184 + "y": 197 }, "id": 40, "options": { @@ -4415,12 +4676,12 @@ ] }, "time": { - "from": "now-30m", + "from": "now-24h", "to": "now" }, "timepicker": {}, "timezone": "utc", "title": "01. Single node performance overview (high-level)", "uid": "f90500a0-a12e-4081-a2f0-07ed96f27915", - "version": 13 + "version": 24 } \ No newline at end of file diff --git a/config/grafana/dashboards/Dashboard_8_Table_Stats.json b/config/grafana/dashboards/Dashboard_8_Table_Stats.json index cef795b..29eba3a 100644 --- a/config/grafana/dashboards/Dashboard_8_Table_Stats.json +++ b/config/grafana/dashboards/Dashboard_8_Table_Stats.json @@ -113,7 +113,7 @@ }, "tooltip": { "hideZeros": false, - "mode": "single", + "mode": "multi", "sort": "none" } }, @@ -190,7 +190,7 @@ } ] }, - "unit": "bytes" + "unit": "binBps" }, "overrides": [] }, @@ -214,7 +214,7 @@ }, "tooltip": { "hideZeros": false, - "mode": "single", + "mode": "multi", "sort": "none" } }, @@ -317,7 +317,7 @@ }, "tooltip": { "hideZeros": false, - "mode": "single", + "mode": "multi", "sort": "none" } }, @@ -394,7 +394,7 @@ } ] }, - "unit": "bytes" + "unit": "binBps" }, "overrides": [] }, @@ -418,7 +418,7 @@ }, "tooltip": { "hideZeros": false, - "mode": "single", + "mode": "multi", "sort": "none" } }, @@ -521,7 +521,7 @@ }, "tooltip": { "hideZeros": false, - "mode": "single", + "mode": "multi", "sort": "none" } }, @@ -598,7 +598,7 @@ } ] }, - "unit": "bytes" + "unit": "binBps" }, "overrides": [] }, @@ -622,7 +622,7 @@ }, "tooltip": { "hideZeros": false, - "mode": "single", + "mode": "multi", "sort": "none" } }, @@ -725,7 +725,7 @@ }, "tooltip": { "hideZeros": false, - "mode": "single", + "mode": "multi", "sort": "none" } }, @@ -802,7 +802,7 @@ } ] }, - "unit": "bytes" + "unit": "binBps" }, "overrides": [] }, @@ -826,7 +826,7 @@ }, "tooltip": { "hideZeros": false, - "mode": "single", + "mode": "multi", "sort": "none" } }, @@ -1187,7 +1187,7 @@ "useBackend": false } ], - "title": "Top $top_n tables by tuples inserts per second", + "title": "Top $top_n tables by tuple inserts per second", "type": "timeseries" }, { @@ -1533,13 +1533,223 @@ "title": "Top $top_n tables by tuple non-HOT updates per second", "type": "timeseries" }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 13, + "w": 24, + "x": 0, + "y": 88 + }, + "id": 40, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, irate(pgwatch_pg_stat_user_tables_seq_tup_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "20", + "legendFormat": "{{schemaname}}.{{relname}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by sequential reads of live tuples", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 13, + "w": 24, + "x": 0, + "y": 101 + }, + "id": 41, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "topk($top_n, irate(pgwatch_pg_stat_user_tables_idx_tup_fetch{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "20", + "legendFormat": "{{schemaname}}.{{relname}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Top $top_n tables by index fetches of live tuples", + "type": "timeseries" + }, { "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, - "y": 88 + "y": 114 }, "id": 30, "panels": [], @@ -1603,15 +1813,15 @@ } ] }, - "unit": "ops" + "unit": "binBps" }, "overrides": [] }, "gridPos": { "h": 13, - "w": 24, + "w": 12, "x": 0, - "y": 89 + "y": 115 }, "id": 31, "options": { @@ -1636,7 +1846,7 @@ { "disableTextWrap": false, "editorMode": "code", - "expr": "topk($top_n, irate(pgwatch_pg_statio_all_tables_heap_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \nirate(pgwatch_pg_statio_all_tables_idx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \nirate(pgwatch_pg_statio_all_tables_toast_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \nirate(pgwatch_pg_statio_all_tables_tidx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "expr": "topk($top_n, \n irate(pgwatch_pg_statio_all_tables_heap_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_idx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_toast_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_tidx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval])\n) * on() group_left() last_over_time(pgwatch_settings_numeric_value{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", setting_name=\"block_size\"}[1d])", "fullMetaSearch": false, "includeNullMetadata": true, "interval": "20", @@ -1646,7 +1856,7 @@ "useBackend": false } ], - "title": "Top $top_n tables by block hits", + "title": "Top $top_n tables by total shared block hits", "type": "timeseries" }, { @@ -1669,7 +1879,7 @@ "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", - "fillOpacity": 100, + "fillOpacity": 0, "gradientMode": "none", "hideFrom": { "legend": false, @@ -1694,6 +1904,7 @@ } }, "mappings": [], + "noValue": "-", "thresholds": { "mode": "absolute", "steps": [ @@ -1706,17 +1917,17 @@ } ] }, - "unit": "ops" + "unit": "percentunit" }, "overrides": [] }, "gridPos": { "h": 13, - "w": 24, - "x": 0, - "y": 102 + "w": 12, + "x": 12, + "y": 115 }, - "id": 37, + "id": 42, "options": { "legend": { "calcs": [ @@ -1739,7 +1950,7 @@ { "disableTextWrap": false, "editorMode": "code", - "expr": "topk($top_n, irate(pgwatch_pg_statio_all_tables_heap_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \nirate(pgwatch_pg_statio_all_tables_idx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \nirate(pgwatch_pg_statio_all_tables_toast_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \nirate(pgwatch_pg_statio_all_tables_tidx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "expr": "topk($top_n, \n (irate(pgwatch_pg_statio_all_tables_heap_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_idx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_toast_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_tidx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))/(irate(pgwatch_pg_statio_all_tables_heap_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_idx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_toast_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_tidx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + (irate(pgwatch_pg_statio_all_tables_heap_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_idx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_toast_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_tidx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))) \n) ", "fullMetaSearch": false, "includeNullMetadata": true, "interval": "20", @@ -1749,7 +1960,7 @@ "useBackend": false } ], - "title": "Top $top_n tables by block reads", + "title": "Top $top_n tables by total shared block hit ratio", "type": "timeseries" }, { @@ -1790,7 +2001,7 @@ "spanNulls": false, "stacking": { "group": "A", - "mode": "normal" + "mode": "none" }, "thresholdsStyle": { "mode": "off" @@ -1809,17 +2020,17 @@ } ] }, - "unit": "ops" + "unit": "binBps" }, "overrides": [] }, "gridPos": { "h": 13, - "w": 24, + "w": 12, "x": 0, - "y": 115 + "y": 128 }, - "id": 36, + "id": 37, "options": { "legend": { "calcs": [ @@ -1842,7 +2053,7 @@ { "disableTextWrap": false, "editorMode": "code", - "expr": "topk($top_n, irate(pgwatch_pg_statio_all_tables_heap_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "expr": "topk($top_n, irate(pgwatch_pg_statio_all_tables_heap_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \nirate(pgwatch_pg_statio_all_tables_idx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \nirate(pgwatch_pg_statio_all_tables_toast_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \nirate(pgwatch_pg_statio_all_tables_tidx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval])) * on() group_left() last_over_time(pgwatch_settings_numeric_value{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", setting_name=\"block_size\"}[1d])", "fullMetaSearch": false, "includeNullMetadata": true, "interval": "20", @@ -1852,7 +2063,7 @@ "useBackend": false } ], - "title": "Top $top_n tables by heap block hits", + "title": "Top $top_n tables by total shared block reads", "type": "timeseries" }, { @@ -1875,7 +2086,7 @@ "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", - "fillOpacity": 100, + "fillOpacity": 0, "gradientMode": "none", "hideFrom": { "legend": false, @@ -1893,13 +2104,14 @@ "spanNulls": false, "stacking": { "group": "A", - "mode": "normal" + "mode": "none" }, "thresholdsStyle": { "mode": "off" } }, "mappings": [], + "noValue": "-", "thresholds": { "mode": "absolute", "steps": [ @@ -1912,17 +2124,17 @@ } ] }, - "unit": "ops" + "unit": "percentunit" }, "overrides": [] }, "gridPos": { "h": 13, - "w": 24, - "x": 0, + "w": 12, + "x": 12, "y": 128 }, - "id": 32, + "id": 43, "options": { "legend": { "calcs": [ @@ -1945,7 +2157,7 @@ { "disableTextWrap": false, "editorMode": "code", - "expr": "topk($top_n, irate(pgwatch_pg_statio_all_tables_heap_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "expr": "topk($top_n, \n (irate(pgwatch_pg_statio_all_tables_heap_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_idx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_toast_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_tidx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))/(irate(pgwatch_pg_statio_all_tables_heap_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_idx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_toast_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_tidx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + (irate(pgwatch_pg_statio_all_tables_heap_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_idx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_toast_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_tidx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))) \n) ", "fullMetaSearch": false, "includeNullMetadata": true, "interval": "20", @@ -1955,7 +2167,7 @@ "useBackend": false } ], - "title": "Top $top_n tables by heap block reads", + "title": "Top $top_n tables by total shared block read ratio", "type": "timeseries" }, { @@ -2015,7 +2227,7 @@ } ] }, - "unit": "ops" + "unit": "binBps" }, "overrides": [] }, @@ -2025,7 +2237,7 @@ "x": 0, "y": 141 }, - "id": 33, + "id": 36, "options": { "legend": { "calcs": [ @@ -2048,7 +2260,7 @@ { "disableTextWrap": false, "editorMode": "code", - "expr": "topk($top_n, irate(pgwatch_pg_statio_all_tables_idx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "expr": "topk($top_n, irate(pgwatch_pg_statio_all_tables_heap_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))* on() group_left() last_over_time(pgwatch_settings_numeric_value{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", setting_name=\"block_size\"}[1d])", "fullMetaSearch": false, "includeNullMetadata": true, "interval": "20", @@ -2058,7 +2270,7 @@ "useBackend": false } ], - "title": "Top $top_n tables by index block hits", + "title": "Top $top_n tables by table (without TOAST) shared block hits", "type": "timeseries" }, { @@ -2118,7 +2330,7 @@ } ] }, - "unit": "ops" + "unit": "binBps" }, "overrides": [] }, @@ -2128,7 +2340,7 @@ "x": 0, "y": 154 }, - "id": 34, + "id": 32, "options": { "legend": { "calcs": [ @@ -2151,7 +2363,7 @@ { "disableTextWrap": false, "editorMode": "code", - "expr": "topk($top_n, irate(pgwatch_pg_statio_all_tables_idx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "expr": "topk($top_n, irate(pgwatch_pg_statio_all_tables_heap_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", "fullMetaSearch": false, "includeNullMetadata": true, "interval": "20", @@ -2161,7 +2373,7 @@ "useBackend": false } ], - "title": "Top $top_n tables by index block reads", + "title": "Top $top_n tables by table (without TOAST) shared block reads", "type": "timeseries" }, { @@ -2221,7 +2433,7 @@ } ] }, - "unit": "ops" + "unit": "binBps" }, "overrides": [] }, @@ -2254,7 +2466,7 @@ { "disableTextWrap": false, "editorMode": "code", - "expr": "topk($top_n, irate(pgwatch_pg_statio_all_tables_toast_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "expr": "topk($top_n, irate(pgwatch_pg_statio_all_tables_toast_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))* on() group_left() last_over_time(pgwatch_settings_numeric_value{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", setting_name=\"block_size\"}[1d])", "fullMetaSearch": false, "includeNullMetadata": true, "interval": "20", @@ -2264,7 +2476,7 @@ "useBackend": false } ], - "title": "Top $top_n tables by TOAST block hits", + "title": "Top $top_n tables by TOAST shared block hits", "type": "timeseries" }, { @@ -2324,7 +2536,7 @@ } ] }, - "unit": "ops" + "unit": "binBps" }, "overrides": [] }, @@ -2367,7 +2579,7 @@ "useBackend": false } ], - "title": "Top $top_n tables by TOAST block reads", + "title": "Top $top_n tables by TOAST shared block reads", "type": "timeseries" }, { @@ -2427,7 +2639,7 @@ } ] }, - "unit": "ops" + "unit": "binBps" }, "overrides": [] }, @@ -2437,7 +2649,7 @@ "x": 0, "y": 193 }, - "id": 40, + "id": 33, "options": { "legend": { "calcs": [ @@ -2447,9 +2659,7 @@ ], "displayMode": "table", "placement": "bottom", - "showLegend": true, - "sortBy": "Mean", - "sortDesc": true + "showLegend": true }, "tooltip": { "hideZeros": false, @@ -2462,7 +2672,7 @@ { "disableTextWrap": false, "editorMode": "code", - "expr": "topk($top_n, irate(pgwatch_pg_stat_user_tables_seq_scan{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "expr": "topk($top_n, irate(pgwatch_pg_statio_all_tables_idx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval])) * on() group_left() last_over_time(pgwatch_settings_numeric_value{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", setting_name=\"block_size\"}[1d])", "fullMetaSearch": false, "includeNullMetadata": true, "interval": "20", @@ -2472,7 +2682,7 @@ "useBackend": false } ], - "title": "Top $top_n tables by sequential scans", + "title": "Top $top_n tables by index shared block hits", "type": "timeseries" }, { @@ -2532,7 +2742,7 @@ } ] }, - "unit": "ops" + "unit": "binBps" }, "overrides": [] }, @@ -2542,7 +2752,7 @@ "x": 0, "y": 206 }, - "id": 41, + "id": 34, "options": { "legend": { "calcs": [ @@ -2552,9 +2762,7 @@ ], "displayMode": "table", "placement": "bottom", - "showLegend": true, - "sortBy": "Mean", - "sortDesc": true + "showLegend": true }, "tooltip": { "hideZeros": false, @@ -2567,7 +2775,7 @@ { "disableTextWrap": false, "editorMode": "code", - "expr": "topk($top_n, irate(pgwatch_pg_stat_user_tables_idx_scan{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))", + "expr": "topk($top_n, irate(pgwatch_pg_statio_all_tables_idx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\"}[$__rate_interval]))* on() group_left() last_over_time(pgwatch_settings_numeric_value{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", setting_name=\"block_size\"}[1d])", "fullMetaSearch": false, "includeNullMetadata": true, "interval": "20", @@ -2577,7 +2785,7 @@ "useBackend": false } ], - "title": "Top $top_n tables by index scans", + "title": "Top $top_n tables by index shared block reads", "type": "timeseries" }, { @@ -2598,7 +2806,7 @@ "showLineNumbers": false, "showMiniMap": false }, - "content": "

\n Brought to you by Postgres AI\n \"Postgres.AI\"\n

\n", + "content": "

\n Brought to you by PostgresAI\n \"Postgres.AI\"\n

\n", "mode": "html" }, "pluginVersion": "12.0.2", @@ -2719,12 +2927,12 @@ ] }, "time": { - "from": "now-3h", + "from": "now-6h", "to": "now" }, "timepicker": {}, "timezone": "utc", "title": "08. Aggregated table analysis", "uid": "92657f2a-985b-4d1a-99ed-2fac6e0c53e2", - "version": 56 + "version": 97 } \ No newline at end of file diff --git a/config/grafana/dashboards/Dashboard_9_Single_table_analysis.json b/config/grafana/dashboards/Dashboard_9_Single_table_analysis.json index b241dce..5600409 100644 --- a/config/grafana/dashboards/Dashboard_9_Single_table_analysis.json +++ b/config/grafana/dashboards/Dashboard_9_Single_table_analysis.json @@ -21,6 +21,19 @@ "id": 16, "links": [], "panels": [ + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 27, + "panels": [], + "title": "Size stats", + "type": "row" + }, { "datasource": { "type": "prometheus", @@ -103,10 +116,10 @@ ] }, "gridPos": { - "h": 14, - "w": 24, + "h": 13, + "w": 12, "x": 0, - "y": 0 + "y": 1 }, "id": 38, "options": { @@ -299,10 +312,10 @@ ] }, "gridPos": { - "h": 14, - "w": 24, - "x": 0, - "y": 14 + "h": 13, + "w": 12, + "x": 12, + "y": 1 }, "id": 39, "options": { @@ -418,6 +431,19 @@ ], "type": "timeseries" }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 14 + }, + "id": 31, + "panels": [], + "title": "Estimated bloat stats", + "type": "row" + }, { "datasource": { "type": "prometheus", @@ -434,11 +460,12 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", + "axisSoftMax": 100, "axisSoftMin": 0, "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", - "fillOpacity": 100, + "fillOpacity": 0, "gradientMode": "none", "hideFrom": { "legend": false, @@ -453,10 +480,10 @@ "type": "linear" }, "showPoints": "auto", - "spanNulls": false, + "spanNulls": true, "stacking": { "group": "A", - "mode": "normal" + "mode": "none" }, "thresholdsStyle": { "mode": "off" @@ -475,17 +502,17 @@ } ] }, - "unit": "ops" + "unit": "percent" }, "overrides": [] }, "gridPos": { - "h": 14, - "w": 24, + "h": 13, + "w": 12, "x": 0, - "y": 28 + "y": 15 }, - "id": 40, + "id": 33, "options": { "legend": { "calcs": [ @@ -495,7 +522,9 @@ ], "displayMode": "table", "placement": "bottom", - "showLegend": true + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true }, "tooltip": { "hideZeros": false, @@ -507,60 +536,17 @@ "targets": [ { "disableTextWrap": false, - "editorMode": "code", - "expr": "irate(pgwatch_pg_statio_all_tables_heap_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", + "editorMode": "builder", + "expr": "pgwatch_pg_table_bloat_bloat_pct{schemaname=\"$schema_name\", tblname=\"$table_name\"}", "fullMetaSearch": false, "includeNullMetadata": true, - "interval": "20", - "legendFormat": "Heap", + "legendFormat": "{{schemaname}}.{{tblname}}", "range": true, "refId": "A", "useBackend": false - }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "editorMode": "code", - "expr": "irate(pgwatch_pg_statio_all_tables_tidx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", - "hide": false, - "instant": false, - "interval": "20", - "legendFormat": "tidx", - "range": true, - "refId": "B" - }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "editorMode": "code", - "expr": "irate(pgwatch_pg_statio_all_tables_toast_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", - "hide": false, - "instant": false, - "interval": "20", - "legendFormat": "TOAST", - "range": true, - "refId": "C" - }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "editorMode": "code", - "expr": "irate(pgwatch_pg_statio_all_tables_idx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", - "hide": false, - "instant": false, - "interval": "20", - "legendFormat": "Index", - "range": true, - "refId": "D" } ], - "title": "Block hits distribution", + "title": "Estimated bloat %", "type": "timeseries" }, { @@ -598,10 +584,10 @@ "type": "linear" }, "showPoints": "auto", - "spanNulls": false, + "spanNulls": true, "stacking": { "group": "A", - "mode": "normal" + "mode": "none" }, "thresholdsStyle": { "mode": "off" @@ -620,17 +606,17 @@ } ] }, - "unit": "ops" + "unit": "bytes" }, "overrides": [] }, "gridPos": { - "h": 14, - "w": 24, - "x": 0, - "y": 42 + "h": 13, + "w": 12, + "x": 12, + "y": 15 }, - "id": 41, + "id": 32, "options": { "legend": { "calcs": [ @@ -640,11 +626,13 @@ ], "displayMode": "table", "placement": "bottom", - "showLegend": true + "showLegend": true, + "sortBy": "Max", + "sortDesc": true }, "tooltip": { "hideZeros": false, - "mode": "single", + "mode": "multi", "sort": "none" } }, @@ -652,60 +640,17 @@ "targets": [ { "disableTextWrap": false, - "editorMode": "code", - "expr": "irate(pgwatch_pg_statio_all_tables_heap_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", + "editorMode": "builder", + "expr": "pgwatch_pg_table_bloat_bloat_size{schemaname=\"$schema_name\", tblname=\"$table_name\"}", "fullMetaSearch": false, "includeNullMetadata": true, - "interval": "20", - "legendFormat": "Heap", + "legendFormat": "{{schemaname}}.{{tblname}}", "range": true, "refId": "A", "useBackend": false - }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "editorMode": "code", - "expr": "irate(pgwatch_pg_statio_all_tables_tidx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", - "hide": false, - "instant": false, - "interval": "20", - "legendFormat": "tidx", - "range": true, - "refId": "B" - }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "editorMode": "code", - "expr": "irate(pgwatch_pg_statio_all_tables_toast_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", - "hide": false, - "instant": false, - "interval": "20", - "legendFormat": "TOAST", - "range": true, - "refId": "C" - }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "editorMode": "code", - "expr": "irate(pgwatch_pg_statio_all_tables_idx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", - "hide": false, - "instant": false, - "interval": "20", - "legendFormat": "Index", - "range": true, - "refId": "D" } ], - "title": "Block reads distribution", + "title": "Estimated bloat size", "type": "timeseries" }, { @@ -714,11 +659,11 @@ "h": 1, "w": 24, "x": 0, - "y": 56 + "y": 28 }, - "id": 31, + "id": 30, "panels": [], - "title": "Bloat stats", + "title": "Tuple stats", "type": "row" }, { @@ -741,7 +686,7 @@ "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", - "fillOpacity": 0, + "fillOpacity": 100, "gradientMode": "none", "hideFrom": { "legend": false, @@ -756,10 +701,10 @@ "type": "linear" }, "showPoints": "auto", - "spanNulls": true, + "spanNulls": false, "stacking": { "group": "A", - "mode": "none" + "mode": "normal" }, "thresholdsStyle": { "mode": "off" @@ -778,17 +723,78 @@ } ] }, - "unit": "bytes" + "unit": "ops" }, - "overrides": [] + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Inserts" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-green", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Deletes" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "HOT updates" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Non-HOT updates" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "yellow", + "mode": "fixed" + } + } + ] + } + ] }, "gridPos": { - "h": 13, - "w": 24, + "h": 10, + "w": 12, "x": 0, - "y": 57 + "y": 29 }, - "id": 32, + "id": 21, "options": { "legend": { "calcs": [ @@ -811,138 +817,116 @@ "pluginVersion": "12.0.2", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, "disableTextWrap": false, - "editorMode": "builder", - "expr": "pgwatch_pg_table_bloat_bloat_size{schemaname=\"$schema_name\", tblname=\"$table_name\"}", + "editorMode": "code", + "expr": "sum by (node_name, table_full_name, dbname, cluster) (irate(pgwatch_table_stats_n_tup_ins{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=\"$schema_name\", table_name=\"$table_name\"}[$__rate_interval]))", "fullMetaSearch": false, "includeNullMetadata": true, - "legendFormat": "{{schemaname}}.{{tblname}}", + "interval": "60", + "legendFormat": "Inserts", "range": true, "refId": "A", "useBackend": false - } - ], - "title": "Bloat size", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "axisSoftMax": 100, - "axisSoftMin": 0, - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 1, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "red", - "value": 80 - } - ] + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" }, - "unit": "percent" + "disableTextWrap": false, + "editorMode": "code", + "expr": "sum by (node_name, table_full_name, dbname, cluster) (irate(pgwatch_table_stats_n_tup_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=\"$schema_name\", table_name=\"$table_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "interval": "60", + "legendFormat": "Updates", + "range": true, + "refId": "B", + "useBackend": false }, - "overrides": [] - }, - "gridPos": { - "h": 13, - "w": 24, - "x": 0, - "y": 70 - }, - "id": 33, - "options": { - "legend": { - "calcs": [ - "min", - "max", - "mean" - ], - "displayMode": "table", - "placement": "bottom", - "showLegend": true, - "sortBy": "Mean", - "sortDesc": true + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "disableTextWrap": false, + "editorMode": "code", + "expr": "sum by (node_name, table_full_name, dbname, cluster) (irate(pgwatch_table_stats_n_tup_hot_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=\"$schema_name\", table_name=\"$table_name\"}[$__rate_interval]))", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "interval": "60", + "legendFormat": "HOT updates", + "range": true, + "refId": "C", + "useBackend": false }, - "tooltip": { - "hideZeros": false, - "mode": "single", - "sort": "none" - } - }, - "pluginVersion": "12.0.2", - "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, "disableTextWrap": false, - "editorMode": "builder", - "expr": "pgwatch_pg_table_bloat_bloat_pct{schemaname=\"$schema_name\", tblname=\"$table_name\"}", + "editorMode": "code", + "expr": "sum by (node_name, table_full_name, dbname, cluster) (irate(pgwatch_table_stats_n_tup_del{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=\"$schema_name\", table_name=\"$table_name\"}[$__rate_interval]))", "fullMetaSearch": false, + "hide": false, "includeNullMetadata": true, - "legendFormat": "{{schemaname}}.{{tblname}}", + "interval": "60", + "legendFormat": "Deletes", "range": true, - "refId": "A", + "refId": "D", "useBackend": false } ], - "title": "Bloat %", + "title": "Tuple operations", + "transformations": [ + { + "id": "calculateField", + "options": { + "alias": "Non-HOT updates", + "binary": { + "left": { + "matcher": { + "id": "byName", + "options": "Updates" + } + }, + "operator": "-", + "right": { + "matcher": { + "id": "byName", + "options": "HOT updates" + } + } + }, + "mode": "binary", + "reduce": { + "reducer": "sum" + } + } + }, + { + "id": "organize", + "options": { + "excludeByName": { + "Updates": true + }, + "includeByName": {}, + "indexByName": {}, + "renameByName": { + "Hot Updates": "HOT Updates" + } + } + } + ], "type": "timeseries" }, - { - "collapsed": false, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 83 - }, - "id": 30, - "panels": [], - "title": "Tuple stats", - "type": "row" - }, { "datasource": { "type": "prometheus", @@ -1000,13 +984,13 @@ } ] }, - "unit": "ops" + "unit": "percentunit" }, "overrides": [ { "matcher": { "id": "byName", - "options": "Inserts" + "options": "Inserts %" }, "properties": [ { @@ -1021,13 +1005,13 @@ { "matcher": { "id": "byName", - "options": "Deletes" + "options": "Non-HOT-Updates %" }, "properties": [ { "id": "color", "value": { - "fixedColor": "dark-red", + "fixedColor": "yellow", "mode": "fixed" } } @@ -1036,7 +1020,7 @@ { "matcher": { "id": "byName", - "options": "HOT Updates" + "options": "HOT-Updates" }, "properties": [ { @@ -1051,13 +1035,13 @@ { "matcher": { "id": "byName", - "options": "Non-HOT Updates" + "options": "Deletes %" }, "properties": [ { "id": "color", "value": { - "fixedColor": "yellow", + "fixedColor": "dark-red", "mode": "fixed" } } @@ -1067,11 +1051,11 @@ }, "gridPos": { "h": 10, - "w": 24, - "x": 0, - "y": 84 + "w": 12, + "x": 12, + "y": 29 }, - "id": 21, + "id": 37, "options": { "legend": { "calcs": [ @@ -1100,7 +1084,7 @@ }, "disableTextWrap": false, "editorMode": "code", - "expr": "sum by (node_name, table_full_name, dbname, cluster) (irate(pgwatch_table_stats_n_tup_ins{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=\"$schema_name\", table_name=\"$table_name\"}[$__rate_interval]))", + "expr": "sum(irate(pgwatch_table_stats_n_tup_ins{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\", table_name=~\"$table_name\"}[$__rate_interval]))", "fullMetaSearch": false, "includeNullMetadata": true, "interval": "60", @@ -1116,7 +1100,7 @@ }, "disableTextWrap": false, "editorMode": "code", - "expr": "sum by (node_name, table_full_name, dbname, cluster) (irate(pgwatch_table_stats_n_tup_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=\"$schema_name\", table_name=\"$table_name\"}[$__rate_interval]))", + "expr": "sum(irate(pgwatch_table_stats_n_tup_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\", table_name=~\"$table_name\"}[$__rate_interval]))", "fullMetaSearch": false, "hide": false, "includeNullMetadata": true, @@ -1133,7 +1117,7 @@ }, "disableTextWrap": false, "editorMode": "code", - "expr": "sum by (node_name, table_full_name, dbname, cluster) (irate(pgwatch_table_stats_n_tup_hot_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=\"$schema_name\", table_name=\"$table_name\"}[$__rate_interval]))", + "expr": "sum(irate(pgwatch_table_stats_n_tup_hot_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\", table_name=~\"$table_name\"}[$__rate_interval]))", "fullMetaSearch": false, "hide": false, "includeNullMetadata": true, @@ -1150,7 +1134,7 @@ }, "disableTextWrap": false, "editorMode": "code", - "expr": "sum by (node_name, table_full_name, dbname, cluster) (irate(pgwatch_table_stats_n_tup_del{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=\"$schema_name\", table_name=\"$table_name\"}[$__rate_interval]))", + "expr": "sum(irate(pgwatch_table_stats_n_tup_del{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\", table_name=~\"$table_name\"}[$__rate_interval]))", "fullMetaSearch": false, "hide": false, "includeNullMetadata": true, @@ -1161,7 +1145,7 @@ "useBackend": false } ], - "title": "Tuple operations", + "title": "Tuple operations (%)", "transformations": [ { "id": "calculateField", @@ -1189,34 +1173,153 @@ } }, { - "id": "organize", + "id": "calculateField", "options": { - "excludeByName": { - "Updates": true + "mode": "reduceRow", + "reduce": { + "include": [ + "Inserts", + "Deletes", + "Updates" + ], + "reducer": "sum" + } + } + }, + { + "id": "calculateField", + "options": { + "alias": "Inserts %", + "binary": { + "left": { + "matcher": { + "id": "byName", + "options": "Inserts" + } + }, + "operator": "/", + "right": { + "matcher": { + "id": "byName", + "options": "Total" + } + } }, - "includeByName": {}, - "indexByName": {}, - "renameByName": { - "Hot Updates": "HOT Updates" + "mode": "binary", + "reduce": { + "reducer": "sum" } } - } - ], - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, + }, + { + "id": "calculateField", + "options": { + "alias": "Non-HOT-Updates %", + "binary": { + "left": { + "matcher": { + "id": "byName", + "options": "Non-HOT Updates" + } + }, + "operator": "/", + "right": { + "matcher": { + "id": "byName", + "options": "Total" + } + } + }, + "mode": "binary", + "reduce": { + "reducer": "sum" + } + } + }, + { + "id": "calculateField", + "options": { + "alias": "HOT-Updates", + "binary": { + "left": { + "matcher": { + "id": "byName", + "options": "HOT Updates" + } + }, + "operator": "/", + "right": { + "matcher": { + "id": "byName", + "options": "Total" + } + } + }, + "mode": "binary", + "reduce": { + "reducer": "sum" + } + } + }, + { + "id": "calculateField", + "options": { + "alias": "Deletes %", + "binary": { + "left": { + "matcher": { + "id": "byName", + "options": "Deletes" + } + }, + "operator": "/", + "right": { + "matcher": { + "id": "byName", + "options": "Total" + } + } + }, + "mode": "binary", + "reduce": { + "reducer": "sum" + } + } + }, + { + "id": "organize", + "options": { + "excludeByName": { + "Deletes": true, + "HOT Updates": true, + "Inserts": true, + "Non-HOT Updates": true, + "Total": true, + "Updates": true + }, + "includeByName": {}, + "indexByName": {}, + "renameByName": { + "Hot Updates": "HOT Updates" + } + } + } + ], + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", @@ -1261,78 +1364,17 @@ } ] }, - "unit": "percentunit" + "unit": "ops" }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "Inserts %" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "dark-green", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "Non-HOT-Updates %" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "yellow", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "HOT-Updates" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "orange", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "Deletes %" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "dark-red", - "mode": "fixed" - } - } - ] - } - ] + "overrides": [] }, "gridPos": { "h": 10, "w": 24, "x": 0, - "y": 94 + "y": 39 }, - "id": 37, + "id": 42, "options": { "legend": { "calcs": [ @@ -1343,7 +1385,7 @@ "displayMode": "table", "placement": "bottom", "showLegend": true, - "sortBy": "Max", + "sortBy": "Mean", "sortDesc": true }, "tooltip": { @@ -1355,17 +1397,13 @@ "pluginVersion": "12.0.2", "targets": [ { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, "disableTextWrap": false, "editorMode": "code", - "expr": "sum(irate(pgwatch_table_stats_n_tup_ins{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\", table_name=~\"$table_name\"}[$__rate_interval]))", + "expr": "irate(pgwatch_pg_stat_user_tables_seq_tup_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", "fullMetaSearch": false, "includeNullMetadata": true, - "interval": "60", - "legendFormat": "Inserts", + "interval": "20", + "legendFormat": "Fetched by sequential scans", "range": true, "refId": "A", "useBackend": false @@ -1377,211 +1415,504 @@ }, "disableTextWrap": false, "editorMode": "code", - "expr": "sum(irate(pgwatch_table_stats_n_tup_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\", table_name=~\"$table_name\"}[$__rate_interval]))", + "expr": "irate(pgwatch_pg_stat_user_tables_idx_tup_fetch{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])", "fullMetaSearch": false, "hide": false, "includeNullMetadata": true, - "interval": "60", - "legendFormat": "Updates", + "interval": "20", + "legendFormat": "Fetched by index scans", "range": true, "refId": "B", "useBackend": false - }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "sum(irate(pgwatch_table_stats_n_tup_hot_upd{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\", table_name=~\"$table_name\"}[$__rate_interval]))", - "fullMetaSearch": false, - "hide": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "HOT Updates", - "range": true, - "refId": "C", - "useBackend": false - }, - { - "datasource": { - "type": "prometheus", - "uid": "P7A0D6631BB10B34F" - }, - "disableTextWrap": false, - "editorMode": "code", - "expr": "sum(irate(pgwatch_table_stats_n_tup_del{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", schema=~\"$schema_name\", table_name=~\"$table_name\"}[$__rate_interval]))", - "fullMetaSearch": false, - "hide": false, - "includeNullMetadata": true, - "interval": "60", - "legendFormat": "Deletes", - "range": true, - "refId": "D", - "useBackend": false } ], - "title": "Tuple operations (%) (Aggregated)", - "transformations": [ - { - "id": "calculateField", - "options": { - "alias": "Non-HOT Updates", - "binary": { - "left": { - "matcher": { - "id": "byName", - "options": "Updates" - } - }, - "operator": "-", - "right": { - "matcher": { - "id": "byName", - "options": "HOT Updates" - } - } - }, - "mode": "binary", - "reduce": { - "reducer": "sum" - } - } - }, - { - "id": "calculateField", - "options": { - "mode": "reduceRow", - "reduce": { - "include": [ - "Inserts", - "Deletes", - "Updates" - ], - "reducer": "sum" + "title": "Live tuples fetch distribution", + "type": "timeseries" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 49 + }, + "id": 43, + "panels": [], + "title": "IO stats", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" } - } - }, - { - "id": "calculateField", - "options": { - "alias": "Inserts %", - "binary": { - "left": { - "matcher": { - "id": "byName", - "options": "Inserts" - } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" }, - "operator": "/", - "right": { - "matcher": { - "id": "byName", - "options": "Total" - } + { + "color": "red", + "value": 80 } - }, - "mode": "binary", - "reduce": { - "reducer": "sum" - } - } + ] + }, + "unit": "binBps" }, - { - "id": "calculateField", - "options": { - "alias": "Non-HOT-Updates %", - "binary": { - "left": { - "matcher": { - "id": "byName", - "options": "Non-HOT Updates" + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Total" + }, + "properties": [ + { + "id": "custom.stacking", + "value": { + "group": "A", + "mode": "none" } }, - "operator": "/", - "right": { - "matcher": { - "id": "byName", - "options": "Total" - } + { + "id": "custom.fillOpacity", + "value": 0 + }, + { + "id": "custom.lineWidth", + "value": 0 } - }, - "mode": "binary", - "reduce": { - "reducer": "sum" - } + ] } + ] + }, + "gridPos": { + "h": 13, + "w": 24, + "x": 0, + "y": 50 + }, + "id": 44, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ { - "id": "calculateField", - "options": { - "alias": "HOT-Updates", - "binary": { - "left": { - "matcher": { - "id": "byName", - "options": "HOT Updates" - } - }, - "operator": "/", - "right": { - "matcher": { - "id": "byName", - "options": "Total" - } - } - }, - "mode": "binary", - "reduce": { - "reducer": "sum" - } - } + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "editorMode": "code", + "expr": "irate(pgwatch_pg_statio_all_tables_heap_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) * on() group_left() last_over_time(pgwatch_settings_numeric_value{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", setting_name=\"block_size\"}[1d])", + "hide": false, + "instant": false, + "interval": "20", + "legendFormat": "Heap", + "range": true, + "refId": "B" }, { - "id": "calculateField", - "options": { - "alias": "Deletes %", - "binary": { - "left": { - "matcher": { - "id": "byName", - "options": "Deletes" - } - }, - "operator": "/", - "right": { - "matcher": { - "id": "byName", - "options": "Total" - } - } - }, - "mode": "binary", - "reduce": { - "reducer": "sum" - } - } + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "editorMode": "code", + "expr": "irate(pgwatch_pg_statio_all_tables_idx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) * on() group_left() last_over_time(pgwatch_settings_numeric_value{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", setting_name=\"block_size\"}[1d])", + "hide": false, + "instant": false, + "interval": "20", + "legendFormat": "Index", + "range": true, + "refId": "C" }, { - "id": "organize", - "options": { - "excludeByName": { - "Deletes": true, - "HOT Updates": true, - "Inserts": true, - "Non-HOT Updates": true, - "Total": true, - "Updates": true - }, - "includeByName": {}, - "indexByName": {}, - "renameByName": { - "Hot Updates": "HOT Updates" - } - } + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "editorMode": "code", + "expr": "irate(pgwatch_pg_statio_all_tables_toast_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) * on() group_left() last_over_time(pgwatch_settings_numeric_value{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", setting_name=\"block_size\"}[1d])", + "hide": false, + "instant": false, + "interval": "20", + "legendFormat": "TOAST", + "range": true, + "refId": "D" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "editorMode": "code", + "expr": "irate(pgwatch_pg_statio_all_tables_tidx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) * on() group_left() last_over_time(pgwatch_settings_numeric_value{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", setting_name=\"block_size\"}[1d])", + "hide": false, + "instant": false, + "interval": "20", + "legendFormat": "TOAST indexes", + "range": true, + "refId": "E" + } + ], + "title": "Shared block hits", + "transformations": [ + { + "id": "calculateField", + "options": {} + } + ], + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "binBps" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Total" + }, + "properties": [ + { + "id": "custom.stacking", + "value": { + "group": "A", + "mode": "none" + } + }, + { + "id": "custom.fillOpacity", + "value": 0 + }, + { + "id": "custom.lineWidth", + "value": 0 + } + ] + } + ] + }, + "gridPos": { + "h": 13, + "w": 24, + "x": 0, + "y": 63 + }, + "id": 45, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "editorMode": "code", + "expr": "irate(pgwatch_pg_statio_all_tables_heap_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) * on() group_left() last_over_time(pgwatch_settings_numeric_value{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", setting_name=\"block_size\"}[1d])", + "hide": false, + "instant": false, + "interval": "20", + "legendFormat": "Heap", + "range": true, + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "editorMode": "code", + "expr": "irate(pgwatch_pg_statio_all_tables_idx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) * on() group_left() last_over_time(pgwatch_settings_numeric_value{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", setting_name=\"block_size\"}[1d])", + "hide": false, + "instant": false, + "interval": "20", + "legendFormat": "Index", + "range": true, + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "editorMode": "code", + "expr": "irate(pgwatch_pg_statio_all_tables_toast_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) * on() group_left() last_over_time(pgwatch_settings_numeric_value{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", setting_name=\"block_size\"}[1d])", + "hide": false, + "instant": false, + "interval": "20", + "legendFormat": "TOAST", + "range": true, + "refId": "D" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "editorMode": "code", + "expr": "irate(pgwatch_pg_statio_all_tables_tidx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) * on() group_left() last_over_time(pgwatch_settings_numeric_value{datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", setting_name=\"block_size\"}[1d])", + "hide": false, + "instant": false, + "interval": "20", + "legendFormat": "TOAST indexes", + "range": true, + "refId": "E" + } + ], + "title": "Shared block reads", + "transformations": [ + { + "id": "calculateField", + "options": {} + } + ], + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMax": 1, + "axisSoftMin": 0, + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 100, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 1, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "noValue": "-", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 14, + "w": 24, + "x": 0, + "y": 76 + }, + "id": 46, + "options": { + "legend": { + "calcs": [ + "min", + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "code", + "expr": "\n (irate(pgwatch_pg_statio_all_tables_heap_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_idx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_toast_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_tidx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]))/(irate(pgwatch_pg_statio_all_tables_heap_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_idx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_toast_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_tidx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) + (irate(pgwatch_pg_statio_all_tables_heap_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_idx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_toast_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_tidx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])))", + "fullMetaSearch": false, + "includeNullMetadata": true, + "interval": "20", + "legendFormat": "Shared blocks hit", + "range": true, + "refId": "A", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "P7A0D6631BB10B34F" + }, + "editorMode": "code", + "expr": "\n (irate(pgwatch_pg_statio_all_tables_heap_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_idx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_toast_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_tidx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]))/(irate(pgwatch_pg_statio_all_tables_heap_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_idx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_toast_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_tidx_blks_read{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) + (irate(pgwatch_pg_statio_all_tables_heap_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_idx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_toast_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval]) + \n irate(pgwatch_pg_statio_all_tables_tidx_blks_hit{schemaname=~\"$schema_name\", datname=\"$db_name\", cluster=\"$cluster_name\", node_name=\"$node_name\", relname=\"$table_name\"}[$__rate_interval])))", + "hide": false, + "instant": false, + "interval": "20", + "legendFormat": "Shared blocks read", + "range": true, + "refId": "B" } ], + "title": "Shared block hit ratio", "type": "timeseries" }, { @@ -1593,7 +1924,7 @@ "h": 3, "w": 24, "x": 0, - "y": 104 + "y": 90 }, "id": 20, "options": { @@ -1708,12 +2039,12 @@ ] }, "time": { - "from": "now-3h", + "from": "now-6h", "to": "now" }, "timepicker": {}, "timezone": "utc", "title": "09. Single table analysis", "uid": "9-single-table-analysis", - "version": 21 + "version": 43 } \ No newline at end of file