diff --git a/docker/compose.grafana.yml b/docker/compose.grafana.yml
index d2f018e7d1..18a2435b08 100644
--- a/docker/compose.grafana.yml
+++ b/docker/compose.grafana.yml
@@ -20,7 +20,7 @@ services:
- "../grafana/prometheus_datasource.yml:/etc/grafana/provisioning/datasources/prometheus_datasource.yml"
# Uncomment the dashboard version you want to use and comment out the other one.
- "../grafana/postgres/v13:/var/lib/grafana/dashboards/postgres"
- - "../grafana/prometheus/v12:/var/lib/grafana/dashboards/prometheus"
+ - "../grafana/prometheus/v13:/var/lib/grafana/dashboards/prometheus"
depends_on:
postgres:
condition: service_healthy
diff --git a/grafana/postgres/v13/3-query-performance-analysis.json b/grafana/postgres/v13/3-query-performance-analysis.json
new file mode 100644
index 0000000000..8723114c38
--- /dev/null
+++ b/grafana/postgres/v13/3-query-performance-analysis.json
@@ -0,0 +1,2042 @@
+{
+ "apiVersion": "dashboard.grafana.app/v2",
+ "kind": "Dashboard",
+ "metadata": {
+ "name": "query-performance-analysis"
+ },
+ "spec": {
+ "annotations": [
+ {
+ "kind": "AnnotationQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "grafana"
+ },
+ "spec": {}
+ },
+ "enable": true,
+ "hide": true,
+ "iconColor": "rgba(0, 211, 255, 1)",
+ "name": "Annotations & Alerts",
+ "builtIn": true,
+ "legacyOptions": {
+ "type": "dashboard"
+ }
+ }
+ }
+ ],
+ "cursorSync": "Off",
+ "description": "Enhanced PostgreSQL statement analysis dashboard with comprehensive table view and visual analytics",
+ "editable": true,
+ "elements": {
+ "panel-10": {
+ "kind": "Panel",
+ "spec": {
+ "id": 10,
+ "title": "Top $top statements by temp_blks_written per second (in bytes)",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "rawQuery": true,
+ "rawSql": "with baseline as (\n select time\n from stat_statements\n where dbname = '$dbname' and time < $__timeFrom()::timestamptz\n order by time desc\n limit 1\n)\n\nselect\n time,\n queryid as metric,\n temp_blks_written_per_sec * 8192\nfrom\n(\n select \n *,\n row_number() over (partition by time order by temp_blks_written_per_sec desc nulls last) as rn\n from\n (\n select\n $__timeGroup(time, $agg_interval) as time,\n queryid,\n sum(temp_blks_written - temp_blks_written_lag) / nullif(extract(epoch from sum(time - time_lag)), 0) as temp_blks_written_per_sec\n from (\n select\n tag_data->>'queryid' as queryid,\n (data->>'temp_blks_written')::int8 as temp_blks_written, lag((data->>'temp_blks_written')::int8) over w as temp_blks_written_lag,\n time, lag(time) over w as time_lag\n from stat_statements\n where time <= $__timeTo()::timestamptz\n and time >= coalesce((select time from baseline), $__timeFrom()::timestamptz)\n and dbname = '$dbname'\n and tag_data->>'query' ~* '$query_filter_regex'\n window w as (partition by tag_data->>'queryid' order by time)\n )\n where time_lag is not null\n group by 1, 2\n )\n)\nwhere rn <= $top and temp_blks_written_per_sec is not null\norder by time",
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ }
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.4",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "min",
+ "max",
+ "mean"
+ ],
+ "displayMode": "table",
+ "placement": "bottom",
+ "showLegend": true,
+ "sortBy": "Max",
+ "sortDesc": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "bytes",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "links": [
+ {
+ "title": "View Query Details",
+ "url": "/d/single-query-details/single-query-details?var-dbname=${dbname}&var-queryid=${__field.labels.queryid}&${__url_time_range}"
+ }
+ ],
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 97,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "vis": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "showValues": false,
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "normal"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-12": {
+ "kind": "Panel",
+ "spec": {
+ "id": 12,
+ "title": "",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "text",
+ "version": "12.3.4",
+ "spec": {
+ "options": {
+ "code": {
+ "language": "plaintext",
+ "showLineNumbers": false,
+ "showMiniMap": false
+ },
+ "content": "## Brought to you by\n\n\n \n",
+ "mode": "markdown"
+ },
+ "fieldConfig": {
+ "defaults": {},
+ "overrides": []
+ }
+ }
+ },
+ "transparent": true
+ }
+ },
+ "panel-13": {
+ "kind": "Panel",
+ "spec": {
+ "id": 13,
+ "title": "Top $top statements by execution time per call",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "editorMode": "code",
+ "format": "time_series",
+ "rawQuery": true,
+ "rawSql": "with baseline as (\n select time\n from stat_statements\n where dbname = '$dbname' and time < $__timeFrom()::timestamptz\n order by time desc\n limit 1\n)\n\nselect\n time,\n queryid as metric,\n time_per_call\nfrom\n(\n select \n *,\n row_number() over (partition by time order by time_per_call desc nulls last) as rn\n from\n (\n select\n $__timeGroup(time, $agg_interval) as time,\n queryid,\n sum(t - t_lag) / nullif(sum(c - c_lag), 0) as time_per_call\n from (\n select\n time,\n tag_data->>'queryid' as queryid,\n (data->>'total_time')::float8 as t, lag((data->>'total_time')::float8) over w as t_lag,\n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag\n from stat_statements\n where time <= $__timeTo()::timestamptz\n and time >= coalesce((select time from baseline), $__timeFrom()::timestamptz)\n and dbname = '$dbname'\n and tag_data->>'query' ~* '$query_filter_regex'\n window w as (partition by tag_data->>'queryid' order by time)\n )\n where c_lag is not null\n group by 1, 2\n )\n)\nwhere rn <= $top and time_per_call is not null\norder by time",
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ }
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.4",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "min",
+ "max",
+ "mean"
+ ],
+ "displayMode": "table",
+ "placement": "bottom",
+ "showLegend": true,
+ "sortBy": "Max",
+ "sortDesc": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "ms",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "links": [
+ {
+ "title": "View Query Details",
+ "url": "/d/single-query-details/single-query-details?var-dbname=${dbname}&var-queryid=${__field.name}&${__url_time_range}"
+ }
+ ],
+ "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,
+ "vis": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "showValues": false,
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-2": {
+ "kind": "Panel",
+ "spec": {
+ "id": 2,
+ "title": "Enhanced Query Performance Analysis Table",
+ "description": "Comprehensive query performance analysis from pg_stat_statements.\n\n**Column Guide:**\n- **Query ID** - Internal PostgreSQL query identifier (click to drill down)\n- **Total Runtime** - Total cumulative execution time\n- **% DB Total** - Percentage of total database execution time\n- **Avg Runtime** - Average execution time per call\n- **Plan Time** - Total time spent planning queries\n- **Avg Plan Time** - Average planning time per call\n- **Calls** - Number of times executed\n- **Rows** - Total rows retrieved/affected\n- **Avg Rows** - Average rows per execution\n- **Shared Hit (MB)** - Buffer cache hits - data found in memory (higher is better)\n- **Shared Read (MB)** - Data read from disk into shared buffers (cache misses)\n- **Shared Written (MB)** - Data written from shared buffers to disk\n- **Temp Read (MB)** - Data read from temporary files (indicates memory pressure)\n- **Temp Written (MB)** - Data written to temporary files during large operations\n- **JIT %** - Percentage of total query execution time spent in JIT\n- **IO Time** - Time spent on disk I/O operations (requires track_io_timing)\n- **Users** - Database roles that executed this query\n- **Query** - Normalized SQL text with constants replaced by placeholders",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "rawQuery": true,
+ "rawSql": "-- Enhanced comprehensive query analysis (Fast mode)\nWITH query_stats AS (\n select\n tag_data->>'queryid' as queryid,\n max((data->>'total_time')::numeric) - min((data->>'total_time')::numeric) as total_runtime,\n (max((data->>'total_time')::numeric) - min((data->>'total_time')::numeric)) / nullif(max((data->>'calls')::int8) - min((data->>'calls')::int8), 0) as avg_runtime,\n max((data->>'total_plan_time')::numeric) - min((data->>'total_plan_time')::numeric) as plan_time,\n (max((data->>'total_plan_time')::numeric) - min((data->>'total_plan_time')::numeric)) / nullif(max((data->>'calls')::int8) - min((data->>'calls')::int8), 0) as avg_plan_time,\n max((data->>'calls')::int8) - min((data->>'calls')::int8) as calls,\n max((data->>'rows')::int8) - min((data->>'rows')::int8) as rows,\n (max((data->>'rows')::int8) - min((data->>'rows')::int8))::numeric / nullif(max((data->>'calls')::int8) - min((data->>'calls')::int8), 0) as avg_rows,\n (max((data->>'shared_blks_hit')::int8) - min((data->>'shared_blks_hit')::int8)) * 8192 / 1024.0 / 1024.0 as shared_hit_mb,\n (max((data->>'shared_blks_read')::int8) - min((data->>'shared_blks_read')::int8)) * 8192 / 1024.0 / 1024.0 as shared_read_mb,\n (max((data->>'shared_blks_written')::int8) - min((data->>'shared_blks_written')::int8)) * 8192 / 1024.0 / 1024.0 as shared_written_mb,\n (max((data->>'temp_blks_read')::int8) - min((data->>'temp_blks_read')::int8)) * 8192 / 1024.0 / 1024.0 as temp_read_mb,\n (max((data->>'temp_blks_written')::int8) - min((data->>'temp_blks_written')::int8)) * 8192 / 1024.0 / 1024.0 as temp_written_mb,\n (max((data->>'blk_read_time')::numeric) - min((data->>'blk_read_time')::numeric)) + \n (max((data->>'blk_write_time')::numeric) - min((data->>'blk_write_time')::numeric)) as io_time,\n (max((data->>'jit_generation_time')::numeric) - min((data->>'jit_generation_time')::numeric)) as jit_time,\n case when length(tag_data->>'query') > 150 then (tag_data->>'query')::varchar(150) || '...' else tag_data->>'query' end as query\n from stat_statements\n where dbname = '$dbname'\n and $__timeFilter(time)\n and tag_data->>'query' ~* '$query_filter_regex'\n group by tag_data->>'queryid', tag_data->>'query'\n having max((data->>'calls')::int8) - min((data->>'calls')::int8) > 0\n),\nwith_percentages AS (\n select \n *,\n 100 * total_runtime / nullif((select sum(total_runtime) from query_stats), 0) as pct_db_total\n from query_stats\n)\nselect\n queryid,\n total_runtime::numeric as \"Total Runtime\",\n pct_db_total::numeric(5,1) as \"% DB Total\",\n avg_runtime::numeric(10,2) as \"Avg Runtime\",\n plan_time::numeric as \"Plan Time\",\n avg_plan_time::numeric(10,2) as \"Avg Plan Time\",\n calls as \"Calls\",\n rows as \"Rows\",\n avg_rows::numeric(10,1) as \"Avg Rows\",\n shared_hit_mb::numeric(10,1) as \"Shared Hit\",\n shared_read_mb::numeric(10,1) as \"Shared Read\",\n shared_written_mb::numeric(10,1) as \"Shared Written\",\n temp_read_mb::numeric(10,1) as \"Temp Read\",\n temp_written_mb::numeric(10,1) as \"Temp Written\",\n case when total_runtime::int8 = 0 then 0 else jit_time::numeric(10, 2) / total_runtime::int8 end as \"JIT %\",\n io_time::numeric(10,1) as \"IO Time\",\n (select data->>'users' from stat_statements where $__timeFilter(time) and dbname = '$dbname' and tag_data->>'queryid' = with_percentages.queryid order by time desc limit 1) as \"Users\",\n query as \"Query\"\nfrom with_percentages\norder by total_runtime desc nulls last\nlimit $top",
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ }
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.4",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true,
+ "sortBy": [
+ {
+ "desc": true,
+ "displayName": "Total Runtime"
+ }
+ ]
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Time"
+ },
+ "properties": [
+ {
+ "id": "custom.hideFrom.viz",
+ "value": true
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "queryid"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Query ID"
+ },
+ {
+ "id": "unit",
+ "value": "string"
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": true,
+ "title": "Opens 'Single query details' dashboard for that queryid",
+ "url": "/d/single-query-details?orgId=1&var-dbname=${dbname}&var-queryid=${__value.raw}&from=${__from}&to=${__to}"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Total Runtime"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "ms"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Avg Runtime"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "ms"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Plan Time"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "ms"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Avg Plan Time"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "ms"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Calls"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 0
+ },
+ {
+ "id": "custom.width",
+ "value": 76
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Rows"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 0
+ },
+ {
+ "id": "custom.width",
+ "value": 73
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Avg Rows"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ },
+ {
+ "id": "custom.width",
+ "value": 86
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Shared Hit"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "decmbytes"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Shared Read"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "decmbytes"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Shared Written"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "decmbytes"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Temp Read"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "decmbytes"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Temp Written"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "decmbytes"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "IO Time"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "ms"
+ },
+ {
+ "id": "decimals",
+ "value": 0
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "% DB Total"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "percent"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Query ID"
+ },
+ "properties": [
+ {
+ "id": "custom.width",
+ "value": 229
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "JIT Time"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "ms"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "JIT %"
+ },
+ "properties": [
+ {
+ "id": "custom.width",
+ "value": 114
+ },
+ {
+ "id": "unit",
+ "value": "percent"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Users"
+ },
+ "properties": [
+ {
+ "id": "custom.width",
+ "value": 0
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Query"
+ },
+ "properties": [
+ {
+ "id": "custom.inspect",
+ "value": true
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-4": {
+ "kind": "Panel",
+ "spec": {
+ "id": 4,
+ "title": "Top $top statements by calls per second",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "editorMode": "code",
+ "format": "time_series",
+ "rawQuery": true,
+ "rawSql": "with baseline as (\n select time\n from stat_statements\n where dbname = '$dbname' and time < $__timeFrom()::timestamptz\n order by time desc\n limit 1\n)\n\nselect\n time,\n queryid as metric,\n calls_per_sec\nfrom\n(\n select \n *,\n row_number() over (partition by time order by calls_per_sec desc nulls last) as rn\n from\n (\n select\n $__timeGroup(time, $agg_interval) as time,\n queryid,\n sum(c - c_lag) / nullif(extract(epoch from sum(time - time_lag)), 0) as calls_per_sec\n from (\n select\n tag_data->>'queryid' as queryid,\n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from stat_statements\n where time <= $__timeTo()::timestamptz\n and time >= coalesce((select time from baseline), $__timeFrom()::timestamptz)\n and dbname = '$dbname'\n and tag_data->>'query' ~* '$query_filter_regex'\n window w as (partition by tag_data->>'queryid' order by time)\n )\n where time_lag is not null\n group by 1, 2\n )\n)\nwhere rn <= $top and calls_per_sec is not null\norder by time",
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ }
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.4",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "min",
+ "max",
+ "mean"
+ ],
+ "displayMode": "table",
+ "placement": "bottom",
+ "showLegend": true,
+ "sortBy": "Max",
+ "sortDesc": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "calls/s",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "links": [
+ {
+ "title": "View Query Details",
+ "url": "/d/single-query-details/single-query-details?var-dbname=${dbname}&var-queryid=${__field.name}&${__url_time_range}"
+ }
+ ],
+ "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,
+ "vis": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "showValues": false,
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "normal"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-5": {
+ "kind": "Panel",
+ "spec": {
+ "id": 5,
+ "title": "Top $top statements by execution time per second",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "rawQuery": true,
+ "rawSql": "with baseline as (\n select time\n from stat_statements\n where dbname = '$dbname' and time < $__timeFrom()::timestamptz\n order by time desc\n limit 1\n)\n\nselect\n time,\n queryid as metric,\n time_per_sec\nfrom\n(\n select \n *,\n row_number() over (partition by time order by time_per_sec desc nulls last) as rn\n from\n (\n select\n $__timeGroup(time, $agg_interval) as time,\n queryid,\n sum(t - t_lag) / nullif(extract(epoch from sum(time - time_lag)), 0) as time_per_sec\n from (\n select\n tag_data->>'queryid' as queryid,\n (data->>'total_time')::float8 as t, lag((data->>'total_time')::float8) over w as t_lag,\n time, lag(time) over w as time_lag\n from stat_statements\n where time <= $__timeTo()::timestamptz\n and time >= coalesce((select time from baseline), $__timeFrom()::timestamptz)\n and dbname = '$dbname'\n and tag_data->>'query' ~* '$query_filter_regex'\n window w as (partition by tag_data->>'queryid' order by time)\n )\n where time_lag is not null\n group by 1, 2\n )\n)\nwhere rn <= $top and time_per_sec is not null\norder by time",
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ }
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.4",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "min",
+ "max",
+ "mean"
+ ],
+ "displayMode": "table",
+ "placement": "bottom",
+ "showLegend": true,
+ "sortBy": "Max",
+ "sortDesc": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "ms",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "links": [
+ {
+ "title": "View Query Details",
+ "url": "/d/single-query-details/single-query-details?var-dbname=${dbname}&var-queryid=${__field.name}&${__url_time_range}"
+ }
+ ],
+ "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,
+ "vis": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "showValues": false,
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "normal"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-6": {
+ "kind": "Panel",
+ "spec": {
+ "id": 6,
+ "title": "Top $top statements by rows retrieved/affected per second",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "rawQuery": true,
+ "rawSql": "with baseline as (\n select time\n from stat_statements\n where dbname = '$dbname' and time < $__timeFrom()::timestamptz\n order by time desc\n limit 1\n)\n\nselect\n time,\n queryid as metric,\n rows_per_sec\nfrom\n(\n select \n *,\n row_number() over (partition by time order by rows_per_sec desc nulls last) as rn\n from\n (\n select\n $__timeGroup(time, $agg_interval) as time,\n queryid,\n sum(rows - rows_lag) / nullif(extract(epoch from sum(time - time_lag)), 0) as rows_per_sec\n from (\n select\n tag_data->>'queryid' as queryid,\n (data->>'rows')::int8 as rows, lag((data->>'rows')::int8) over w as rows_lag,\n time, lag(time) over w as time_lag\n from stat_statements\n where time <= $__timeTo()::timestamptz\n and time >= coalesce((select time from baseline), $__timeFrom()::timestamptz)\n and dbname = '$dbname'\n and tag_data->>'query' ~* '$query_filter_regex'\n window w as (partition by tag_data->>'queryid' order by time)\n )\n where time_lag is not null\n group by 1, 2\n )\n)\nwhere rn <= $top and rows_per_sec is not null\norder by time",
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ }
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.4",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "min",
+ "max",
+ "mean"
+ ],
+ "displayMode": "table",
+ "placement": "bottom",
+ "showLegend": true,
+ "sortBy": "Max",
+ "sortDesc": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "rowsps",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "links": [
+ {
+ "title": "View Query Details",
+ "url": "/d/single-query-details/single-query-details?var-dbname=${dbname}&var-queryid=${__field.name}&${__url_time_range}"
+ }
+ ],
+ "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,
+ "vis": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "showValues": false,
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "normal"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-7": {
+ "kind": "Panel",
+ "spec": {
+ "id": 7,
+ "title": "Top $top statements by shared_blks_hit per second (in bytes)",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "rawQuery": true,
+ "rawSql": "with baseline as (\n select time\n from stat_statements\n where dbname = '$dbname' and time < $__timeFrom()::timestamptz\n order by time desc\n limit 1\n)\n\nselect\n time,\n queryid as metric,\n blks_hit_per_sec * 8192\nfrom\n(\n select \n *,\n row_number() over (partition by time order by blks_hit_per_sec desc nulls last) as rn\n from\n (\n select\n $__timeGroup(time, $agg_interval) as time,\n queryid,\n sum(blks_hit - blks_hit_lag) / nullif(extract(epoch from sum(time - time_lag)), 0) as blks_hit_per_sec\n from (\n select\n tag_data->>'queryid' as queryid,\n (data->>'shared_blks_hit')::int8 as blks_hit, lag((data->>'shared_blks_hit')::int8) over w as blks_hit_lag,\n time, lag(time) over w as time_lag\n from stat_statements\n where time <= $__timeTo()::timestamptz\n and time >= coalesce((select time from baseline), $__timeFrom()::timestamptz)\n and dbname = '$dbname'\n and tag_data->>'query' ~* '$query_filter_regex'\n window w as (partition by tag_data->>'queryid' order by time)\n )\n where time_lag is not null\n group by 1, 2\n )\n)\nwhere rn <= $top and blks_hit_per_sec is not null\norder by time",
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ }
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.4",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "min",
+ "max",
+ "mean"
+ ],
+ "displayMode": "table",
+ "placement": "bottom",
+ "showLegend": true,
+ "sortBy": "Max",
+ "sortDesc": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "bytes",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "links": [
+ {
+ "title": "View Query Details",
+ "url": "/d/single-query-details/single-query-details?var-dbname=${dbname}&var-queryid=${__field.name}&${__url_time_range}"
+ }
+ ],
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 98,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "vis": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "showValues": false,
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "normal"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-8": {
+ "kind": "Panel",
+ "spec": {
+ "id": 8,
+ "title": "Top $top statements by shared_blks_read per second (in bytes)",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "rawQuery": true,
+ "rawSql": "with baseline as (\n select time\n from stat_statements\n where dbname = '$dbname' and time < $__timeFrom()::timestamptz\n order by time desc\n limit 1\n)\n\nselect\n time,\n queryid as metric,\n blks_read_per_sec * 8192\nfrom\n(\n select \n *,\n row_number() over (partition by time order by blks_read_per_sec desc nulls last) as rn\n from\n (\n select\n $__timeGroup(time, $agg_interval) as time,\n queryid,\n sum(blks_read - blks_read_lag) / nullif(extract(epoch from sum(time - time_lag)), 0) as blks_read_per_sec\n from (\n select\n tag_data->>'queryid' as queryid,\n (data->>'shared_blks_read')::int8 as blks_read, lag((data->>'shared_blks_read')::int8) over w as blks_read_lag,\n time, lag(time) over w as time_lag\n from stat_statements\n where time <= $__timeTo()::timestamptz\n and time >= coalesce((select time from baseline), $__timeFrom()::timestamptz)\n and dbname = '$dbname'\n and tag_data->>'query' ~* '$query_filter_regex'\n window w as (partition by tag_data->>'queryid' order by time)\n )\n where time_lag is not null\n group by 1, 2\n )\n)\nwhere rn <= $top and blks_read_per_sec is not null\norder by time",
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ }
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.4",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "min",
+ "max",
+ "mean"
+ ],
+ "displayMode": "table",
+ "placement": "bottom",
+ "showLegend": true,
+ "sortBy": "Max",
+ "sortDesc": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "bytes",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "links": [
+ {
+ "title": "View Query Details",
+ "url": "/d/single-query-details/single-query-details?var-dbname=${dbname}&var-queryid=${__field.name}&${__url_time_range}"
+ }
+ ],
+ "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,
+ "vis": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "showValues": false,
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "normal"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-9": {
+ "kind": "Panel",
+ "spec": {
+ "id": 9,
+ "title": "Top $top statements by temp_blks_read per second (in bytes)",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "editorMode": "code",
+ "format": "time_series",
+ "rawQuery": true,
+ "rawSql": "with baseline as (\n select time\n from stat_statements\n where dbname = '$dbname' and time < $__timeFrom()::timestamptz\n order by time desc\n limit 1\n)\n\nselect\n time,\n queryid as metric,\n temp_blks_read_per_sec * 8192\nfrom\n(\n select \n *,\n row_number() over (partition by time order by temp_blks_read_per_sec desc nulls last) as rn\n from\n (\n select\n $__timeGroup(time, $agg_interval) as time,\n queryid,\n sum(temp_blks_read - temp_blks_read_lag) / nullif(extract(epoch from sum(time - time_lag)), 0) as temp_blks_read_per_sec\n from (\n select\n tag_data->>'queryid' as queryid,\n (data->>'temp_blks_read')::int8 as temp_blks_read, lag((data->>'temp_blks_read')::int8) over w as temp_blks_read_lag,\n time, lag(time) over w as time_lag\n from stat_statements\n where time <= $__timeTo()::timestamptz\n and time >= coalesce((select time from baseline), $__timeFrom()::timestamptz)\n and dbname = '$dbname'\n and tag_data->>'query' ~* '$query_filter_regex'\n window w as (partition by tag_data->>'queryid' order by time)\n )\n where time_lag is not null\n group by 1, 2\n )\n)\nwhere rn <= $top and temp_blks_read_per_sec is not null\norder by time",
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ }
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.4",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "min",
+ "max",
+ "mean"
+ ],
+ "displayMode": "table",
+ "placement": "bottom",
+ "showLegend": true,
+ "sortBy": "Max",
+ "sortDesc": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "bytes",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "links": [
+ {
+ "title": "View Query Details",
+ "url": "/d/single-query-details/single-query-details?var-dbname=${dbname}&var-queryid=${__field.labels.queryid}&${__url_time_range}"
+ }
+ ],
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 98,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "vis": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "showValues": false,
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "normal"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ }
+ },
+ "layout": {
+ "kind": "RowsLayout",
+ "spec": {
+ "rows": [
+ {
+ "kind": "RowsLayoutRow",
+ "spec": {
+ "title": "Comprehensive Query Analysis Table (pg_stat_statements)",
+ "collapse": false,
+ "layout": {
+ "kind": "GridLayout",
+ "spec": {
+ "items": [
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 0,
+ "width": 24,
+ "height": 12,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-2"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "kind": "RowsLayoutRow",
+ "spec": {
+ "title": "Top $top queries visual analysis (pg_stat_statements)",
+ "collapse": false,
+ "layout": {
+ "kind": "GridLayout",
+ "spec": {
+ "items": [
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 0,
+ "width": 24,
+ "height": 8,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-4"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 8,
+ "width": 12,
+ "height": 8,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-5"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 12,
+ "y": 8,
+ "width": 12,
+ "height": 8,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-13"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 16,
+ "width": 12,
+ "height": 8,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-7"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 12,
+ "y": 16,
+ "width": 12,
+ "height": 8,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-8"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 24,
+ "width": 12,
+ "height": 8,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-9"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 12,
+ "y": 24,
+ "width": 12,
+ "height": 8,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-10"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 32,
+ "width": 12,
+ "height": 8,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-6"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 12,
+ "y": 32,
+ "width": 12,
+ "height": 8,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-12"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ }
+ },
+ "links": [],
+ "liveNow": false,
+ "preload": false,
+ "tags": [
+ "pgwatch"
+ ],
+ "timeSettings": {
+ "timezone": "browser",
+ "from": "now-24h",
+ "to": "now",
+ "autoRefresh": "",
+ "autoRefreshIntervals": [
+ "5s",
+ "10s",
+ "30s",
+ "1m",
+ "5m",
+ "15m",
+ "30m",
+ "1h",
+ "2h",
+ "1d"
+ ],
+ "hideTimepicker": false,
+ "fiscalYearStartMonth": 0
+ },
+ "title": "3. Query Performance Analysis",
+ "variables": [
+ {
+ "kind": "QueryVariable",
+ "spec": {
+ "name": "dbname",
+ "current": {
+ "text": "",
+ "value": ""
+ },
+ "label": "Database",
+ "hide": "dontHide",
+ "refresh": "onDashboardLoad",
+ "skipUrlSync": false,
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "__legacyStringValue": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'stat_statements' ORDER BY 1;"
+ }
+ },
+ "regex": "",
+ "sort": "disabled",
+ "definition": "",
+ "options": [],
+ "multi": false,
+ "includeAll": false,
+ "allowCustomValue": true
+ }
+ },
+ {
+ "kind": "CustomVariable",
+ "spec": {
+ "name": "top",
+ "query": "5,10,15,20,30,50",
+ "current": {
+ "text": "10",
+ "value": "10"
+ },
+ "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"
+ },
+ {
+ "selected": false,
+ "text": "30",
+ "value": "30"
+ },
+ {
+ "selected": false,
+ "text": "50",
+ "value": "50"
+ }
+ ],
+ "multi": false,
+ "includeAll": false,
+ "label": "Top N",
+ "hide": "dontHide",
+ "skipUrlSync": false,
+ "description": "Limit output to top N entries",
+ "allowCustomValue": true
+ }
+ },
+ {
+ "kind": "CustomVariable",
+ "spec": {
+ "name": "query_filter_regex",
+ "query": "^(?!.*pgwatch_generated),.*,^(?!.*SELECT),(UPDATE|DELETE|INSERT),UPDATE.*^(?!.*WHERE)",
+ "current": {
+ "text": ".*",
+ "value": ".*"
+ },
+ "options": [
+ {
+ "selected": false,
+ "text": "^(?!.*pgwatch_generated)",
+ "value": "^(?!.*pgwatch_generated)"
+ },
+ {
+ "selected": true,
+ "text": ".*",
+ "value": ".*"
+ },
+ {
+ "selected": false,
+ "text": "^(?!.*SELECT)",
+ "value": "^(?!.*SELECT)"
+ },
+ {
+ "selected": false,
+ "text": "(UPDATE|DELETE|INSERT)",
+ "value": "(UPDATE|DELETE|INSERT)"
+ },
+ {
+ "selected": false,
+ "text": "UPDATE.*^(?!.*WHERE)",
+ "value": "UPDATE.*^(?!.*WHERE)"
+ }
+ ],
+ "multi": false,
+ "includeAll": false,
+ "label": "Filter RegEx",
+ "hide": "dontHide",
+ "skipUrlSync": false,
+ "description": "Custom regex filter for queries. Examples: '.*' (all queries), '^(?!.*pgwatch_generated)' (exclude pgwatch_generated), '(SELECT|INSERT)' (include only SELECT/INSERT), '^(?!.*(SELECT|INSERT))' (exclude SELECT/INSERT), 'UPDATE.*^(?!.*WHERE)' (dangerous UPDATEs without WHERE - security risk).",
+ "allowCustomValue": true
+ }
+ },
+ {
+ "kind": "IntervalVariable",
+ "spec": {
+ "name": "agg_interval",
+ "query": "3m,6m,9m,12m,15m,30m",
+ "current": {
+ "text": "6m",
+ "value": "6m"
+ },
+ "options": [
+ {
+ "selected": false,
+ "text": "3m",
+ "value": "3m"
+ },
+ {
+ "selected": true,
+ "text": "6m",
+ "value": "6m"
+ },
+ {
+ "selected": false,
+ "text": "9m",
+ "value": "9m"
+ },
+ {
+ "selected": false,
+ "text": "12m",
+ "value": "12m"
+ },
+ {
+ "selected": false,
+ "text": "15m",
+ "value": "15m"
+ },
+ {
+ "selected": false,
+ "text": "30m",
+ "value": "30m"
+ }
+ ],
+ "auto": false,
+ "auto_min": "10s",
+ "auto_count": 30,
+ "refresh": "onTimeRangeChanged",
+ "label": "Aggregate Interval",
+ "hide": "dontHide",
+ "skipUrlSync": false
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/grafana/postgres/v13/4-tables-overview.json b/grafana/postgres/v13/4-tables-overview.json
new file mode 100644
index 0000000000..16f3333983
--- /dev/null
+++ b/grafana/postgres/v13/4-tables-overview.json
@@ -0,0 +1,2186 @@
+{
+ "apiVersion": "dashboard.grafana.app/v2",
+ "kind": "Dashboard",
+ "metadata": {
+ "name": "tables-overview"
+ },
+ "spec": {
+ "annotations": [
+ {
+ "kind": "AnnotationQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "grafana"
+ },
+ "spec": {}
+ },
+ "enable": true,
+ "hide": true,
+ "iconColor": "rgba(0, 211, 255, 1)",
+ "name": "Annotations & Alerts",
+ "builtIn": true,
+ "legacyOptions": {
+ "type": "dashboard"
+ }
+ }
+ }
+ ],
+ "cursorSync": "Off",
+ "description": "Combined dashboard showing table statistics and visualizations with tabbed interface",
+ "editable": true,
+ "elements": {
+ "panel-1": {
+ "kind": "Panel",
+ "spec": {
+ "id": 1,
+ "title": "Table Data Sizes Treemap",
+ "description": "Interactive treemap visualization showing table data sizes excluding indexes and TOAST. Useful for identifying tables with large amounts of actual data.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "rawQuery": true,
+ "rawSql": "SELECT\n 0 as time,\n (data->>'table_size_b')::int8 + coalesce((data->>'toast_size_b')::int8, 0) as table_size_b,\n tag_data->>'table_full_name' as table_name\nFROM\n table_stats\nWHERE\n time = (select max(time) from table_stats WHERE dbname = '$dbname' AND $__timeFilter(time))\n AND dbname = '$dbname'\nORDER BY\n 2 DESC NULLS LAST\nLIMIT 100"
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "marcusolsson-treemap-panel",
+ "version": "2.1.1",
+ "spec": {
+ "options": {
+ "sizeField": "table_size_b",
+ "textField": "table_name",
+ "tiling": "treemapSquarify"
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "bytes",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ }
+ ]
+ },
+ "color": {
+ "mode": "continuous-GrYlRd"
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-11": {
+ "kind": "Panel",
+ "spec": {
+ "id": 11,
+ "title": "Tables with Most Disk I/O Reads",
+ "description": "Tables with the most disk block reads during the selected time period. Based on pg_statio_user_tables. Assumes 8KB page size. High values may indicate insufficient shared_buffers or poor indexing.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "rawQuery": true,
+ "rawSql": "SELECT\n x.*,\n (data->>'table_size_b')::int8 as data_size,\n (data->>'seq_scan')::int8 - (select (data->>'seq_scan')::int8 from table_stats where dbname = '$dbname' and tag_data->>'table_full_name' = x.table_full_name and $__timeFilter(time) order by time limit 1) as seq_scan,\n (data->>'seconds_since_last_vacuum')::int8 as last_vacuum,\n (data->>'seconds_since_last_analyze')::int8 as last_analyze\nFROM (\nSELECT\n tag_data->>'table_full_name' as table_full_name,\n 8192 * (coalesce(max((data->>'heap_blks_read')::int8) - min((data->>'heap_blks_read')::int8), 0) + coalesce(max((data->>'toast_blks_read')::int8) - min((data->>'toast_blks_read')::int8), 0) + coalesce(max((data->>'tidx_blks_read')::int8) - min((data->>'tidx_blks_read')::int8), 0)) as blks_read\nFROM\n table_io_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY\n 1 \nHAVING\n max((data->>'heap_blks_read')::int8) > min((data->>'heap_blks_read')::int8)\nORDER BY\n 2 DESC NULLS LAST\nLIMIT\n $top\n) x\njoin lateral (select data from table_stats where dbname = '$dbname' and tag_data->>'table_full_name' = x.table_full_name and $__timeFilter(time) order by time desc limit 1) y on true",
+ "resultFormat": "table"
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "left",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "table_full_name"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Table Name"
+ },
+ {
+ "id": "custom.inspect",
+ "value": true
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": false,
+ "title": "View Table Details",
+ "url": "/d/table-details/table-details?orgId=1&var-dbname=${dbname}&var-table_full_name=${__data.fields.table_full_name}"
+ }
+ ]
+ },
+ {
+ "id": "custom.width",
+ "value": 200
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "blks_read"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Disk Reads"
+ },
+ {
+ "id": "unit",
+ "value": "bytes"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "data_size"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Table Size"
+ },
+ {
+ "id": "unit",
+ "value": "bytes"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "seq_scan"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Sequential Scans"
+ },
+ {
+ "id": "unit",
+ "value": "short"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "last_vacuum"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Last Vacuum"
+ },
+ {
+ "id": "unit",
+ "value": "s"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "last_analyze"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Last Analyze"
+ },
+ {
+ "id": "unit",
+ "value": "s"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-12": {
+ "kind": "Panel",
+ "spec": {
+ "id": 12,
+ "title": "Largest Tables by Total Size",
+ "description": "Tables ranked by total relation size (table + indexes + TOAST). Click on table name to view detailed metrics for that table.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "rawQuery": true,
+ "rawSql": "select\n x.*,\n (data->>'seconds_since_last_vacuum')::int8 as last_vacuum,\n (data->>'seconds_since_last_analyze')::int8 as last_analyze\nfrom (\nSELECT\n tag_data->>'table_full_name' as table_full_name,\n max((data->>'total_relation_size_b')::int8) as total_relation_size,\n max((data->>'table_size_b')::int8) as data_size\nFROM\n table_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 1 \nORDER BY 2 DESC NULLS LAST\nLIMIT $top\n) x\njoin lateral (select data from table_stats where dbname = '$dbname' and tag_data->>'table_full_name' = x.table_full_name and $__timeFilter(time) order by time desc limit 1) y on true",
+ "resultFormat": "table"
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "displayName": "",
+ "unit": "short",
+ "decimals": 2,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "left",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "table_full_name"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Table Name"
+ },
+ {
+ "id": "custom.inspect",
+ "value": true
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": false,
+ "title": "View Table Details",
+ "url": "/d/table-details/table-details?orgId=1&var-dbname=${dbname}&var-table_full_name=${__data.fields.table_full_name}"
+ }
+ ]
+ },
+ {
+ "id": "custom.width",
+ "value": 403
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "total_relation_size"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Total Size"
+ },
+ {
+ "id": "unit",
+ "value": "bytes"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "data_size"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Data Size"
+ },
+ {
+ "id": "unit",
+ "value": "bytes"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "last_vacuum"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Last Vacuum"
+ },
+ {
+ "id": "unit",
+ "value": "s"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "last_analyze"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Last Analyze"
+ },
+ {
+ "id": "unit",
+ "value": "s"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-13": {
+ "kind": "Panel",
+ "spec": {
+ "id": 13,
+ "title": "Largest Tables by Data Size",
+ "description": "Tables ranked by data size only (excluding indexes and TOAST). Click on table name to view detailed metrics for that table.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "rawQuery": true,
+ "rawSql": "SELECT\n x.*,\n (data->>'seconds_since_last_vacuum')::int8 as last_vacuum,\n (data->>'seconds_since_last_analyze')::int8 as last_analyze\nFROM (\nSELECT\n tag_data->>'table_full_name' as table_full_name,\n max((data->>'total_relation_size_b')::int8) as total_relation_size,\n max((data->>'table_size_b')::int8) as data_size\nFROM\n table_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 1 \nORDER BY 3 DESC NULLS LAST\nLIMIT $top\n) x\njoin lateral (select data from table_stats where dbname = '$dbname' and tag_data->>'table_full_name' = x.table_full_name and $__timeFilter(time) order by time desc limit 1) y on true",
+ "resultFormat": "table"
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "decimals": 2,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "left",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "table_full_name"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Table Name"
+ },
+ {
+ "id": "custom.inspect",
+ "value": true
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": false,
+ "title": "View Table Details",
+ "url": "/d/table-details/table-details?orgId=1&var-dbname=${dbname}&var-table_full_name=${__data.fields.table_full_name}"
+ }
+ ]
+ },
+ {
+ "id": "custom.width",
+ "value": 403
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "total_relation_size"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Total Size"
+ },
+ {
+ "id": "unit",
+ "value": "bytes"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "data_size"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Data Size"
+ },
+ {
+ "id": "unit",
+ "value": "bytes"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "last_vacuum"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Last Vacuum"
+ },
+ {
+ "id": "unit",
+ "value": "s"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "last_analyze"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Last Analyze"
+ },
+ {
+ "id": "unit",
+ "value": "s"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-2": {
+ "kind": "Panel",
+ "spec": {
+ "id": 2,
+ "title": "Index Sizes Treemap",
+ "description": "Interactive treemap visualization showing index sizes. Helps identify large indexes that may need optimization or rebuilding.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "rawQuery": true,
+ "rawSql": "SELECT\n 0 as time,\n (data->>'index_size_b')::int8 as index_size_b,\n tag_data->>'index_full_name' as index_full_name\nFROM\n index_stats\nWHERE\n time = (select max(time) from index_stats WHERE dbname = '$dbname' AND $__timeFilter(time))\n AND dbname = '$dbname'\nORDER BY\n 2 DESC NULLS LAST\nLIMIT 100"
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "maxDataPoints": 100
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "marcusolsson-treemap-panel",
+ "version": "2.1.1",
+ "spec": {
+ "options": {
+ "sizeField": "index_size_b",
+ "textField": "index_full_name",
+ "tiling": "treemapSquarify"
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "bytes",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ }
+ ]
+ },
+ "color": {
+ "mode": "continuous-GrYlRd"
+ },
+ "custom": {
+ "separator": "."
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-201": {
+ "kind": "Panel",
+ "spec": {
+ "id": 201,
+ "title": "",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "text",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "code": {
+ "language": "plaintext",
+ "showLineNumbers": false,
+ "showMiniMap": false
+ },
+ "content": "### Brought to you by\n\n[](https://www.cybertec-postgresql.com/en/)\n",
+ "mode": "markdown"
+ },
+ "fieldConfig": {
+ "defaults": {},
+ "overrides": []
+ }
+ }
+ },
+ "transparent": true
+ }
+ },
+ "panel-202": {
+ "kind": "Panel",
+ "spec": {
+ "id": 202,
+ "title": "Tables with oldest non-frozen xid age",
+ "description": "Tables with the oldest non-frozen transaction id age.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "editorMode": "code",
+ "format": "table",
+ "rawQuery": true,
+ "rawSql": "SELECT\n*\nFROM\n(\n SELECT DISTINCT ON (table_full_name)\n tag_data->>'table_full_name' as table_full_name,\n data->>'tx_freeze_age' as tx_freeze_age,\n (data->>'seconds_since_last_vacuum')::int8 as last_vacuum,\n (data->>'seconds_since_last_analyze')::int8 as last_analyze\n FROM\n table_stats\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n ORDER BY\n 1, time DESC\n)\nORDER BY 2 DESC NULLS LAST\nLIMIT $top\n",
+ "resultFormat": "table",
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ }
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "left",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "footer": {
+ "reducers": []
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "table_full_name"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Table Name"
+ },
+ {
+ "id": "custom.inspect",
+ "value": true
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": false,
+ "title": "View Table Details",
+ "url": "/d/table-details/table-details?orgId=1&var-dbname=${dbname}&var-table_full_name=${__data.fields.table_full_name}"
+ }
+ ]
+ },
+ {
+ "id": "custom.width",
+ "value": 440
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "last_vacuum"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Last Vacuum"
+ },
+ {
+ "id": "unit",
+ "value": "s"
+ },
+ {
+ "id": "custom.width"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "last_analyze"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Last Analyze"
+ },
+ {
+ "id": "unit",
+ "value": "s"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "tx_freeze_age"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Oldest non-frozen xid age"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Oldest non-frozen xid age"
+ },
+ "properties": [
+ {
+ "id": "custom.width",
+ "value": 246
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "dbname"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Source Name"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-3": {
+ "kind": "Panel",
+ "spec": {
+ "id": 3,
+ "title": "Table Sizes Treemap",
+ "description": "Interactive treemap visualization showing relative sizes of tables and their indexes. Larger rectangles represent bigger tables.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "rawQuery": true,
+ "rawSql": "SELECT\n time,\n (data->>'total_relation_size_b')::int8 as total_relation_size_b,\n tag_data->>'table_full_name'::text as table_name\nFROM\n table_stats\nWHERE\n time = (select max(time) from table_stats WHERE dbname = '$dbname' AND $__timeFilter(time))\n AND dbname = '$dbname'\nORDER BY\n 2 DESC NULLS LAST\nLIMIT 100"
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "maxDataPoints": 100
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "marcusolsson-treemap-panel",
+ "version": "2.1.1",
+ "spec": {
+ "options": {
+ "sizeField": "total_relation_size_b",
+ "textField": "table_name",
+ "tiling": "treemapSquarify"
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "bytes",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ }
+ ]
+ },
+ "color": {
+ "mode": "continuous-GrYlRd"
+ },
+ "custom": {
+ "separator": "."
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-4": {
+ "kind": "Panel",
+ "spec": {
+ "id": 4,
+ "title": "Tables with Most Sequential Scans",
+ "description": "Tables with the most sequential scans during the selected time period. Limited to tables larger than 100MB as seq scans on small tables are normal.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "rawQuery": true,
+ "rawSql": "SELECT\n x.*,\n (data->>'table_size_b')::int8 as table_size,\n (data->>'seconds_since_last_vacuum')::int8 as last_vacuum,\n (data->>'seconds_since_last_analyze')::int8 as last_analyze\nFROM (\nSELECT\n tag_data->>'table_full_name' as table_full_name,\n max((data->>'seq_scan')::int8) - min((data->>'seq_scan')::int8) as seq_scan\nFROM\n table_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n AND (data->>'table_size_b')::int8 > 100000000\n GROUP BY\n 1 \nHAVING\n max((data->>'seq_scan')::int8) > min((data->>'seq_scan')::int8)\nORDER BY\n 2 DESC\nLIMIT\n $top\n) x\njoin lateral (select data from table_stats where dbname = '$dbname' and tag_data->>'table_full_name' = x.table_full_name and $__timeFilter(time) order by time desc limit 1) y on true",
+ "resultFormat": "table"
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "decimals": 2,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "left",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "table_full_name"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Table Name"
+ },
+ {
+ "id": "custom.inspect",
+ "value": true
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": false,
+ "title": "View Table Details",
+ "url": "/d/table-details/table-details?orgId=1&var-dbname=${dbname}&var-table_full_name=${__data.fields.table_full_name}"
+ }
+ ]
+ },
+ {
+ "id": "custom.width",
+ "value": 403
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "seq_scan"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Sequential Scans"
+ },
+ {
+ "id": "unit",
+ "value": "short"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "table_size"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Table Size"
+ },
+ {
+ "id": "unit",
+ "value": "bytes"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "last_vacuum"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Last Vacuum"
+ },
+ {
+ "id": "unit",
+ "value": "s"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "last_analyze"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Last Analyze"
+ },
+ {
+ "id": "unit",
+ "value": "s"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-5": {
+ "kind": "Panel",
+ "spec": {
+ "id": 5,
+ "title": "Tables with Highest Growth",
+ "description": "Tables with the largest growth in total relation size during the selected time period. Assumes no statistics reset occurred.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "rawQuery": true,
+ "rawSql": "SELECT\n x.*,\n (data->>'seconds_since_last_vacuum')::int8 as last_vacuum,\n (data->>'seconds_since_last_analyze')::int8 as last_analyze\nFROM (\n SELECT\n tag_data->>'table_full_name' as table_full_name,\n max((data->>'total_relation_size_b')::int8) - min((data->>'total_relation_size_b')::int8) as growth,\n max((data->>'total_relation_size_b')::int8) as total_relation_size\n FROM\n table_stats\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n GROUP BY 1 \n ORDER BY growth DESC NULLS LAST\n LIMIT $top\n) x\njoin lateral (select data from table_stats where dbname = '$dbname' and tag_data->>'table_full_name' = x.table_full_name and $__timeFilter(time) order by time desc limit 1) y on true",
+ "resultFormat": "table"
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "decimals": 2,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "left",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "table_full_name"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Table Name"
+ },
+ {
+ "id": "custom.inspect",
+ "value": true
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": false,
+ "title": "View Table Details",
+ "url": "/d/table-details/table-details?orgId=1&var-dbname=${dbname}&var-table_full_name=${__data.fields.table_full_name}"
+ }
+ ]
+ },
+ {
+ "id": "custom.width",
+ "value": 403
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "growth"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Size Growth"
+ },
+ {
+ "id": "unit",
+ "value": "bytes"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "total_relation_size"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Current Total Size"
+ },
+ {
+ "id": "unit",
+ "value": "bytes"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "last_vacuum"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Last Vacuum"
+ },
+ {
+ "id": "unit",
+ "value": "s"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "last_analyze"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Last Analyze"
+ },
+ {
+ "id": "unit",
+ "value": "s"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-6": {
+ "kind": "Panel",
+ "spec": {
+ "id": 6,
+ "title": "Tables with Most INSERT Activity",
+ "description": "Tables with the most INSERT operations during the selected time period. Useful for identifying write-heavy tables.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "rawQuery": true,
+ "rawSql": "SELECT\n x.*,\n (data->>'total_relation_size_b')::int8 as total_relation_size,\n (data->>'seconds_since_last_vacuum')::int8 as last_vacuum,\n (data->>'seconds_since_last_analyze')::int8 as last_analyze\nFROM (\nSELECT\n tag_data->>'table_full_name' as table_full_name,\n max((data->>'n_tup_ins')::int8) - min((data->>'n_tup_ins')::int8) as ins\nFROM\n table_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY\n 1 \nHAVING\n max((data->>'n_tup_ins')::int8) > min((data->>'n_tup_ins')::int8)\nORDER BY\n 2 DESC NULLS LAST\nLIMIT\n $top\n) x\njoin lateral (select data from table_stats where dbname = '$dbname' and tag_data->>'table_full_name' = x.table_full_name and $__timeFilter(time) order by time desc limit 1) y on true",
+ "resultFormat": "table"
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "decimals": 2,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "left",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "table_full_name"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Table Name"
+ },
+ {
+ "id": "custom.inspect",
+ "value": true
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": false,
+ "title": "View Table Details",
+ "url": "/d/table-details/table-details?orgId=1&var-dbname=${dbname}&var-table_full_name=${__data.fields.table_full_name}"
+ }
+ ]
+ },
+ {
+ "id": "custom.width",
+ "value": 403
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "ins"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "INSERT Operations"
+ },
+ {
+ "id": "unit",
+ "value": "short"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "total_relation_size"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Total Size"
+ },
+ {
+ "id": "unit",
+ "value": "bytes"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "last_vacuum"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Last Vacuum"
+ },
+ {
+ "id": "unit",
+ "value": "s"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "last_analyze"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Last Analyze"
+ },
+ {
+ "id": "unit",
+ "value": "s"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-7": {
+ "kind": "Panel",
+ "spec": {
+ "id": 7,
+ "title": "Tables with Most UPDATE Activity",
+ "description": "Tables with the most UPDATE operations during the selected time period. High UPDATE activity may indicate need for more frequent VACUUM operations.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "rawQuery": true,
+ "rawSql": "SELECT\n x.*,\n (data->>'total_relation_size_b')::int8 as total_relation_size, \n (data->>'seconds_since_last_vacuum')::int8 as last_vacuum,\n (data->>'seconds_since_last_analyze')::int8 as last_analyze\nFROM (\nSELECT\n tag_data->>'table_full_name' as table_full_name,\n max((data->>'n_tup_upd')::int8) - min((data->>'n_tup_upd')::int8) as upd -- assumes no reset\nFROM\n table_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY\n 1 \nHAVING\n max((data->>'n_tup_upd')::int8) > min((data->>'n_tup_upd')::int8)\nORDER BY\n 2 DESC NULLS LAST\nLIMIT\n $top\n) x\njoin lateral (select data from table_stats where dbname = '$dbname' and tag_data->>'table_full_name' = x.table_full_name and $__timeFilter(time) order by time desc limit 1) y on true",
+ "resultFormat": "table"
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "decimals": 2,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "left",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "table_full_name"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Table Name"
+ },
+ {
+ "id": "custom.inspect",
+ "value": true
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": false,
+ "title": "View Table Details",
+ "url": "/d/table-details/table-details?orgId=1&var-dbname=${dbname}&var-table_full_name=${__data.fields.table_full_name}"
+ }
+ ]
+ },
+ {
+ "id": "custom.width",
+ "value": 403
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "upd"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "UPDATE Operations"
+ },
+ {
+ "id": "unit",
+ "value": "short"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "total_relation_size"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Total Size"
+ },
+ {
+ "id": "unit",
+ "value": "bytes"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "last_vacuum"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Last Vacuum"
+ },
+ {
+ "id": "unit",
+ "value": "s"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "last_analyze"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Last Analyze"
+ },
+ {
+ "id": "unit",
+ "value": "s"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-8": {
+ "kind": "Panel",
+ "spec": {
+ "id": 8,
+ "title": "Tables with Most DELETE Activity",
+ "description": "Tables with the most DELETE operations during the selected time period. High DELETE activity may indicate need for more frequent VACUUM operations.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "rawQuery": true,
+ "rawSql": "SELECT\n x.*,\n (data->>'total_relation_size_b')::int8 as total_relation_size, \n (data->>'seconds_since_last_vacuum')::int8 as last_vacuum,\n (data->>'seconds_since_last_analyze')::int8 as last_analyze\nFROM (\nSELECT\n tag_data->>'table_full_name' as table_full_name,\n max((data->>'n_tup_del')::int8) - min((data->>'n_tup_del')::int8) as del -- assumes no reset\nFROM\n table_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY\n 1 \nHAVING\n max((data->>'n_tup_del')::int8) > min((data->>'n_tup_del')::int8)\nORDER BY\n 2 DESC NULLS LAST\nLIMIT\n $top\n) x\njoin lateral (select data from table_stats where dbname = '$dbname' and tag_data->>'table_full_name' = x.table_full_name and $__timeFilter(time) order by time desc limit 1) y on true",
+ "resultFormat": "table"
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "decimals": 2,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "left",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "table_full_name"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Table Name"
+ },
+ {
+ "id": "custom.inspect",
+ "value": true
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": false,
+ "title": "View Table Details",
+ "url": "/d/table-details/table-details?orgId=1&var-dbname=${dbname}&var-table_full_name=${__data.fields.table_full_name}"
+ }
+ ]
+ },
+ {
+ "id": "custom.width",
+ "value": 403
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "del"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "DELETE Operations"
+ },
+ {
+ "id": "unit",
+ "value": "short"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "total_relation_size"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Total Size"
+ },
+ {
+ "id": "unit",
+ "value": "bytes"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "last_vacuum"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Last Vacuum"
+ },
+ {
+ "id": "unit",
+ "value": "s"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "last_analyze"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Last Analyze"
+ },
+ {
+ "id": "unit",
+ "value": "s"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ }
+ },
+ "layout": {
+ "kind": "RowsLayout",
+ "spec": {
+ "rows": [
+ {
+ "kind": "RowsLayoutRow",
+ "spec": {
+ "title": "Table Statistics",
+ "collapse": false,
+ "layout": {
+ "kind": "GridLayout",
+ "spec": {
+ "items": [
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 0,
+ "width": 24,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-12"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 7,
+ "width": 24,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-13"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 14,
+ "width": 24,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-5"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 21,
+ "width": 24,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-4"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 28,
+ "width": 24,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-6"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 35,
+ "width": 24,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-7"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 42,
+ "width": 24,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-8"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 49,
+ "width": 24,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-11"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 56,
+ "width": 24,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-202"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "kind": "RowsLayoutRow",
+ "spec": {
+ "title": "Visual Analysis",
+ "collapse": false,
+ "layout": {
+ "kind": "GridLayout",
+ "spec": {
+ "items": [
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 0,
+ "width": 24,
+ "height": 10,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-3"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 10,
+ "width": 24,
+ "height": 10,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-1"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 20,
+ "width": 24,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-2"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 27,
+ "width": 11,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-201"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ }
+ },
+ "links": [],
+ "liveNow": false,
+ "preload": false,
+ "tags": [
+ "pgwatch"
+ ],
+ "timeSettings": {
+ "from": "now-3h",
+ "to": "now",
+ "autoRefresh": "1m",
+ "autoRefreshIntervals": [
+ "5s",
+ "10s",
+ "30s",
+ "1m",
+ "5m",
+ "15m",
+ "30m",
+ "1h",
+ "2h",
+ "1d"
+ ],
+ "hideTimepicker": false,
+ "fiscalYearStartMonth": 0
+ },
+ "title": "4. Tables Overview",
+ "variables": [
+ {
+ "kind": "QueryVariable",
+ "spec": {
+ "name": "dbname",
+ "current": {
+ "text": "",
+ "value": ""
+ },
+ "label": "Source Name",
+ "hide": "dontHide",
+ "refresh": "onDashboardLoad",
+ "skipUrlSync": false,
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "__legacyStringValue": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'table_stats' ORDER BY 1;"
+ }
+ },
+ "regex": "",
+ "sort": "disabled",
+ "definition": "",
+ "options": [],
+ "multi": false,
+ "includeAll": false,
+ "allowCustomValue": true
+ }
+ },
+ {
+ "kind": "CustomVariable",
+ "spec": {
+ "name": "top",
+ "query": "1,3,5,10,20,50",
+ "current": {
+ "text": "5",
+ "value": "5"
+ },
+ "options": [
+ {
+ "selected": false,
+ "text": "1",
+ "value": "1"
+ },
+ {
+ "selected": false,
+ "text": "3",
+ "value": "3"
+ },
+ {
+ "selected": true,
+ "text": "5",
+ "value": "5"
+ },
+ {
+ "selected": false,
+ "text": "10",
+ "value": "10"
+ },
+ {
+ "selected": false,
+ "text": "20",
+ "value": "20"
+ },
+ {
+ "selected": false,
+ "text": "50",
+ "value": "50"
+ }
+ ],
+ "multi": false,
+ "includeAll": false,
+ "label": "Top N",
+ "hide": "dontHide",
+ "skipUrlSync": false,
+ "description": "Limit to top N entries",
+ "allowCustomValue": true
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/grafana/postgres/v13/5-table-details.json b/grafana/postgres/v13/5-table-details.json
new file mode 100644
index 0000000000..5d3fa5b058
--- /dev/null
+++ b/grafana/postgres/v13/5-table-details.json
@@ -0,0 +1,3485 @@
+{
+ "apiVersion": "dashboard.grafana.app/v2",
+ "kind": "Dashboard",
+ "metadata": {
+ "name": "table-details"
+ },
+ "spec": {
+ "annotations": [
+ {
+ "kind": "AnnotationQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "grafana"
+ },
+ "spec": {}
+ },
+ "enable": true,
+ "hide": true,
+ "iconColor": "rgba(0, 211, 255, 1)",
+ "name": "Annotations & Alerts",
+ "builtIn": true,
+ "legacyOptions": {
+ "type": "dashboard"
+ }
+ }
+ }
+ ],
+ "cursorSync": "Off",
+ "editable": true,
+ "elements": {
+ "panel-1": {
+ "kind": "Panel",
+ "spec": {
+ "id": 1,
+ "title": "Table Size",
+ "description": "Size of the table including all indexes and TOAST data",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "total_relation_size",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "table_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "SELECT mean(\"total_relation_size_b\") FROM \"table_stats\" WHERE \"dbname\" =~ /^$dbname$/ AND \"table_full_name\" =~ /^$table_full_name$/ AND $timeFilter GROUP BY time($interval) fill(none)",
+ "rawQuery": true,
+ "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg((data->>'table_size_b')::int8) as table_size,\n avg((data->>'total_relation_size_b')::int8) as total_relation_size,\n avg((data->>'toast_size_b')::int8) as toast_size\nFROM\n table_stats\nWHERE\n $__timeFilter(time) AND dbname = '$dbname'\n AND tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\nGROUP BY 1\nORDER BY 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "total_relation_size_b"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$dbname$/"
+ },
+ {
+ "condition": "AND",
+ "key": "table_full_name",
+ "operator": "=~",
+ "value": "/^$table_full_name$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "5m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "bytes",
+ "decimals": 1,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": true,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-101": {
+ "kind": "Panel",
+ "spec": {
+ "id": 101,
+ "title": "INSERT Operations",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n sum(ins-ins_lag) as \"INSERT\"\nfrom (\n select \n (data->>'n_tup_ins')::int8 as ins,\n lag((data->>'n_tup_ins')::int8) over w as ins_lag,\n time\n from\n table_stats\n where\n dbname = '$dbname'\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n and $__timeFilter(time)\n window w as (order by time)\n\n) x\nwhere ins >= ins_lag\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ },
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n sum(ins-ins_lag) as \"INSERT-$lag_interval\"\nfrom (\n select \n (data->>'n_tup_ins')::int8 as ins,\n lag((data->>'n_tup_ins')::int8) over w as ins_lag,\n time + '$lag_interval'::interval as time\n from\n table_stats\n where\n dbname = '$dbname'\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n window w as (order by time)\n\n) x\nwhere ins >= ins_lag\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "B",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-102": {
+ "kind": "Panel",
+ "spec": {
+ "id": 102,
+ "title": "UPDATE Operations",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n sum(upd-upd_lag) as \"UPDATE\"\nfrom (\n select \n (data->>'n_tup_upd')::int8 as upd,\n lag((data->>'n_tup_upd')::int8) over w as upd_lag,\n time\n from\n table_stats\n where\n dbname = '$dbname'\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n and $__timeFilter(time)\n window w as (order by time)\n\n) x\nwhere upd >= upd_lag\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ },
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n sum(upd-upd_lag) as \"UPDATE-$lag_interval\"\nfrom (\n select \n (data->>'n_tup_upd')::int8 as upd,\n lag((data->>'n_tup_upd')::int8) over w as upd_lag,\n time + '$lag_interval'::interval as time\n from\n table_stats\n where\n dbname = '$dbname'\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n window w as (order by time)\n\n) x\nwhere upd >= upd_lag\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "B",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-103": {
+ "kind": "Panel",
+ "spec": {
+ "id": 103,
+ "title": "DELETE Operations",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n sum(del-del_lag) as \"DELETE\"\nfrom (\n select \n (data->>'n_tup_del')::int8 as del,\n lag((data->>'n_tup_del')::int8) over w as del_lag,\n time\n from\n table_stats\n where\n dbname = '$dbname'\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n and $__timeFilter(time)\n window w as (order by time)\n\n) x\nwhere del >= del_lag\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ },
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n sum(del-del_lag) as \"DELETE-$lag_interval\"\nfrom (\n select \n (data->>'n_tup_del')::int8 as del,\n lag((data->>'n_tup_del')::int8) over w as del_lag,\n time + '$lag_interval'::interval as time\n from\n table_stats\n where\n dbname = '$dbname'\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n window w as (order by time)\n\n) x\nwhere del >= del_lag\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "B",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-104": {
+ "kind": "Panel",
+ "spec": {
+ "id": 104,
+ "title": "Sequential Scans",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n sum(seq_scan-seq_scan_lag) as seq_scan\nFROM ( \n SELECT\n (data->>'seq_scan')::int8 as seq_scan, lag((data->>'seq_scan')::int8) over w as seq_scan_lag,\n time\n FROM\n table_stats\n WHERE\n $__timeFilter(time) AND dbname = '$dbname'\n AND tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n WINDOW w as (order by time)\n) x\nWHERE seq_scan >= seq_scan_lag\nGROUP BY 1\nORDER BY 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ },
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n sum(seq_scan-seq_scan_lag) as \"seq_scan-$lag_interval\"\nFROM ( \n SELECT\n (data->>'seq_scan')::int8 as seq_scan, lag((data->>'seq_scan')::int8) over w as seq_scan_lag,\n time + '$lag_interval'::interval as time\n FROM\n table_stats\n WHERE\n time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n AND dbname = '$dbname'\n AND tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n WINDOW w as (order by time)\n) x\nWHERE seq_scan >= seq_scan_lag\nGROUP BY 1\nORDER BY 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "B",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-105": {
+ "kind": "Panel",
+ "spec": {
+ "id": 105,
+ "title": "Index Scans",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n sum(idx_scan-idx_scan_lag) as idx_scan\nFROM ( \n SELECT\n (data->>'idx_scan')::int8 as idx_scan, lag((data->>'idx_scan')::int8) over w as idx_scan_lag,\n time\n FROM\n table_stats\n WHERE\n $__timeFilter(time) AND dbname = '$dbname'\n AND tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n WINDOW w as (order by time)\n) x\nWHERE idx_scan >= idx_scan_lag\nGROUP BY 1\nORDER BY 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ },
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n sum(idx_scan-idx_scan_lag) as \"idx_scan-$lag_interval\"\nFROM ( \n SELECT\n (data->>'idx_scan')::int8 as idx_scan, lag((data->>'idx_scan')::int8) over w as idx_scan_lag,\n time + '$lag_interval'::interval as time\n FROM\n table_stats\n WHERE\n time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n AND dbname = '$dbname'\n AND tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n WINDOW w as (order by time)\n) x\nWHERE idx_scan >= idx_scan_lag\nGROUP BY 1\nORDER BY 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "B",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-106": {
+ "kind": "Panel",
+ "spec": {
+ "id": 106,
+ "title": "Shared Buffers Hit Rate - Heap",
+ "description": "Hit rate for the main table excluding indexes and TOAST",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg( case when hh = hh_lag and hr = hr_lag then null else (hh-hh_lag)::numeric * 100 / (hh-hh_lag+hr-hr_lag) end ) as \"Heap hit\"\nfrom (\n select \n (data->>'heap_blks_hit')::int8 as hh, lag((data->>'heap_blks_hit')::int8) over w as hh_lag,\n (data->>'heap_blks_read')::int8 as hr, lag((data->>'heap_blks_read')::int8) over w as hr_lag,\n time\n from table_io_stats\n where dbname = '$dbname' and $__timeFilter(time)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere hh >= hh_lag and hr >= hr_lag\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ },
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n avg( case when hh = hh_lag and hr = hr_lag then null else (hh-hh_lag)::numeric * 100 / (hh-hh_lag+hr-hr_lag) end ) as \"Heap hit-$lag_interval\"\nfrom (\n select \n (data->>'heap_blks_hit')::int8 as hh, lag((data->>'heap_blks_hit')::int8) over w as hh_lag,\n (data->>'heap_blks_read')::int8 as hr, lag((data->>'heap_blks_read')::int8) over w as hr_lag,\n time +'$lag_interval'::interval as time\n from table_io_stats\n where dbname = '$dbname'\n and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere hh >= hh_lag and hr >= hr_lag\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "B",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "percent",
+ "decimals": 2,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-107": {
+ "kind": "Panel",
+ "spec": {
+ "id": 107,
+ "title": "Shared Buffers Hit Rate - Toast",
+ "description": "Hit rate for the main table excluding indexes and TOAST",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n 100 * avg( case when tr = tr_lag and th = th_lag and tir = tir_lag and tih = tir_lag then null else (coalesce(th,0)-coalesce(th_lag,0) + coalesce(tih,0)-coalesce(tih_lag,0))::numeric / (coalesce(th,0)-coalesce(th_lag,0) + coalesce(tr,0)-coalesce(tr_lag,0) + coalesce(tir,0)-coalesce(tir_lag,0) + coalesce(tih,0)-coalesce(tih_lag,0)) end ) as \"Toast hit\"\nfrom (\n select \n (data->>'toast_blks_read')::int8 as tr, lag((data->>'toast_blks_read')::int8) over w as tr_lag,\n (data->>'toast_blks_hit')::int8 as th, lag((data->>'toast_blks_hit')::int8) over w as th_lag,\n (data->>'tidx_blks_read')::int8 as tir, lag((data->>'tidx_blks_read')::int8) over w as tir_lag,\n (data->>'tidx_blks_hit')::int8 as tih, lag((data->>'tidx_blks_hit')::int8) over w as tih_lag,\n time\n from table_io_stats\n where dbname = '$dbname' and $__timeFilter(time)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere th > th_lag or tih > tih_lag or tr > tr_lag or tir > tir_lag\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ },
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n 100 * avg( case when tr = tr_lag and th = th_lag and tir = tir_lag and tih = tir_lag then null else (coalesce(th,0)-coalesce(th_lag,0) + coalesce(tih,0)-coalesce(tih_lag,0))::numeric / (coalesce(th,0)-coalesce(th_lag,0) + coalesce(tr,0)-coalesce(tr_lag,0) + coalesce(tir,0)-coalesce(tir_lag,0) + coalesce(tih,0)-coalesce(tih_lag,0)) end ) as \"Toast hit-$lag_interval\"\nfrom (\n select \n (data->>'toast_blks_read')::int8 as tr, lag((data->>'toast_blks_read')::int8) over w as tr_lag,\n (data->>'toast_blks_hit')::int8 as th, lag((data->>'toast_blks_hit')::int8) over w as th_lag,\n (data->>'tidx_blks_read')::int8 as tir, lag((data->>'tidx_blks_read')::int8) over w as tir_lag,\n (data->>'tidx_blks_hit')::int8 as tih, lag((data->>'tidx_blks_hit')::int8) over w as tih_lag,\n time + '$lag_interval'::interval as time\n from table_io_stats\n where dbname = '$dbname'\n and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere th > th_lag or tih > tih_lag or tr > tr_lag or tir > tir_lag\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "B",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "percent",
+ "decimals": 2,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-108": {
+ "kind": "Panel",
+ "spec": {
+ "id": 108,
+ "title": "Block Bandwidth - Heap",
+ "description": "Block bandwidth for heap data (assuming 8k blocks)",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n 8192 * sum(hh-hh_lag+hr-hr_lag) as \"Heap read\"\nfrom (\n select \n (data->>'heap_blks_hit')::int8 as hh, lag((data->>'heap_blks_hit')::int8) over w as hh_lag,\n (data->>'heap_blks_read')::int8 as hr, lag((data->>'heap_blks_read')::int8) over w as hr_lag,\n time\n from table_io_stats\n where dbname = '$dbname' and $__timeFilter(time)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere hr >= hr_lag and hh >= hh_lag\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ },
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n 8192 * sum(hh-hh_lag+hr-hr_lag) as \"Heap read-$lag_interval\"\nfrom (\n select \n (data->>'heap_blks_hit')::int8 as hh, lag((data->>'heap_blks_hit')::int8) over w as hh_lag,\n (data->>'heap_blks_read')::int8 as hr, lag((data->>'heap_blks_read')::int8) over w as hr_lag,\n time + '$lag_interval'::interval as time\n from table_io_stats\n where dbname = '$dbname'\n and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere hr >= hr_lag and hh >= hh_lag\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "B",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "bytes",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-109": {
+ "kind": "Panel",
+ "spec": {
+ "id": 109,
+ "title": "Block Bandwidth - Indexes",
+ "description": "Block bandwidth for index data (assuming 8k blocks)",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n 8192 * sum(ih-ih_lag+ir-ir_lag) as \"Idx read\"\nfrom (\n select \n (data->>'idx_blks_hit')::int8 as ih, lag((data->>'idx_blks_hit')::int8) over w as ih_lag,\n (data->>'idx_blks_read')::int8 as ir, lag((data->>'idx_blks_read')::int8) over w as ir_lag,\n time\n from table_io_stats\n where dbname = '$dbname' and $__timeFilter(time)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere ir >= ir_lag and ih >= ih_lag\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ },
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n 8192 * sum(ih-ih_lag+ir-ir_lag) as \"Idx read-$lag_interval\"\nfrom (\n select \n (data->>'idx_blks_hit')::int8 as ih, lag((data->>'idx_blks_hit')::int8) over w as ih_lag,\n (data->>'idx_blks_read')::int8 as ir, lag((data->>'idx_blks_read')::int8) over w as ir_lag,\n time + '$lag_interval'::interval as time\n from table_io_stats\n where dbname = '$dbname'\n and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere ir >= ir_lag and ih >= ih_lag\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "B",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "bytes",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-110": {
+ "kind": "Panel",
+ "spec": {
+ "id": 110,
+ "title": "Block Bandwidth - Toast",
+ "description": "Block bandwidth for TOAST data (assuming 8k blocks)",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n 8192 * sum(coalesce(th,0)-coalesce(th_lag,0) + coalesce(tr,0)-coalesce(tr_lag,0) + coalesce(tir,0)-coalesce(tir_lag,0) + coalesce(tih,0)-coalesce(tih_lag,0)) as \"Toast read\"\nfrom (\n select \n (data->>'toast_blks_read')::int8 as tr, lag((data->>'toast_blks_read')::int8) over w as tr_lag,\n (data->>'toast_blks_hit')::int8 as th, lag((data->>'toast_blks_hit')::int8) over w as th_lag,\n (data->>'tidx_blks_read')::int8 as tir, lag((data->>'tidx_blks_read')::int8) over w as tir_lag,\n (data->>'tidx_blks_hit')::int8 as tih, lag((data->>'tidx_blks_hit')::int8) over w as tih_lag,\n time\n from table_io_stats\n where dbname = '$dbname' and $__timeFilter(time)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere th > th_lag or tih > tih_lag or tr > tr_lag or tir > tir_lag\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ },
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n 8192 * sum(coalesce(th,0)-coalesce(th_lag,0) + coalesce(tr,0)-coalesce(tr_lag,0) + coalesce(tir,0)-coalesce(tir_lag,0) + coalesce(tih,0)-coalesce(tih_lag,0)) as \"Toast read-$lag_interval\"\nfrom (\n select \n (data->>'toast_blks_read')::int8 as tr, lag((data->>'toast_blks_read')::int8) over w as tr_lag,\n (data->>'toast_blks_hit')::int8 as th, lag((data->>'toast_blks_hit')::int8) over w as th_lag,\n (data->>'tidx_blks_read')::int8 as tir, lag((data->>'tidx_blks_read')::int8) over w as tir_lag,\n (data->>'tidx_blks_hit')::int8 as tih, lag((data->>'tidx_blks_hit')::int8) over w as tih_lag,\n time + '$lag_interval'::interval as time\n from table_io_stats\n where dbname = '$dbname'\n and time between ($__timeFrom()::timestamptz - '$lag_interval'::interval) and ($__timeTo()::timestamptz - '$lag_interval'::interval)\n and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere th > th_lag or tih > tih_lag or tr > tr_lag or tir > tir_lag\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "B",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "bytes",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-2": {
+ "kind": "Panel",
+ "spec": {
+ "id": 2,
+ "title": "Table Scans",
+ "description": "Sequential and index scans performed on the table (1h rate, aggregated by interval)",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "seq_scans",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "table_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "WITH last_out_of_range_row_time(time) AS (\n SELECT time \n FROM table_stats\n WHERE dbname = '$dbname' AND time < $__timeFrom()::timestamptz\n ORDER BY time DESC\n LIMIT 1\n)\n\nSELECT\n $__timeGroup(time, $agg_interval),\n avg( ((seq_scan-seq_scan_lag)::numeric*3600) / extract(epoch from time - time_lag) ) as seq_scan,\n avg( ((idx_scan-idx_scan_lag)::numeric*3600) / extract(epoch from time - time_lag) ) as idx_scan\nFROM ( \n SELECT\n (data->>'seq_scan')::int8 as seq_scan, lag((data->>'seq_scan')::int8) over w as seq_scan_lag,\n (data->>'idx_scan')::int8 as idx_scan, lag((data->>'idx_scan')::int8) over w as idx_scan_lag,\n time, lag(time) over w as time_lag \n FROM\n table_stats\n WHERE \n time <= $__timeTo()::timestamptz AND time >= (SELECT time FROM last_out_of_range_row_time)\n AND dbname = '$dbname' AND tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n WINDOW w as (order by time)\n) x\nWHERE seq_scan >= seq_scan_lag and time > time_lag\nGROUP BY 1\nORDER BY 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "seq_scan"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "1m"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$dbname$/"
+ },
+ {
+ "condition": "AND",
+ "key": "table_full_name",
+ "operator": "=~",
+ "value": "/^$table_full_name$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "5m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "decimals": 1,
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": true,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "idx_scans"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "#629E51",
+ "mode": "fixed"
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "seq_scans"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "#BF1B00",
+ "mode": "fixed"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-3": {
+ "kind": "Panel",
+ "spec": {
+ "id": 3,
+ "title": "Data Modifications",
+ "description": "Insert, Update, and Delete operations on the table (1h rate, aggregated by interval)",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "INS",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "table_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "WITH last_out_of_range_row_time(time) AS (\n SELECT time \n FROM table_stats\n WHERE dbname = '$dbname' AND time < $__timeFrom()::timestamptz\n ORDER BY time DESC\n LIMIT 1\n)\n\nselect\n $__timeGroup(time, $agg_interval),\n avg((ins-ins_lag) * 3600 / extract(epoch from time - time_lag)) as \"INSERT\",\n avg((upd-upd_lag) * 3600 / extract(epoch from time - time_lag)) as \"UPDATE\",\n avg((del-del_lag) * 3600 / extract(epoch from time - time_lag)) as \"DELETE\"\nfrom (\n select \n (data->>'n_tup_ins')::int8 as ins, lag((data->>'n_tup_ins')::int8) over w as ins_lag,\n (data->>'n_tup_upd')::int8 as upd, lag((data->>'n_tup_upd')::int8) over w as upd_lag,\n (data->>'n_tup_del')::int8 as del, lag((data->>'n_tup_del')::int8) over w as del_lag,\n time, lag(time) over w as time_lag\n from table_stats\n where \n time <= $__timeTo()::timestamptz AND time >= (SELECT time FROM last_out_of_range_row_time)\n AND dbname = '$dbname' and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere ins >= ins_lag and time > time_lag\ngroup by 1\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "n_tup_ins"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "1m"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$dbname$/"
+ },
+ {
+ "condition": "AND",
+ "key": "table_full_name",
+ "operator": "=~",
+ "value": "/^$table_full_name$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "5m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "decimals": 1,
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": true,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-4": {
+ "kind": "Panel",
+ "spec": {
+ "id": 4,
+ "title": "Shared Buffer Hit Rates",
+ "description": "Cache hit rates for heap, index, and TOAST data (aggregated by interval)",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "Heap",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "table_io_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "SELECT non_negative_derivative(mean(\"heap_blks_hit\"), 10s) / (non_negative_derivative(mean(\"heap_blks_hit\"), 10s) + non_negative_derivative(mean(\"heap_blks_read\"), 10s)) * 100 FROM \"table_io_stats\" WHERE \"dbname\" =~ /^$dbname$/ AND \"table_full_name\" =~ /^$table_full_name$/ AND $timeFilter GROUP BY time($__interval) fill(none)",
+ "rawQuery": true,
+ "rawSql": "WITH last_out_of_range_row_time(time) AS (\n SELECT time \n FROM table_io_stats\n WHERE dbname = '$dbname' AND time < $__timeFrom()::timestamptz\n ORDER BY time DESC\n LIMIT 1\n)\n\nselect\n $__timeGroup(time, $agg_interval),\n avg( case when hh = hh_lag and hr = hr_lag then null else (hh-hh_lag)::numeric * 100 / (hh-hh_lag+hr-hr_lag) end ) as \"Heap\",\n avg( case when ih = ih_lag and ir = ir_lag then null else (ih-ih_lag)::numeric * 100 / (ih-ih_lag+ir-ir_lag) end ) as \"Indexes\" \nfrom (\n select \n (data->>'heap_blks_hit')::int8 as hh, lag((data->>'heap_blks_hit')::int8) over w as hh_lag,\n (data->>'heap_blks_read')::int8 as hr, lag((data->>'heap_blks_read')::int8) over w as hr_lag,\n (data->>'idx_blks_hit')::int8 as ih, lag((data->>'idx_blks_hit')::int8) over w as ih_lag,\n (data->>'idx_blks_read')::int8 as ir, lag((data->>'idx_blks_read')::int8) over w as ir_lag,\n time\n from table_io_stats\n where\n time <= $__timeTo()::timestamptz AND time >= (SELECT time FROM last_out_of_range_row_time)\n AND dbname = '$dbname' and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere hh >= hh_lag\ngroup by 1\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "heap_blks_hit"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "10s"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$dbname$/"
+ },
+ {
+ "condition": "AND",
+ "key": "table_full_name",
+ "operator": "=~",
+ "value": "/^$table_full_name$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "5m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "percent",
+ "decimals": 1,
+ "max": 100,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-5": {
+ "kind": "Panel",
+ "spec": {
+ "id": 5,
+ "title": "Index Scan Activity",
+ "description": "Index scans per individual index (1h rate, aggregated by interval)",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "$tag_index_name",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "index_name"
+ ],
+ "type": "tag"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "index_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "WITH last_out_of_range_row_time(time) AS (\n SELECT time \n FROM index_stats\n WHERE dbname = '$dbname' AND time < $__timeFrom()::timestamptz\n ORDER BY time DESC\n LIMIT 1\n)\n\nselect\n $__timeGroup(time, $agg_interval),\n index_name,\n avg( ((idx_scan - idx_scan_lag)::numeric * 3600) / extract(epoch from time - time_lag) )\nfrom (\n select \n (data->>'idx_scan')::int8 as idx_scan, lag((data->>'idx_scan')::int8) over w as idx_scan_lag,\n tag_data->>'index_name' as index_name,\n time, lag(time) over w as time_lag\n from index_stats\n where\n time <= $__timeTo()::timestamptz AND time >= (SELECT time FROM last_out_of_range_row_time)\n AND dbname = '$dbname' and tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\n window w as (order by time)\n) x\nwhere idx_scan >= idx_scan_lag and time > time_lag\ngroup by 1, 2\norder by 1, 2",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "idx_scan"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "1m"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "table_full_name",
+ "operator": "=~",
+ "value": "/^$table_full_name$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "5m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-6": {
+ "kind": "Panel",
+ "spec": {
+ "id": 6,
+ "title": "",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "text",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "code": {
+ "language": "plaintext",
+ "showLineNumbers": false,
+ "showMiniMap": false
+ },
+ "content": "### Brought to you by\n\n[](https://www.cybertec-postgresql.com/en/)\n",
+ "mode": "markdown"
+ },
+ "fieldConfig": {
+ "defaults": {},
+ "overrides": []
+ }
+ }
+ },
+ "transparent": true
+ }
+ },
+ "panel-8": {
+ "kind": "Panel",
+ "spec": {
+ "id": 8,
+ "title": "Last VACUUM",
+ "description": "Time since last VACUUM including manual and AUTOVACUUM (1 month warning, 2 month error threshold)",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT\n time,\n (data->>'seconds_since_last_vacuum')::int8\nFROM\n table_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n AND tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\nORDER BY time DESC\nLIMIT 1\n",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "maxDataPoints": 100
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "stat",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "colorMode": "none",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "percentChangeColorMode": "standard",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "dtdurations",
+ "mappings": [
+ {
+ "type": "special",
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ }
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "#299c46"
+ },
+ {
+ "value": 2592000,
+ "color": "rgba(237, 129, 40, 0.89)"
+ },
+ {
+ "value": 5184000,
+ "color": "#d44a3a"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-9": {
+ "kind": "Panel",
+ "spec": {
+ "id": 9,
+ "title": "Last ANALYZE",
+ "description": "Time since last ANALYZE including manual and auto-ANALYZE (1 month warning, 2 month error threshold)",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT\n time,\n (data->>'seconds_since_last_analyze')::int8\nFROM\n table_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n AND tag_data @> jsonb_build_object('table_full_name', '$table_full_name')\nORDER BY time DESC\nLIMIT 1\n",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "maxDataPoints": 100
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "stat",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "colorMode": "none",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "percentChangeColorMode": "standard",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "dtdurations",
+ "mappings": [
+ {
+ "type": "special",
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ }
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "#299c46"
+ },
+ {
+ "value": 2592000,
+ "color": "rgba(237, 129, 40, 0.89)"
+ },
+ {
+ "value": 5184000,
+ "color": "#d44a3a"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ }
+ },
+ "layout": {
+ "kind": "RowsLayout",
+ "spec": {
+ "rows": [
+ {
+ "kind": "RowsLayoutRow",
+ "spec": {
+ "title": "Table Details",
+ "collapse": false,
+ "layout": {
+ "kind": "GridLayout",
+ "spec": {
+ "items": [
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 0,
+ "width": 24,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-1"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 5,
+ "width": 24,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-2"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 10,
+ "width": 24,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-3"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 15,
+ "width": 24,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-4"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 20,
+ "width": 24,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-5"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 25,
+ "width": 12,
+ "height": 3,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-8"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 12,
+ "y": 25,
+ "width": 12,
+ "height": 3,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-9"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "kind": "RowsLayoutRow",
+ "spec": {
+ "title": "Time Lag Comparison",
+ "collapse": true,
+ "layout": {
+ "kind": "GridLayout",
+ "spec": {
+ "items": [
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 280,
+ "width": 24,
+ "height": 9,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-101"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 289,
+ "width": 24,
+ "height": 9,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-102"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 298,
+ "width": 24,
+ "height": 9,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-103"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 307,
+ "width": 24,
+ "height": 9,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-104"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 316,
+ "width": 24,
+ "height": 9,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-105"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 325,
+ "width": 24,
+ "height": 9,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-106"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 334,
+ "width": 24,
+ "height": 9,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-107"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 343,
+ "width": 24,
+ "height": 9,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-108"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 352,
+ "width": 24,
+ "height": 9,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-109"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 361,
+ "width": 24,
+ "height": 9,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-110"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 0,
+ "width": 12,
+ "height": 6,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-6"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ }
+ },
+ "links": [],
+ "liveNow": false,
+ "preload": false,
+ "tags": [
+ "pgwatch"
+ ],
+ "timeSettings": {
+ "timezone": "browser",
+ "from": "now-3h",
+ "to": "now",
+ "autoRefresh": "",
+ "autoRefreshIntervals": [
+ "5s",
+ "10s",
+ "30s",
+ "1m",
+ "5m",
+ "15m",
+ "30m",
+ "1h",
+ "2h",
+ "1d"
+ ],
+ "hideTimepicker": false,
+ "fiscalYearStartMonth": 0
+ },
+ "title": "5. Table Details",
+ "variables": [
+ {
+ "kind": "QueryVariable",
+ "spec": {
+ "name": "dbname",
+ "current": {
+ "text": "",
+ "value": ""
+ },
+ "label": "Monitored Source",
+ "hide": "dontHide",
+ "refresh": "onDashboardLoad",
+ "skipUrlSync": false,
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "__legacyStringValue": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'table_stats' ORDER BY 1;"
+ }
+ },
+ "regex": "",
+ "sort": "alphabeticalAsc",
+ "definition": "",
+ "options": [],
+ "multi": false,
+ "includeAll": false,
+ "allowCustomValue": true
+ }
+ },
+ {
+ "kind": "QueryVariable",
+ "spec": {
+ "name": "table_full_name",
+ "current": {
+ "text": "",
+ "value": ""
+ },
+ "label": "Table Full Name",
+ "hide": "dontHide",
+ "refresh": "onDashboardLoad",
+ "skipUrlSync": false,
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "__legacyStringValue": "SELECT DISTINCT tag_data->>'table_full_name' FROM table_stats WHERE time > current_date-3 AND dbname = '$dbname' ORDER BY 1"
+ }
+ },
+ "regex": "",
+ "sort": "alphabeticalAsc",
+ "definition": "",
+ "options": [],
+ "multi": false,
+ "includeAll": false,
+ "allowCustomValue": true
+ }
+ },
+ {
+ "kind": "IntervalVariable",
+ "spec": {
+ "name": "agg_interval",
+ "query": "1m,5m,10m,15m,30m,1h,6h,12h,1d",
+ "current": {
+ "text": "10m",
+ "value": "10m"
+ },
+ "options": [
+ {
+ "selected": false,
+ "text": "1m",
+ "value": "1m"
+ },
+ {
+ "selected": false,
+ "text": "5m",
+ "value": "5m"
+ },
+ {
+ "selected": true,
+ "text": "10m",
+ "value": "10m"
+ },
+ {
+ "selected": false,
+ "text": "15m",
+ "value": "15m"
+ },
+ {
+ "selected": false,
+ "text": "30m",
+ "value": "30m"
+ },
+ {
+ "selected": false,
+ "text": "1h",
+ "value": "1h"
+ },
+ {
+ "selected": false,
+ "text": "6h",
+ "value": "6h"
+ },
+ {
+ "selected": false,
+ "text": "12h",
+ "value": "12h"
+ },
+ {
+ "selected": false,
+ "text": "1d",
+ "value": "1d"
+ }
+ ],
+ "auto": false,
+ "auto_min": "10s",
+ "auto_count": 30,
+ "refresh": "onTimeRangeChanged",
+ "label": "Aggregation Interval",
+ "hide": "dontHide",
+ "skipUrlSync": false
+ }
+ },
+ {
+ "kind": "IntervalVariable",
+ "spec": {
+ "name": "lag_interval",
+ "query": "1h,6h,12h,1d,7d,14d,30d",
+ "current": {
+ "text": "1d",
+ "value": "1d"
+ },
+ "options": [
+ {
+ "selected": false,
+ "text": "1h",
+ "value": "1h"
+ },
+ {
+ "selected": false,
+ "text": "6h",
+ "value": "6h"
+ },
+ {
+ "selected": false,
+ "text": "12h",
+ "value": "12h"
+ },
+ {
+ "selected": true,
+ "text": "1d",
+ "value": "1d"
+ },
+ {
+ "selected": false,
+ "text": "7d",
+ "value": "7d"
+ },
+ {
+ "selected": false,
+ "text": "14d",
+ "value": "14d"
+ },
+ {
+ "selected": false,
+ "text": "30d",
+ "value": "30d"
+ }
+ ],
+ "auto": false,
+ "auto_min": "10s",
+ "auto_count": 30,
+ "refresh": "onTimeRangeChanged",
+ "label": "Lag Interval",
+ "hide": "dontHide",
+ "skipUrlSync": false
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/grafana/postgres/v13/change-events.json b/grafana/postgres/v13/change-events.json
new file mode 100644
index 0000000000..7809a82804
--- /dev/null
+++ b/grafana/postgres/v13/change-events.json
@@ -0,0 +1,1576 @@
+{
+ "apiVersion": "dashboard.grafana.app/v2",
+ "kind": "Dashboard",
+ "metadata": {
+ "name": "change-events"
+ },
+ "spec": {
+ "annotations": [
+ {
+ "kind": "AnnotationQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "grafana"
+ },
+ "spec": {}
+ },
+ "enable": true,
+ "hide": true,
+ "iconColor": "rgba(0, 211, 255, 1)",
+ "name": "Annotations & Alerts",
+ "builtIn": true,
+ "legacyOptions": {
+ "type": "dashboard"
+ }
+ }
+ },
+ {
+ "kind": "AnnotationQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {}
+ },
+ "enable": true,
+ "hide": false,
+ "iconColor": "rgba(255, 96, 96, 1)",
+ "name": "changes summary",
+ "legacyOptions": {
+ "limit": 100,
+ "query": "select details from object_changes where $timeFilter AND dbname = '$dbname'",
+ "rawQuery": "SELECT\n time,\n data->>'details' as text\nFROM\n object_changes\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n",
+ "showIn": 0,
+ "type": "alert"
+ }
+ }
+ }
+ ],
+ "cursorSync": "Off",
+ "description": "use change_events metric for capturing table/index/sproc/postgresql.conf changes",
+ "editable": true,
+ "elements": {
+ "panel-1": {
+ "kind": "Panel",
+ "spec": {
+ "id": 1,
+ "title": "DDL / config change events",
+ "description": "If there are no vertical red stripes then no changes were detected for that time period",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "CPU load",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "cpu_load",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "",
+ "rawQuery": true,
+ "rawSql": "SELECT\n $__timeGroup(time, $__interval),\n avg((data->>'load_5min')::float8) as \"load_5min\"\nFROM\n cpu_load\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 1\nORDER BY 1",
+ "resultFormat": "time_series",
+ "select": [
+ []
+ ],
+ "table": "cpu_load",
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$dbname$/"
+ }
+ ],
+ "timeColumn": "\"time\"",
+ "timeColumnType": "timestamptz",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ },
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "Rollback ratio",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "auto"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "db_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $__interval),\n avg( case when (xc = xc_lag and xr = xr_lag) then null else ( ((xr - xr_lag)::numeric*100) / ((xc - xc_lag) + (xr - xr_lag)) ) end ) as \"Rollback ratio\"\nfrom (\n select\n (data->>'xact_rollback')::float8 as xr, lag((data->>'xact_rollback')::float8) over w as xr_lag,\n (data->>'xact_commit')::float8 as xc, lag((data->>'xact_rollback')::float8) over w as xc_lag,\n time\n from db_stats\n where dbname = '$dbname'\n and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere xc >= xc_lag\ngroup by 1\norder by 1\n\n\n\n\n\n",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "load_5min"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$dbname$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "B",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "5m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "decimals": 1,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Rollback ratio"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "#BF1B00",
+ "mode": "fixed"
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "rollback ratio"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "percent"
+ },
+ {
+ "id": "min",
+ "value": 0
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Rollback ratio"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "percent"
+ },
+ {
+ "id": "min",
+ "value": 0
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-2": {
+ "kind": "Panel",
+ "spec": {
+ "id": 2,
+ "title": "Table changes",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "1s"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "object_changes",
+ "metricColumn": "none",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "SELECT\n (date_trunc('minute', time))::time as time,\n data->>'event' as event,\n tag_data->>'table' as table\nFROM\n table_changes\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nORDER BY\n time",
+ "resultFormat": "table",
+ "select": [
+ [
+ {
+ "params": [
+ "details"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "footer": {
+ "countRows": false,
+ "fields": "",
+ "reducer": [
+ "sum"
+ ],
+ "show": false
+ },
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "decimals": 2,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Time"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "time: YYYY-MM-DD HH:mm:ss"
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-3": {
+ "kind": "Panel",
+ "spec": {
+ "id": 3,
+ "title": "Index changes",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "1s"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "object_changes",
+ "metricColumn": "none",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "SELECT\n (date_trunc('minute', time))::time as time,\n data->>'event' as event,\n tag_data->>'index' as index,\n data->>'table' as table\nFROM\n index_changes\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nORDER BY\n time",
+ "resultFormat": "table",
+ "select": [
+ [
+ {
+ "params": [
+ "details"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "footer": {
+ "countRows": false,
+ "fields": "",
+ "reducer": [
+ "sum"
+ ],
+ "show": false
+ },
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "decimals": 2,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Time"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "time: YYYY-MM-DD HH:mm:ss"
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-4": {
+ "kind": "Panel",
+ "spec": {
+ "id": 4,
+ "title": "Sproc changes",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "metricColumn": "none",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "SELECT\n time::time,\n data->>'event' as event,\n tag_data->>'sproc' as sproc\nFROM\n sproc_changes\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nORDER BY\n time",
+ "resultFormat": "table",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "footer": {
+ "countRows": false,
+ "fields": "",
+ "reducer": [
+ "sum"
+ ],
+ "show": false
+ },
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "decimals": 2,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Time"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "time: YYYY-MM-DD HH:mm:ss"
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-5": {
+ "kind": "Panel",
+ "spec": {
+ "id": 5,
+ "title": "Config changes",
+ "description": "postgresql.conf settings changes",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "metricColumn": "none",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "SELECT\n time::time,\n tag_data->>'setting' as event,\n data->>'value' as value\nFROM\n configuration_changes\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nORDER BY\n time",
+ "resultFormat": "table",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "footer": {
+ "countRows": false,
+ "fields": "",
+ "reducer": [
+ "sum"
+ ],
+ "show": false
+ },
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "decimals": 2,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Time"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "time: YYYY-MM-DD HH:mm:ss"
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-7": {
+ "kind": "Panel",
+ "spec": {
+ "id": 7,
+ "title": "Settings",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n (select time from settings where $__timeFilter(time) order by time desc limit 1) as \"Time\",\n key,\n value::text as value\nfrom (\n select * from jsonb_each((select data from settings where $__timeFilter(time) order by time desc limit 1))\n) x;",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "footer": {
+ "countRows": false,
+ "fields": "",
+ "reducer": [
+ "sum"
+ ],
+ "show": false
+ },
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "displayName": "",
+ "unit": "short",
+ "decimals": 2,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Time"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Time"
+ },
+ {
+ "id": "unit",
+ "value": "time: YYYY-MM-DD HH:mm:ss"
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-8": {
+ "kind": "Panel",
+ "spec": {
+ "id": 8,
+ "title": "Login and superuser role changes",
+ "description": "Instance level",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "metricColumn": "none",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "SELECT\n (date_trunc('minute', time))::time as time,\n tag_data->>'role' as role,\n data->>'event' as event, \n data->>'privilege_type' as privilege_type\nFROM\n privilege_changes\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n AND (data->>'privilege_type' = 'LOGIN'\n OR data->>'privilege_type' = 'SUPERUSER') \nORDER BY\n time, tag_data->>'role', data->>'privilege_type'",
+ "resultFormat": "table",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "footer": {
+ "countRows": false,
+ "fields": "",
+ "reducer": [
+ "sum"
+ ],
+ "show": false
+ },
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "decimals": 2,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Time"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "time: YYYY-MM-DD HH:mm:ss"
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-9": {
+ "kind": "Panel",
+ "spec": {
+ "id": 9,
+ "title": "Privilege changes",
+ "description": "Per database",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "metricColumn": "none",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "SELECT\n (date_trunc('minute', time))::time as time,\n tag_data->>'role' as role,\n data->>'event' as event, \n data->>'privilege_type' as privilege_type,\n tag_data->>'object' as object\nFROM\n privilege_changes\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n AND data->>'privilege_type' != 'LOGIN'\n AND data->>'privilege_type' != 'SUPERUSER'\nORDER BY\n time, tag_data->>'role', data->>'privilege_type', data->>'object'",
+ "resultFormat": "table",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "footer": {
+ "countRows": false,
+ "fields": "",
+ "reducer": [
+ "sum"
+ ],
+ "show": false
+ },
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "decimals": 2,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Time"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "time: YYYY-MM-DD HH:mm:ss"
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ }
+ },
+ "layout": {
+ "kind": "GridLayout",
+ "spec": {
+ "items": [
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 0,
+ "width": 24,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-1"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 7,
+ "width": 12,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-2"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 12,
+ "y": 7,
+ "width": 12,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-3"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 12,
+ "width": 12,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-4"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 12,
+ "y": 12,
+ "width": 12,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-5"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 17,
+ "width": 12,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-8"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 12,
+ "y": 17,
+ "width": 12,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-9"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 22,
+ "width": 24,
+ "height": 8,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-7"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "links": [],
+ "liveNow": false,
+ "preload": false,
+ "tags": [
+ "pgwatch"
+ ],
+ "timeSettings": {
+ "timezone": "browser",
+ "from": "now-12h",
+ "to": "now",
+ "autoRefresh": "",
+ "autoRefreshIntervals": [
+ "5s",
+ "10s",
+ "30s",
+ "1m",
+ "5m",
+ "15m",
+ "30m",
+ "1h",
+ "2h",
+ "1d"
+ ],
+ "hideTimepicker": false,
+ "fiscalYearStartMonth": 0
+ },
+ "title": "Change events",
+ "variables": [
+ {
+ "kind": "QueryVariable",
+ "spec": {
+ "name": "dbname",
+ "current": {
+ "text": "",
+ "value": ""
+ },
+ "hide": "dontHide",
+ "refresh": "onDashboardLoad",
+ "skipUrlSync": false,
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "__legacyStringValue": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics ORDER BY 1;"
+ }
+ },
+ "regex": "",
+ "sort": "disabled",
+ "definition": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics ORDER BY 1;",
+ "options": [],
+ "multi": false,
+ "includeAll": false,
+ "allowCustomValue": true
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/grafana/postgres/v13/checkpointer-bgwriter-stats.json b/grafana/postgres/v13/checkpointer-bgwriter-stats.json
new file mode 100644
index 0000000000..ad85a264dd
--- /dev/null
+++ b/grafana/postgres/v13/checkpointer-bgwriter-stats.json
@@ -0,0 +1,1186 @@
+{
+ "apiVersion": "dashboard.grafana.app/v2",
+ "kind": "Dashboard",
+ "metadata": {
+ "name": "checkpointer-bgwriter-stats"
+ },
+ "spec": {
+ "annotations": [
+ {
+ "kind": "AnnotationQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "grafana"
+ },
+ "spec": {}
+ },
+ "enable": true,
+ "hide": true,
+ "iconColor": "rgba(0, 211, 255, 1)",
+ "name": "Annotations & Alerts",
+ "builtIn": true,
+ "legacyOptions": {
+ "type": "dashboard"
+ }
+ }
+ }
+ ],
+ "cursorSync": "Off",
+ "editable": true,
+ "elements": {
+ "panel-2": {
+ "kind": "Panel",
+ "spec": {
+ "id": 2,
+ "title": "Checkpoints",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "checkpoints_timed",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "1h"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "bgwriter",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "SELECT\n $__timeGroup(time, '$agg_interval'),\n sum(nullif(ct - ct_lag, 0)) as \"checkpoints_timed\",\n sum(nullif(cr - cr_lag, 0)) as \"checkpoints_req\"\nFROM (\n SELECT\n time,\n (data->>'checkpoints_timed')::int8 as ct, lag((data->>'checkpoints_timed')::int8) over w as ct_lag,\n (data->>'checkpoints_req')::int8 as cr, lag((data->>'checkpoints_req')::int8) over w as cr_lag\n FROM\n bgwriter\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n WINDOW w as (order by time)\n \n UNION ALL\n \n SELECT\n time,\n (data->>'num_timed')::int8 as ct, lag((data->>'num_timed')::int8) over w as ct_lag,\n (data->>'num_requested')::int8 as cr, lag((data->>'num_requested')::int8) over w as cr_lag\n FROM\n checkpointer\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n WINDOW w as (order by time)\n) x\nWHERE ct >= ct_lag and cr >= cr_lag\nGROUP BY 1\nORDER BY 1\n",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "checkpoints_timed"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "last"
+ },
+ {
+ "params": [
+ "1h"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$dbname$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "B",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "sum"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "points",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 8,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "always",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "checkpoints_req"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "semi-dark-red",
+ "mode": "fixed"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-4": {
+ "kind": "Panel",
+ "spec": {
+ "id": 4,
+ "title": "Checkpointer Write / Sync durations",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "checkpoint_write_time",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "1h"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "bgwriter",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "SELECT\n $__timeGroup(time, '$agg_interval'),\n sum(wt-wt_lag) as \"checkpoint_write_time\",\n sum(st-st_lag) as \"checkpoint_sync_time\"\nFROM (\n SELECT\n time,\n (data->>'write_time')::int8 as wt, lag((data->>'write_time')::int8) over w as wt_lag,\n (data->>'sync_time')::int8 as st, lag((data->>'sync_time')::int8) over w as st_lag\n FROM\n checkpointer\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n WINDOW w as (order by time) \n UNION ALL\n SELECT\n time,\n (data->>'checkpoint_write_time')::int8 as wt, lag((data->>'checkpoint_write_time')::int8) over w as wt_lag,\n (data->>'checkpoint_sync_time')::int8 as st, lag((data->>'checkpoint_sync_time')::int8) over w as st_lag\n FROM\n bgwriter\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n WINDOW w as (order by time)\n) x\nWHERE wt >= wt_lag or st >= st_lag\nGROUP BY 1\nORDER BY 1\n",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "checkpoint_write_time"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "1h"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$dbname$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "B",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "ms",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "always",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-5": {
+ "kind": "Panel",
+ "spec": {
+ "id": 5,
+ "title": "Bgwriter Stats",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "buffers_checkpoint",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "5m"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "bgwriter",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n 8192 * sum(buffers_checkpoint-buffers_checkpoint_lag) as \"buffers_checkpoint\",\n 8192 * sum(buffers_clean-buffers_clean_lag) as \"buffers_clean\",\n 8192 * sum(buffers_backend-buffers_backend_lag) as \"buffers_backend\"\nFROM (\n SELECT\n time,\n (data->>'buffers_checkpoint')::int8 as buffers_checkpoint, lag((data->>'buffers_checkpoint')::int8) over w as buffers_checkpoint_lag,\n (data->>'buffers_clean')::int8 as buffers_clean, lag((data->>'buffers_clean')::int8) over w as buffers_clean_lag,\n (data->>'buffers_backend')::int8 as buffers_backend, lag((data->>'buffers_backend')::int8) over w as buffers_backend_lag\n FROM\n bgwriter\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n WINDOW w as (order by time)\n) x\nWHERE buffers_checkpoint >= buffers_checkpoint_lag and buffers_clean >= buffers_clean_lag and buffers_backend >= buffers_backend_lag\nGROUP BY 1\nORDER BY 1\n",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "buffers_checkpoint"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "1h"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$dbname$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "B",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "60m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "bytes",
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "always",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-6": {
+ "kind": "Panel",
+ "spec": {
+ "id": 6,
+ "title": "Backend Read / Write times",
+ "description": "Based on pg_stat_database. Requires \"track_io_timing=on\"",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "blk_read_time (backend)",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "5m"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "db_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n sum(rt-rt_lag) as \"blk_read_time\",\n sum(wt-wt_lag) as \"blk_write_time\"\nFROM (\n SELECT\n time,\n (data->>'blk_read_time')::float8 as rt, lag((data->>'blk_read_time')::float8) over w as rt_lag,\n (data->>'blk_write_time')::float8 as wt, lag((data->>'blk_write_time')::float8) over w as wt_lag\n FROM\n db_stats\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n WINDOW w as (order by time)\n) x\nWHERE rt >= rt_lag and wt >= wt_lag\nGROUP BY 1\nORDER BY 1\n",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "blk_read_time"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "1h"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$dbname$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "15m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "ms",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "always",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-7": {
+ "kind": "Panel",
+ "spec": {
+ "id": 7,
+ "title": "Table / Index / Toast Blocks Read",
+ "description": "Reads could still be served by the Linux file system cache so they don't necessarily have to come from disk",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "heap_blks_read",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "15m"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "table_io_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n 8192 * sum(heap-heap_lag) as \"heap_blks_read\",\n 8192 * sum(idx-idx_lag) as \"idx_blks_read\",\n 8192 * sum(tidx-tidx_lag) as \"tidx_blks_read\",\n 8192 * sum(toast-toast_lag) as \"toast_blks_read\"\nFROM (\n SELECT\n time,\n (data->>'heap_blks_read')::float8 as heap, lag((data->>'heap_blks_read')::float8) over w as heap_lag,\n (data->>'idx_blks_read')::float8 as idx, lag((data->>'idx_blks_read')::float8) over w as idx_lag,\n (data->>'tidx_blks_read')::float8 as tidx, lag((data->>'tidx_blks_read')::float8) over w as tidx_lag,\n (data->>'toast_blks_read')::float8 as toast, lag((data->>'toast_blks_read')::float8) over w as toast_lag\n FROM\n table_io_stats\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n WINDOW w as (partition by tag_data->>'table_full_name' order by time)\n) x\nWHERE heap >= heap_lag and idx >= idx_lag\nGROUP BY 1\nORDER BY 1\n",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "heap_blks_read"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "1h"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$dbname$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "bytes",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "log": 10,
+ "type": "log"
+ },
+ "showPoints": "always",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-9": {
+ "kind": "Panel",
+ "spec": {
+ "id": 9,
+ "title": "",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "text",
+ "version": "10.4.1",
+ "spec": {
+ "options": {
+ "code": {
+ "language": "plaintext",
+ "showLineNumbers": false,
+ "showMiniMap": false
+ },
+ "content": "### Brought to you by\n\n[](https://www.cybertec-postgresql.com/en/)\n",
+ "mode": "markdown"
+ },
+ "fieldConfig": {
+ "defaults": {},
+ "overrides": []
+ }
+ }
+ },
+ "transparent": true
+ }
+ }
+ },
+ "layout": {
+ "kind": "GridLayout",
+ "spec": {
+ "items": [
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 0,
+ "width": 24,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-2"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 5,
+ "width": 24,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-4"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 10,
+ "width": 24,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-5"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 15,
+ "width": 24,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-6"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 20,
+ "width": 24,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-7"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 25,
+ "width": 12,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-9"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "links": [],
+ "liveNow": false,
+ "preload": false,
+ "tags": [
+ "pgwatch"
+ ],
+ "timeSettings": {
+ "from": "now-24h",
+ "to": "now",
+ "autoRefresh": "",
+ "autoRefreshIntervals": [
+ "5s",
+ "10s",
+ "30s",
+ "1m",
+ "5m",
+ "15m",
+ "30m",
+ "1h",
+ "2h",
+ "1d"
+ ],
+ "hideTimepicker": false,
+ "fiscalYearStartMonth": 0
+ },
+ "title": "Checkpointer / Bgwriter / Block IO Stats",
+ "variables": [
+ {
+ "kind": "QueryVariable",
+ "spec": {
+ "name": "dbname",
+ "current": {
+ "text": "",
+ "value": ""
+ },
+ "hide": "dontHide",
+ "refresh": "onDashboardLoad",
+ "skipUrlSync": false,
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "__legacyStringValue": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'bgwriter' ORDER BY 1;"
+ }
+ },
+ "regex": "",
+ "sort": "disabled",
+ "definition": "",
+ "options": [],
+ "multi": false,
+ "includeAll": false,
+ "allowCustomValue": true
+ }
+ },
+ {
+ "kind": "IntervalVariable",
+ "spec": {
+ "name": "agg_interval",
+ "query": "1s,1m,5m,10m,15m,30m,1h,3h,6h,12h,1d,7d,14d,30d",
+ "current": {
+ "text": "1h",
+ "value": "1h"
+ },
+ "options": [
+ {
+ "selected": false,
+ "text": "1s",
+ "value": "1s"
+ },
+ {
+ "selected": false,
+ "text": "1m",
+ "value": "1m"
+ },
+ {
+ "selected": false,
+ "text": "5m",
+ "value": "5m"
+ },
+ {
+ "selected": false,
+ "text": "10m",
+ "value": "10m"
+ },
+ {
+ "selected": false,
+ "text": "15m",
+ "value": "15m"
+ },
+ {
+ "selected": false,
+ "text": "30m",
+ "value": "30m"
+ },
+ {
+ "selected": true,
+ "text": "1h",
+ "value": "1h"
+ },
+ {
+ "selected": false,
+ "text": "3h",
+ "value": "3h"
+ },
+ {
+ "selected": false,
+ "text": "6h",
+ "value": "6h"
+ },
+ {
+ "selected": false,
+ "text": "12h",
+ "value": "12h"
+ },
+ {
+ "selected": false,
+ "text": "1d",
+ "value": "1d"
+ },
+ {
+ "selected": false,
+ "text": "7d",
+ "value": "7d"
+ },
+ {
+ "selected": false,
+ "text": "14d",
+ "value": "14d"
+ },
+ {
+ "selected": false,
+ "text": "30d",
+ "value": "30d"
+ }
+ ],
+ "auto": false,
+ "auto_min": "10s",
+ "auto_count": 30,
+ "refresh": "onTimeRangeChanged",
+ "hide": "dontHide",
+ "skipUrlSync": false
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/grafana/postgres/v13/global-health.json b/grafana/postgres/v13/global-health.json
new file mode 100644
index 0000000000..60456031f0
--- /dev/null
+++ b/grafana/postgres/v13/global-health.json
@@ -0,0 +1,2599 @@
+{
+ "apiVersion": "dashboard.grafana.app/v2",
+ "kind": "Dashboard",
+ "metadata": {
+ "name": "global-health"
+ },
+ "spec": {
+ "annotations": [
+ {
+ "kind": "AnnotationQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "grafana"
+ },
+ "spec": {}
+ },
+ "enable": true,
+ "hide": true,
+ "iconColor": "rgba(0, 211, 255, 1)",
+ "name": "Annotations & Alerts",
+ "builtIn": true,
+ "legacyOptions": {
+ "type": "dashboard"
+ }
+ }
+ }
+ ],
+ "cursorSync": "Off",
+ "editable": true,
+ "elements": {
+ "panel-10": {
+ "kind": "Panel",
+ "spec": {
+ "id": 10,
+ "title": "Top $top_limit by longest TX time",
+ "description": "Includes \"idle in transaction\" TX. 5 / 10 min default thresholds",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT * FROM (\nSELECT\n dbname,\n max((data->>'longest_tx_seconds')::int) AS longest_tx_seconds\nFROM\n backends\nWHERE\n $__timeFilter(\"time\")\nGROUP BY\n dbname\n) x\nWHERE longest_tx_seconds > 0\nORDER BY 2 DESC\nLIMIT $top_limit",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "longest_tx_seconds"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "dtdurations"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ },
+ {
+ "id": "custom.cellOptions",
+ "value": {
+ "type": "color-text"
+ }
+ },
+ {
+ "id": "custom.align"
+ },
+ {
+ "id": "thresholds",
+ "value": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "rgba(50, 172, 45, 0.97)",
+ "value": 0
+ },
+ {
+ "color": "rgba(237, 129, 40, 0.89)",
+ "value": 300
+ },
+ {
+ "color": "rgba(245, 54, 54, 0.9)",
+ "value": 600
+ }
+ ]
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "dbname"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": true,
+ "title": "Go to 'Overview' dash",
+ "url": "/d/db-overview?var-dbname=${__value.text}"
+ }
+ ]
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-11": {
+ "kind": "Panel",
+ "spec": {
+ "id": 11,
+ "title": "Lowest $top_limit by free disk %",
+ "description": "Assumes \"psutil_disk\" helper. 10 / 5% default warning thresholds",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select * from (\nselect \n dbname,\n max((data->>'percent')::float) as used_percent\nfrom\n psutil_disk\nwhere\n $__timeFilter(\"time\")\n and (data->>'percent')::float > 0\ngroup by\n dbname\n) x\norder by 2 desc nulls last\nlimit $top_limit",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "used_percent"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ },
+ {
+ "id": "custom.cellOptions",
+ "value": {
+ "type": "color-text"
+ }
+ },
+ {
+ "id": "custom.align"
+ },
+ {
+ "id": "thresholds",
+ "value": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "rgba(50, 172, 45, 0.97)",
+ "value": 0
+ },
+ {
+ "color": "rgba(237, 129, 40, 0.89)",
+ "value": 80
+ },
+ {
+ "color": "rgba(245, 54, 54, 0.9)",
+ "value": 90
+ }
+ ]
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "dbname"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": true,
+ "title": "Go to 'System Stats' dash",
+ "url": "/d/system-stats?var-dbname=${__value.text}"
+ }
+ ]
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-13": {
+ "kind": "Panel",
+ "spec": {
+ "id": 13,
+ "title": "",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "text",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "code": {
+ "language": "plaintext",
+ "showLineNumbers": false,
+ "showMiniMap": false
+ },
+ "content": "### Brought to you by\n\n[](https://www.cybertec-postgresql.com/en/)\n",
+ "mode": "markdown"
+ },
+ "fieldConfig": {
+ "defaults": {},
+ "overrides": []
+ }
+ }
+ },
+ "transparent": true
+ }
+ },
+ "panel-14": {
+ "kind": "Panel",
+ "spec": {
+ "id": 14,
+ "title": "Top $top_limit by used connections",
+ "description": "Assumes get_stat_activity() helper for non-privileged monitoring users",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT\n dbname,\n round(100 * instance_total::numeric / max_connections, 1) AS \"pct_used\",\n instance_total AS used_connections,\n max_connections\nFROM\n (\n select\n distinct on (dbname)\n dbname,\n (data->>'max_connections')::int as max_connections,\n (data->>'instance_total')::int as instance_total\n FROM\n backends\n WHERE\n $__timeFilter(time)\n order by dbname, time desc\n ) x\nORDER BY\n 2 DESC NULLS LAST\nLIMIT\n $top_limit",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "dbname"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": false,
+ "title": "Go to Overview dash",
+ "url": "/d/db-overview?var-dbname=${__value.text}"
+ }
+ ]
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "waiting"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "custom.cellOptions",
+ "value": {
+ "type": "color-text"
+ }
+ },
+ {
+ "id": "custom.align"
+ },
+ {
+ "id": "thresholds",
+ "value": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "rgba(50, 172, 45, 0.97)",
+ "value": 0
+ },
+ {
+ "color": "rgba(237, 129, 40, 0.89)",
+ "value": 1
+ },
+ {
+ "color": "rgba(245, 54, 54, 0.9)",
+ "value": 5
+ }
+ ]
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-15": {
+ "kind": "Panel",
+ "spec": {
+ "id": 15,
+ "title": "Top $top_limit by CPU utilization %",
+ "description": "Assumes \"psutil_cpu\" helpers are installed and configured",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT\n dbname,\n round(max((data->>'cpu_utilization')::numeric), 1) AS \"cpu_utilization\"\nFROM\n psutil_cpu\nWHERE\n $__timeFilter(\"time\")\nGROUP BY\n 1\nORDER BY\n 2 DESC NULLS LAST\nLIMIT\n $top_limit",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "dbname"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": false,
+ "title": "Go to Overview dash",
+ "url": "/d/db-overview?var-dbname=${__value.text}"
+ }
+ ]
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "cpu_utilization"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "percent"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ },
+ {
+ "id": "custom.cellOptions",
+ "value": {
+ "type": "color-text"
+ }
+ },
+ {
+ "id": "custom.align"
+ },
+ {
+ "id": "thresholds",
+ "value": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "rgba(50, 172, 45, 0.97)",
+ "value": 0
+ },
+ {
+ "color": "rgba(237, 129, 40, 0.89)",
+ "value": 30
+ },
+ {
+ "color": "rgba(245, 54, 54, 0.9)",
+ "value": 60
+ }
+ ]
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-16": {
+ "kind": "Panel",
+ "spec": {
+ "id": 16,
+ "title": "Top $top_limit by WAL folder size",
+ "description": "Needs \"get_wal_size\" helper for unprivileged monitoring users",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT\n dbname,\n max((data->>'wal_size_b')::int8) as wal_size\nFROM\n wal_size\nWHERE\n $__timeFilter(\"time\")\nGROUP BY\n 1\nORDER BY\n 2 DESC NULLS LAST\nLIMIT\n $top_limit",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "dbname"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": false,
+ "title": "Go to Overview dash",
+ "url": "/d/db-overview?var-dbname=${__value.text}"
+ }
+ ]
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "wal_size"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "bytes"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-17": {
+ "kind": "Panel",
+ "spec": {
+ "id": 17,
+ "title": "Top $top_limit by JIT %",
+ "description": "Top $top_limit sources by the percentage of total query execution time spent in JIT. (requires stat_statements metric).",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "editorMode": "code",
+ "format": "table",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select \n dbname, pct\nfrom (\n select \n dbname,\n (sum(total_jit - total_jit_lag) / sum(total_time - total_time_lag)) * 100 as pct\n from\n (\n select\n dbname,\n (data->>'jit_generation_time')::float8 as total_jit, lag((data->>'jit_generation_time')::float8) over w as total_jit_lag,\n (data->>'total_time')::float8 as total_time, lag((data->>'total_time')::float8) over w as total_time_lag\n from stat_statements\n where $__timeFilter(time)\n window w as (order by time)\n )\n where total_time > total_time_lag\n group by 1\n)\nwhere pct > 0\norder by 2 desc\nlimit $top_limit",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "pct"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "percent"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "custom.cellOptions",
+ "value": {
+ "type": "color-text"
+ }
+ },
+ {
+ "id": "custom.align"
+ },
+ {
+ "id": "thresholds",
+ "value": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "rgba(50, 172, 45, 0.97)",
+ "value": 0
+ },
+ {
+ "color": "rgba(237, 129, 40, 0.89)",
+ "value": 2
+ },
+ {
+ "color": "rgba(245, 54, 54, 0.9)",
+ "value": 5
+ }
+ ]
+ }
+ },
+ {
+ "id": "displayName",
+ "value": "percent"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "dbname"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": true,
+ "title": "Go to 'System Stats' dash",
+ "url": "/d/system-stats?var-dbname=${__value.text}"
+ }
+ ]
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-2": {
+ "kind": "Panel",
+ "spec": {
+ "id": 2,
+ "title": "Monitored primary DB-s ",
+ "description": "Please adjust the markers as needed!\n\nAlso the default query assumes that all DBs are separate instances. If not so change the query to add some filters or groupings based on the wal.sys_id column for example.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [
+ {
+ "params": [
+ "dbname"
+ ],
+ "type": "column"
+ }
+ ],
+ "metricColumn": "dbname",
+ "rawQuery": true,
+ "rawSql": "SELECT\n 0 AS \"time\",\n count(distinct dbname)\nFROM wal\nWHERE\n $__timeFilter(\"time\")\n AND (data->>'in_recovery_int')::int = 0",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ },
+ {
+ "params": [
+ "avg"
+ ],
+ "type": "aggregate"
+ },
+ {
+ "params": [
+ "value"
+ ],
+ "type": "alias"
+ }
+ ]
+ ],
+ "table": "db_stats",
+ "timeColumn": "\"time\"",
+ "timeColumnType": "timestamptz",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "gauge",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "minVizHeight": 75,
+ "minVizWidth": 75,
+ "orientation": "auto",
+ "reduceOptions": {
+ "calcs": [
+ "last"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showThresholdLabels": true,
+ "showThresholdMarkers": true,
+ "sizing": "auto"
+ },
+ "fieldConfig": {
+ "defaults": {
+ "min": 0,
+ "max": 10,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "dark-red"
+ },
+ {
+ "value": 10,
+ "color": "dark-green"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-3": {
+ "kind": "Panel",
+ "spec": {
+ "id": 3,
+ "title": "Monitored replica DB-s",
+ "description": "Please adjust the markers as needed!\n\nAlso the default query assumes that all DBs are separate instances. If not so change the query to add some filters or groupings based on the wal.sys_id column for example.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [
+ {
+ "params": [
+ "dbname"
+ ],
+ "type": "column"
+ }
+ ],
+ "metricColumn": "dbname",
+ "rawQuery": true,
+ "rawSql": "SELECT\n 0 AS \"time\",\n count(distinct dbname)\nFROM\n wal\nWHERE\n $__timeFilter(\"time\")\n AND (data->>'in_recovery_int')::int = 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ },
+ {
+ "params": [
+ "avg"
+ ],
+ "type": "aggregate"
+ },
+ {
+ "params": [
+ "value"
+ ],
+ "type": "alias"
+ }
+ ]
+ ],
+ "table": "db_stats",
+ "timeColumn": "\"time\"",
+ "timeColumnType": "timestamptz",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "gauge",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "minVizHeight": 75,
+ "minVizWidth": 75,
+ "orientation": "auto",
+ "reduceOptions": {
+ "calcs": [
+ "last"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showThresholdLabels": true,
+ "showThresholdMarkers": true,
+ "sizing": "auto"
+ },
+ "fieldConfig": {
+ "defaults": {
+ "min": 0,
+ "max": 10,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "dark-red"
+ },
+ {
+ "value": 9,
+ "color": "dark-orange"
+ },
+ {
+ "value": 10,
+ "color": "dark-green"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-5": {
+ "kind": "Panel",
+ "spec": {
+ "id": 5,
+ "title": "Offline nodes",
+ "description": "Configured to be monitored but no recent data",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "editorMode": "code",
+ "format": "table",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT\n dbname,\n (SELECT CASE WHEN data->>'in_recovery_int' = '0' THEN 'primary' ELSE 'replica' END FROM wal WHERE dbname = c.dbname ORDER BY time DESC LIMIT 1) AS last_role,\n (SELECT (extract(epoch from now() - time))::int8 FROM instance_up WHERE (data->>'instance_up')::int8 = 1 AND dbname = c.dbname ORDER BY time DESC LIMIT 1) AS last_seen,\n (SELECT (data->>'postmaster_uptime_s')::int FROM db_stats WHERE dbname = c.dbname ORDER BY time DESC LIMIT 1) AS last_seen_uptime\nFROM\n (SELECT DISTINCT ON (dbname) * FROM instance_up ORDER BY dbname, time DESC) AS c\nWHERE\n (data->>'instance_up')::int8 = 0\n AND $__timeFilter(time)\nORDER BY dbname, time DESC\n",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "last_seen"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "dtdurations"
+ },
+ {
+ "id": "custom.cellOptions",
+ "value": {
+ "type": "color-background"
+ }
+ },
+ {
+ "id": "custom.align"
+ },
+ {
+ "id": "thresholds",
+ "value": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "#FA6400",
+ "value": 0
+ },
+ {
+ "color": "#E02F44",
+ "value": 600
+ },
+ {
+ "color": "#C4162A",
+ "value": 3600
+ }
+ ]
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "last_seen_uptime"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "dtdurations"
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "dbname"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": true,
+ "title": "Go to Overview dash",
+ "url": "/d/db-overview?var-dbname=${__value.text}"
+ }
+ ]
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-6": {
+ "kind": "Panel",
+ "spec": {
+ "id": 6,
+ "title": "Top $top_limit by blocked sessions",
+ "description": "Assumes get_stat_activity() helper for non-privileged monitoring users",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT\n dbname,\n max((data->>'waiting')::int) AS \"waiting\"\nFROM\n backends\nWHERE\n $__timeFilter(\"time\")\n AND (data->>'waiting')::int > 0\nGROUP BY\n 1\nORDER BY\n 2 DESC NULLS LAST\nLIMIT\n $top_limit",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "dbname"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": false,
+ "title": "Go to Overview dash",
+ "url": "/d/db-overview?var-dbname=${__value.text}"
+ }
+ ]
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "waiting"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "custom.cellOptions",
+ "value": {
+ "type": "color-text"
+ }
+ },
+ {
+ "id": "custom.align"
+ },
+ {
+ "id": "thresholds",
+ "value": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "rgba(50, 172, 45, 0.97)",
+ "value": 0
+ },
+ {
+ "color": "rgba(237, 129, 40, 0.89)",
+ "value": 1
+ },
+ {
+ "color": "rgba(245, 54, 54, 0.9)",
+ "value": 5
+ }
+ ]
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-7": {
+ "kind": "Panel",
+ "spec": {
+ "id": 7,
+ "title": "Top $top_limit by TX rollback %",
+ "description": "Last $__interval average. 2 /5 % threshold defaults.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select * from (\nselect\n dbname,\n avg((roll-roll_lag)::numeric / ((roll-roll_lag) + (comm-comm_lag)))*100 as \"rollback_ratio\"\nfrom (\n select\n dbname,\n time,\n (data->>'xact_rollback')::int8 as roll, lag((data->>'xact_rollback')::int8) over w as roll_lag,\n (data->>'xact_commit')::int8 as comm, lag((data->>'xact_commit')::int8) over w as comm_lag\n FROM\n db_stats\n WHERE\n $__timeFilter(\"time\")\n window w as (partition by dbname order by time)\n) x\nWHERE comm > comm_lag or roll > roll_lag\nGROUP BY 1\n) y\nWHERE rollback_ratio > 0\nORDER BY 2 DESC\nLIMIT $top_limit\n",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "enablePagination": false,
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "filterable": false,
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "rollback_ratio"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "none"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ },
+ {
+ "id": "custom.cellOptions",
+ "value": {
+ "type": "color-text"
+ }
+ },
+ {
+ "id": "custom.align"
+ },
+ {
+ "id": "thresholds",
+ "value": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "rgba(50, 172, 45, 0.97)",
+ "value": 0
+ },
+ {
+ "color": "rgba(237, 129, 40, 0.89)",
+ "value": 2
+ },
+ {
+ "color": "rgba(245, 54, 54, 0.9)",
+ "value": 5
+ }
+ ]
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "dbname"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": true,
+ "title": "Go to 'Overview' dash",
+ "url": "/d/db-overview?var-dbname=${__value.text}"
+ }
+ ]
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-8": {
+ "kind": "Panel",
+ "spec": {
+ "id": 8,
+ "title": "Top $top_limit by replication lag",
+ "description": "1 / 16 MB default thresholds",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select * from (\nselect \n dbname,\n max((data->>'replay_lag_b')::int8) as replay_lag_b\nfrom\n replication\nwhere\n (data->>'replay_lag_b')::int8 > 0\ngroup by\n dbname\n) x\norder by 2 desc\nlimit $top_limit",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "replay_lag_b"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "bytes"
+ },
+ {
+ "id": "custom.cellOptions",
+ "value": {
+ "type": "color-text"
+ }
+ },
+ {
+ "id": "custom.align"
+ },
+ {
+ "id": "thresholds",
+ "value": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "rgba(50, 172, 45, 0.97)",
+ "value": 0
+ },
+ {
+ "color": "rgba(237, 129, 40, 0.89)",
+ "value": 1000000
+ },
+ {
+ "color": "rgba(245, 54, 54, 0.9)",
+ "value": 16000000
+ }
+ ]
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "dbname"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": true,
+ "title": "Go to 'Replication' dash",
+ "url": "/d/replication?var-dbname=${__value.text}"
+ }
+ ]
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-9": {
+ "kind": "Panel",
+ "spec": {
+ "id": 9,
+ "title": "Top $top_limit by temp. files",
+ "description": "100 MB / 1 GB default threshold",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select * from (\nselect\n dbname,\n avg((tb-tb_lag) / (etime - lag_etime))*60 as \"temp_bytes_per_minute\"\nfrom (\n select\n dbname,\n (data->>'temp_bytes')::int8 as tb, lag((data->>'temp_bytes')::int8) over w as tb_lag,\n (extract(epoch from time))::int8 as etime,\n (lag(extract(epoch from time)) over w)::int8 as lag_etime\n from db_stats\n where $__timeFilter(time)\n window w as (partition by dbname order by time)\n) x\nwhere\n tb >= tb_lag and etime > lag_etime\ngroup by\n dbname\n) y\nwhere temp_bytes_per_minute > 0\norder by 2 desc\nlimit $top_limit",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "temp_bytes_per_minute"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "bytes"
+ },
+ {
+ "id": "custom.cellOptions",
+ "value": {
+ "type": "color-text"
+ }
+ },
+ {
+ "id": "custom.align"
+ },
+ {
+ "id": "thresholds",
+ "value": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "rgba(50, 172, 45, 0.97)",
+ "value": 0
+ },
+ {
+ "color": "rgba(237, 129, 40, 0.89)",
+ "value": 100000000
+ },
+ {
+ "color": "rgba(245, 54, 54, 0.9)",
+ "value": 1000000000
+ }
+ ]
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "dbname"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Go to 'Overview' dash"
+ },
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": true,
+ "title": "Go to 'Overview' dash",
+ "url": "/d/db-overview?var-dbname=${__value.text}"
+ }
+ ]
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ }
+ },
+ "layout": {
+ "kind": "GridLayout",
+ "spec": {
+ "items": [
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 0,
+ "width": 8,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-2"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 8,
+ "y": 0,
+ "width": 8,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-3"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 16,
+ "y": 0,
+ "width": 8,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-5"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 7,
+ "width": 8,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-7"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 8,
+ "y": 7,
+ "width": 8,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-10"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 16,
+ "y": 7,
+ "width": 8,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-6"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 12,
+ "width": 8,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-14"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 8,
+ "y": 12,
+ "width": 8,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-9"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 16,
+ "y": 12,
+ "width": 8,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-8"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 17,
+ "width": 8,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-11"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 8,
+ "y": 17,
+ "width": 8,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-15"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 16,
+ "y": 17,
+ "width": 8,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-16"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 22,
+ "width": 8,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-17"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 8,
+ "y": 22,
+ "width": 8,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-13"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "links": [],
+ "liveNow": false,
+ "preload": false,
+ "tags": [
+ "pgwatch"
+ ],
+ "timeSettings": {
+ "from": "now-1h",
+ "to": "now",
+ "autoRefresh": "1m",
+ "autoRefreshIntervals": [
+ "5s",
+ "10s",
+ "30s",
+ "1m",
+ "5m",
+ "15m",
+ "30m",
+ "1h",
+ "2h",
+ "1d"
+ ],
+ "hideTimepicker": false,
+ "fiscalYearStartMonth": 0
+ },
+ "title": "Global Health",
+ "variables": [
+ {
+ "kind": "CustomVariable",
+ "spec": {
+ "name": "top_limit",
+ "query": "1,3,5,10",
+ "current": {
+ "text": "3",
+ "value": "3"
+ },
+ "options": [
+ {
+ "selected": false,
+ "text": "1",
+ "value": "1"
+ },
+ {
+ "selected": true,
+ "text": "3",
+ "value": "3"
+ },
+ {
+ "selected": false,
+ "text": "5",
+ "value": "5"
+ },
+ {
+ "selected": false,
+ "text": "10",
+ "value": "10"
+ }
+ ],
+ "multi": false,
+ "includeAll": false,
+ "hide": "dontHide",
+ "skipUrlSync": false,
+ "allowCustomValue": true
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/grafana/postgres/v13/index-overview.json b/grafana/postgres/v13/index-overview.json
new file mode 100644
index 0000000000..3f859b672b
--- /dev/null
+++ b/grafana/postgres/v13/index-overview.json
@@ -0,0 +1,2101 @@
+{
+ "apiVersion": "dashboard.grafana.app/v2",
+ "kind": "Dashboard",
+ "metadata": {
+ "name": "index-overview"
+ },
+ "spec": {
+ "annotations": [
+ {
+ "kind": "AnnotationQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "grafana"
+ },
+ "spec": {}
+ },
+ "enable": true,
+ "hide": true,
+ "iconColor": "rgba(0, 211, 255, 1)",
+ "name": "Annotations & Alerts",
+ "builtIn": true,
+ "legacyOptions": {
+ "type": "dashboard"
+ }
+ }
+ }
+ ],
+ "cursorSync": "Off",
+ "editable": true,
+ "elements": {
+ "panel-10": {
+ "kind": "Panel",
+ "spec": {
+ "id": 10,
+ "title": "Unused indexes (Non-PK)",
+ "description": "Before dropping indexes make sure they are not used on replicas, if having any. FYI - one could also adjust the default 0 threshold so that \"little used\" indexes are shown.\n\nRequires `reco_drop_index` metric.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "SELECT\n dbname as \"Source Name\",\n tag_data->>'table_full_name' as \"Table Name\",\n tag_data->>'object_name' as \"Index Name\",\n (data->>'index_size_b')::int8 as \"Index size\",\n 0::int8 as \"Scans\"\nFROM\n recommendations \nWHERE \n time in (\n select max(time) \n from recommendations \n where $__timeFilter(time) AND dbname in ($dbname) \n and tag_data->>'reco_topic' = 'drop_index' and tag_data->>'issue_type' = 'unused' \n group by dbname\n )\n AND dbname IN ($dbname) AND tag_data->>'reco_topic' = 'drop_index' and tag_data->>'issue_type' = 'unused'\n",
+ "resultFormat": "table",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true,
+ "sortBy": []
+ },
+ "fieldConfig": {
+ "defaults": {
+ "displayName": "",
+ "unit": "short",
+ "decimals": 2,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "footer": {
+ "reducers": []
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Table Name"
+ },
+ "properties": [
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": true,
+ "title": "Opens 'Table details' dashboard",
+ "url": "/d/table-details?var-dbname=${__data.fields[\"dbname\"]}&var-table_full_name=${__data.fields[\"table_full_name\"]}"
+ }
+ ]
+ },
+ {
+ "id": "custom.align",
+ "value": "left"
+ },
+ {
+ "id": "custom.width",
+ "value": 173
+ },
+ {
+ "id": "custom.inspect",
+ "value": true
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Index size"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "bytes"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ },
+ {
+ "id": "custom.align",
+ "value": "left"
+ },
+ {
+ "id": "custom.width",
+ "value": 126
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Index Name"
+ },
+ "properties": [
+ {
+ "id": "custom.width",
+ "value": 179
+ },
+ {
+ "id": "custom.inspect",
+ "value": true
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Scans"
+ },
+ "properties": [
+ {
+ "id": "decimals",
+ "value": 0
+ },
+ {
+ "id": "custom.align",
+ "value": "left"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Source Name"
+ },
+ "properties": [
+ {
+ "id": "custom.width",
+ "value": 137
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-11": {
+ "kind": "Panel",
+ "spec": {
+ "id": 11,
+ "title": "Invalid indexes",
+ "description": "Requires `reco_drop_index` metric.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "SELECT\n dbname as \"Source Name\",\n tag_data->>'table_full_name' as \"Table Name\",\n tag_data->>'object_name' as \"Index Name\",\n (data->>'index_size_b')::int8 as \"Index size\"\nFROM\n recommendations \nWHERE \n time in (\n select max(time) \n from recommendations \n where $__timeFilter(time) AND dbname in ($dbname) \n and tag_data->>'reco_topic' = 'drop_index' and tag_data->>'issue_type' = 'invalid' \n group by dbname\n )\n AND dbname IN ($dbname) AND tag_data->>'reco_topic' = 'drop_index' and tag_data->>'issue_type' = 'invalid'\n",
+ "resultFormat": "table",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true,
+ "sortBy": []
+ },
+ "fieldConfig": {
+ "defaults": {
+ "displayName": "",
+ "unit": "short",
+ "decimals": 2,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "footer": {
+ "reducers": []
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Table Name"
+ },
+ "properties": [
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": true,
+ "title": "Opens 'Table details' dashboard",
+ "url": "/d/table-details?var-dbname=${__data.fields[\"dbname\"]}&var-table_full_name=${__data.fields[\"table_full_name\"]}"
+ }
+ ]
+ },
+ {
+ "id": "custom.align"
+ },
+ {
+ "id": "custom.width",
+ "value": 245
+ },
+ {
+ "id": "custom.inspect",
+ "value": true
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Index size"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "bytes"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ },
+ {
+ "id": "custom.align",
+ "value": "left"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Index Name"
+ },
+ "properties": [
+ {
+ "id": "custom.width",
+ "value": 203
+ },
+ {
+ "id": "custom.inspect",
+ "value": true
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-12": {
+ "kind": "Panel",
+ "spec": {
+ "id": 12,
+ "title": "Missing Indexes",
+ "description": "Adding indexes can have unexpected performance effects, so ensure that you test them first to verify that the recommendation has the desired effect.\n\nRequires `reco_add_index` metric. \n\nColumn Guide:\n- **Sum. Avg Queries Exec Time**: the sum of the average execution time for all queries that should be optimized by this index.\n- **Affected Queries**: all affected query ids to investigate further\n- **Recommendation**: the recommended index ddl.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT\n dbname as \"Source Name\",\n tag_data->>'object_name' AS \"Table Name\",\n data->>'total_avg_exec_time' AS \"Sum. Avg Exec Time\",\n data->>'affected_query_ids' AS \"Affected Queries\",\n data->>'recommendation' AS \"Recommendation\"\nFROM recommendations \nWHERE \n time in (\n select max(time) \n from recommendations \n where time <= $__timeTo() AND dbname in ($dbname) and tag_data->>'reco_topic' = 'create_index' \n group by dbname\n )\n AND dbname IN ($dbname) AND tag_data->>'reco_topic' = 'create_index' \nORDER BY (data->>'total_avg_exec_time')::float8 DESC",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "md",
+ "enablePagination": false,
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "footer": {
+ "reducers": []
+ },
+ "inspect": false,
+ "wrapText": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Table Name"
+ },
+ "properties": [
+ {
+ "id": "custom.width",
+ "value": 182
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "title": "Opens 'Table details' dashboard for this table",
+ "url": "d/table-details/5-table-details?orgId=1&var-dbname=${__data.fields[\"Source Name\"]}&var-table_full_name=${__value.raw}"
+ }
+ ]
+ },
+ {
+ "id": "custom.inspect",
+ "value": true
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Recommendation"
+ },
+ "properties": [
+ {
+ "id": "custom.inspect",
+ "value": true
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Affected Queries"
+ },
+ "properties": [
+ {
+ "id": "custom.width",
+ "value": 372
+ },
+ {
+ "id": "custom.inspect",
+ "value": true
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Source Name"
+ },
+ "properties": [
+ {
+ "id": "custom.width",
+ "value": 151
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Sum. Avg Exec Time"
+ },
+ "properties": [
+ {
+ "id": "custom.width",
+ "value": 193
+ },
+ {
+ "id": "unit",
+ "value": "ms"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-13": {
+ "kind": "Panel",
+ "spec": {
+ "id": 13,
+ "title": "Top $top indexes by disk reads",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "rawQuery": true,
+ "rawSql": "with index_stats_changes as (\n select\n time,\n dbname,\n tag_data->>'index_full_name' as index_full_name,\n coalesce((data->>'idx_blks_read')::int8 - lag((data->>'idx_blks_read')::int8) over w, 0) as blks_read\n from index_stats \n where dbname in ($dbname) and $__timeFilter(time)\n window w as (partition by dbname, tag_data->>'index_full_name' order by time)\n), top_indexes as (\n select\n dbname,\n index_full_name,\n sum(blks_read) as total_blks_read\n from index_stats_changes\n group by dbname, index_full_name\n order by total_blks_read desc\n limit $top\n), blocks(size) as (\n select (data->>'block_size')::int8\n from settings\n where time <= $__timeTo()\n order by time desc\n limit 1\n)\n\nselect \n $__timeGroup(time, $agg_interval),\n sum(blks_read) * (select size from blocks) as blks_read,\n dbname || ' ' || index_full_name as metric\nfrom index_stats_changes\nwhere dbname in (select dbname from top_indexes)\nand index_full_name in (select index_full_name from top_indexes)\ngroup by 1, dbname, index_full_name\norder by 1, dbname, index_full_name",
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ }
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "min",
+ "max",
+ "mean"
+ ],
+ "displayMode": "table",
+ "placement": "bottom",
+ "showLegend": true,
+ "sortBy": "Max",
+ "sortDesc": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "binBps",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "vis": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "showValues": false,
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-14": {
+ "kind": "Panel",
+ "spec": {
+ "id": 14,
+ "title": "Top $top indexes by cache hits",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "rawQuery": true,
+ "rawSql": "with index_stats_changes as (\n select\n time,\n dbname,\n tag_data->>'index_full_name' as index_full_name,\n coalesce((data->>'idx_blks_hit')::int8 - lag((data->>'idx_blks_hit')::int8) over w, 0) as blks_hit\n from index_stats \n where dbname in ($dbname) and $__timeFilter(time)\n window w as (partition by dbname, tag_data->>'index_full_name' order by time)\n), top_indexes as (\n select\n dbname,\n index_full_name,\n sum(blks_hit) as total_blks_hit\n from index_stats_changes\n group by dbname, index_full_name\n order by total_blks_hit desc\n limit $top\n), blocks(size) as (\n select (data->>'block_size')::int8\n from settings\n where time <= $__timeTo()\n order by time desc\n limit 1\n)\n\nselect \n $__timeGroup(time, $agg_interval),\n sum(blks_hit) * (select size from blocks) as blks_hit,\n dbname || ' ' || index_full_name as metric\nfrom index_stats_changes\nwhere dbname in (select dbname from top_indexes)\nand index_full_name in (select index_full_name from top_indexes)\ngroup by 1, dbname, index_full_name\norder by 1, dbname, index_full_name",
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ }
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "min",
+ "max",
+ "mean"
+ ],
+ "displayMode": "table",
+ "placement": "bottom",
+ "showLegend": true,
+ "sortBy": "Max",
+ "sortDesc": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "binBps",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "vis": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "showValues": false,
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-15": {
+ "kind": "Panel",
+ "spec": {
+ "id": 15,
+ "title": "Top $top indexes by number of tuples read",
+ "description": "Tuples Read = Number of index entries returned by scans on this index",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "rawQuery": true,
+ "rawSql": "with index_stats_changes as (\n select\n time,\n dbname,\n tag_data->>'index_full_name' as index_full_name,\n coalesce((data->>'idx_tup_read')::int8 - lag((data->>'idx_tup_read')::int8) over w, 0) as tuples_read\n from index_stats \n where dbname in ($dbname) and $__timeFilter(time)\n window w as (partition by dbname, tag_data->>'index_full_name' order by time)\n), top_indexes as (\n select\n dbname,\n index_full_name,\n sum(tuples_read) as total_tuples_read\n from index_stats_changes\n group by dbname, index_full_name\n order by total_tuples_read desc\n limit $top\n)\nselect \n $__timeGroup(time, $agg_interval),\n sum(tuples_read) as tuples_read,\n dbname || ' ' || index_full_name as metric\nfrom index_stats_changes\nwhere dbname in (select dbname from top_indexes)\nand index_full_name in (select index_full_name from top_indexes)\ngroup by 1, dbname, index_full_name\norder by 1, dbname, index_full_name",
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ }
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "min",
+ "max",
+ "mean"
+ ],
+ "displayMode": "table",
+ "placement": "bottom",
+ "showLegend": true,
+ "sortBy": "Max",
+ "sortDesc": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "vis": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "showValues": false,
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-16": {
+ "kind": "Panel",
+ "spec": {
+ "id": 16,
+ "title": "Top $top indexes by number of tuples fetched",
+ "description": "Tuples Fetched = Number of live rows fetched from the table by simple index scans using this index",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "rawQuery": true,
+ "rawSql": "with index_stats_changes as (\n select\n time,\n dbname,\n tag_data->>'index_full_name' as index_full_name,\n coalesce((data->>'idx_tup_fetch')::int8 - lag((data->>'idx_tup_fetch')::int8) over w, 0) as tuples_fetched\n from index_stats \n where dbname in ($dbname) and $__timeFilter(time)\n window w as (partition by dbname, tag_data->>'index_full_name' order by time)\n), top_indexes as (\n select\n dbname,\n index_full_name,\n sum(tuples_fetched) as total_tuples_fetched\n from index_stats_changes\n group by dbname, index_full_name\n order by total_tuples_fetched desc\n limit $top\n)\nselect \n $__timeGroup(time, $agg_interval),\n sum(tuples_fetched) as tuples_fetched,\n dbname || ' ' || index_full_name as metric\nfrom index_stats_changes\nwhere dbname in (select dbname from top_indexes)\nand index_full_name in (select index_full_name from top_indexes)\ngroup by 1, dbname, index_full_name\norder by 1, dbname, index_full_name",
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ }
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "min",
+ "max",
+ "mean"
+ ],
+ "displayMode": "table",
+ "placement": "bottom",
+ "showLegend": true,
+ "sortBy": "Max",
+ "sortDesc": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "vis": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "showValues": false,
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-6": {
+ "kind": "Panel",
+ "spec": {
+ "id": 6,
+ "title": "",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "text",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "code": {
+ "language": "plaintext",
+ "showLineNumbers": false,
+ "showMiniMap": false
+ },
+ "content": "## Brought to you by\n\n\n
\n",
+ "mode": "markdown"
+ },
+ "fieldConfig": {
+ "defaults": {},
+ "overrides": []
+ }
+ }
+ },
+ "transparent": true
+ }
+ },
+ "panel-8": {
+ "kind": "Panel",
+ "spec": {
+ "id": 8,
+ "title": "Duplicate Indexes",
+ "description": "Requires `reco_drop_index` metric.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "SELECT\n dbname as \"Source Name\",\n tag_data->>'table_full_name' as \"Table Name\",\n (data->>'index_size_b')::int8 as \"Max Index size\",\n data->>'duplicate_count' as \"Num of duplicates\",\n data->>'oids' as \"OIDs\",\n data->>'index_def' as \"Index def\"\nFROM\n recommendations \nWHERE \n time in (\n select max(time) \n from recommendations \n where $__timeFilter(time) AND dbname in ($dbname) \n and tag_data->>'reco_topic' = 'drop_index' and tag_data->>'issue_type' = 'duplicate' \n group by dbname\n )\n AND dbname IN ($dbname) AND tag_data->>'reco_topic' = 'drop_index' and tag_data->>'issue_type' = 'duplicate'\n\n",
+ "resultFormat": "table",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "displayName": "",
+ "unit": "short",
+ "decimals": 2,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "footer": {
+ "reducers": []
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Index def"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "custom.align",
+ "value": "left"
+ },
+ {
+ "id": "custom.inspect",
+ "value": true
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Max Index size"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "bytes"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ },
+ {
+ "id": "custom.align",
+ "value": "left"
+ },
+ {
+ "id": "custom.width",
+ "value": 150
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Table Name"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": true,
+ "title": "Opens 'Table details' dashboard",
+ "url": "/d/table-details?var-dbname=${__data.fields[\"dbname\"]}&var-table_full_name=${__data.fields[\"table_full_name\"]}"
+ }
+ ]
+ },
+ {
+ "id": "custom.align",
+ "value": "left"
+ },
+ {
+ "id": "custom.width",
+ "value": 222
+ },
+ {
+ "id": "custom.inspect",
+ "value": true
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Num of duplicates"
+ },
+ "properties": [
+ {
+ "id": "custom.width",
+ "value": 154
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "OIDs"
+ },
+ "properties": [
+ {
+ "id": "custom.width",
+ "value": 244
+ },
+ {
+ "id": "custom.inspect",
+ "value": true
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Source Name"
+ },
+ "properties": [
+ {
+ "id": "custom.width",
+ "value": 146
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-9": {
+ "kind": "Panel",
+ "spec": {
+ "id": 9,
+ "title": "Top $top biggest indexes",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "WITH index_scan_changes AS (\n SELECT\n time,\n dbname,\n tag_data ->> 'index_full_name' AS index_full_name,\n tag_data ->> 'table_full_name' AS table_full_name,\n (data ->> 'idx_scan')::int8 - LEAD((data ->> 'idx_scan')::int8) OVER w AS idx_scans,\n (data ->> 'index_size_b')::int8 AS index_size_b,\n ROW_NUMBER() OVER w AS rn\n FROM\n index_stats\n WHERE\n dbname IN ($dbname)\n WINDOW w AS (\n PARTITION BY dbname,\n tag_data ->> 'table_full_name',\n tag_data ->> 'index_full_name'\n ORDER BY time DESC\n )\n),\ntotal_scans AS (\n SELECT\n dbname,\n table_full_name,\n index_full_name,\n SUM(COALESCE(idx_scans, 0)) AS total_idx_scans,\n MAX(index_size_b) FILTER (WHERE rn = 1) AS latest_index_size\n FROM\n index_scan_changes\n WHERE\n $__timeFilter(time)\n GROUP BY\n dbname, table_full_name, index_full_name\n)\nSELECT\n dbname AS \"Source Name\",\n index_full_name AS \"Index Name\",\n table_full_name AS \"Table Name\",\n latest_index_size AS \"Index Size\",\n total_idx_scans AS \"Scans\"\nFROM\n total_scans\nORDER BY\n latest_index_size DESC\nLIMIT $top",
+ "resultFormat": "table",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "displayName": "",
+ "unit": "short",
+ "decimals": 2,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": []
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "footer": {
+ "reducers": []
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Table Name"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": true,
+ "title": "Opens 'Table details' dashboard",
+ "url": "/d/table-details?var-dbname=${__data.fields[\"dbname\"]}&var-table_full_name=${__data.fields[\"table_full_name\"]}"
+ }
+ ]
+ },
+ {
+ "id": "custom.align",
+ "value": "left"
+ },
+ {
+ "id": "custom.width",
+ "value": 480
+ },
+ {
+ "id": "custom.inspect",
+ "value": true
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Index Size"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "bytes"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ },
+ {
+ "id": "custom.align",
+ "value": "left"
+ },
+ {
+ "id": "custom.width",
+ "value": 301
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Scans"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 0
+ },
+ {
+ "id": "custom.align",
+ "value": "left"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Index Name"
+ },
+ "properties": [
+ {
+ "id": "custom.width",
+ "value": 392
+ },
+ {
+ "id": "custom.inspect",
+ "value": true
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ }
+ },
+ "layout": {
+ "kind": "GridLayout",
+ "spec": {
+ "items": [
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 0,
+ "width": 24,
+ "height": 8,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-9"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 8,
+ "width": 12,
+ "height": 8,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-13"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 12,
+ "y": 8,
+ "width": 12,
+ "height": 8,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-14"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 16,
+ "width": 12,
+ "height": 8,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-15"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 12,
+ "y": 16,
+ "width": 12,
+ "height": 8,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-16"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 24,
+ "width": 24,
+ "height": 8,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-12"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 32,
+ "width": 12,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-11"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 12,
+ "y": 32,
+ "width": 12,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-10"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 39,
+ "width": 24,
+ "height": 6,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-8"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 45,
+ "width": 24,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-6"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "links": [],
+ "liveNow": false,
+ "preload": false,
+ "tags": [
+ "pgwatch"
+ ],
+ "timeSettings": {
+ "timezone": "browser",
+ "from": "now-12h",
+ "to": "now",
+ "autoRefresh": "",
+ "autoRefreshIntervals": [
+ "5s",
+ "10s",
+ "30s",
+ "1m",
+ "5m",
+ "15m",
+ "30m",
+ "1h",
+ "2h",
+ "1d"
+ ],
+ "hideTimepicker": false,
+ "fiscalYearStartMonth": 0
+ },
+ "title": "Index overview",
+ "variables": [
+ {
+ "kind": "QueryVariable",
+ "spec": {
+ "name": "dbname",
+ "current": {
+ "text": "All",
+ "value": [
+ "$__all"
+ ]
+ },
+ "label": "Source Name",
+ "hide": "dontHide",
+ "refresh": "onDashboardLoad",
+ "skipUrlSync": false,
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "__legacyStringValue": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics ORDER BY 1;"
+ }
+ },
+ "regex": "",
+ "sort": "disabled",
+ "definition": "",
+ "options": [],
+ "multi": true,
+ "includeAll": true,
+ "allowCustomValue": true
+ }
+ },
+ {
+ "kind": "CustomVariable",
+ "spec": {
+ "name": "top",
+ "query": "10,15,30,50,100",
+ "current": {
+ "text": "10",
+ "value": "10"
+ },
+ "options": [
+ {
+ "selected": true,
+ "text": "10",
+ "value": "10"
+ },
+ {
+ "selected": false,
+ "text": "15",
+ "value": "15"
+ },
+ {
+ "selected": false,
+ "text": "30",
+ "value": "30"
+ },
+ {
+ "selected": false,
+ "text": "50",
+ "value": "50"
+ },
+ {
+ "selected": false,
+ "text": "100",
+ "value": "100"
+ }
+ ],
+ "multi": false,
+ "includeAll": false,
+ "label": "Top",
+ "hide": "dontHide",
+ "skipUrlSync": false,
+ "allowCustomValue": true
+ }
+ },
+ {
+ "kind": "IntervalVariable",
+ "spec": {
+ "name": "agg_interval",
+ "query": "5m,10m,15m,30m,1h,6h,12h,1d",
+ "current": {
+ "text": "5m",
+ "value": "5m"
+ },
+ "options": [
+ {
+ "selected": true,
+ "text": "5m",
+ "value": "5m"
+ },
+ {
+ "selected": false,
+ "text": "10m",
+ "value": "10m"
+ },
+ {
+ "selected": false,
+ "text": "15m",
+ "value": "15m"
+ },
+ {
+ "selected": false,
+ "text": "30m",
+ "value": "30m"
+ },
+ {
+ "selected": false,
+ "text": "1h",
+ "value": "1h"
+ },
+ {
+ "selected": false,
+ "text": "6h",
+ "value": "6h"
+ },
+ {
+ "selected": false,
+ "text": "12h",
+ "value": "12h"
+ },
+ {
+ "selected": false,
+ "text": "1d",
+ "value": "1d"
+ }
+ ],
+ "auto": false,
+ "auto_min": "10s",
+ "auto_count": 30,
+ "refresh": "onTimeRangeChanged",
+ "label": "Aggregate Interval",
+ "hide": "dontHide",
+ "skipUrlSync": false
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/grafana/postgres/v13/pgbouncer-stats.json b/grafana/postgres/v13/pgbouncer-stats.json
new file mode 100644
index 0000000000..72dcad1e49
--- /dev/null
+++ b/grafana/postgres/v13/pgbouncer-stats.json
@@ -0,0 +1,2637 @@
+{
+ "apiVersion": "dashboard.grafana.app/v2",
+ "kind": "Dashboard",
+ "metadata": {
+ "name": "pgbouncer-stats"
+ },
+ "spec": {
+ "annotations": [
+ {
+ "kind": "AnnotationQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "grafana"
+ },
+ "spec": {}
+ },
+ "enable": true,
+ "hide": true,
+ "iconColor": "rgba(0, 211, 255, 1)",
+ "name": "Annotations & Alerts",
+ "builtIn": true,
+ "legacyOptions": {
+ "type": "dashboard"
+ }
+ }
+ }
+ ],
+ "cursorSync": "Off",
+ "editable": true,
+ "elements": {
+ "panel-1": {
+ "kind": "Panel",
+ "spec": {
+ "id": 1,
+ "title": "TPS - $databases",
+ "description": "Current \"Transaction Per Second\" based on total_xact_count",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "TPS",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "pgbouncer_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $__interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as tps\nfrom (\n select \n (data->>'total_xact_count')::int8 as c, lag((data->>'total_xact_count')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "total_xact_count"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "1s"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$databases$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "timeFrom": "15m",
+ "maxDataPoints": 100,
+ "interval": "2m",
+ "hideTimeOverride": true
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "stat",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "colorMode": "value",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "percentChangeColorMode": "standard",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "decimals": 1,
+ "mappings": [
+ {
+ "type": "special",
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ }
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-10": {
+ "kind": "Panel",
+ "spec": {
+ "id": 10,
+ "title": "Incoming traffic rate",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "Incoming rate",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "pgbouncer_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $__interval),\n database,\n avg((c - c_lag) / extract(epoch from time - time_lag)) as \"Incoming rate\"\nfrom (\n select \n (data->>'total_received')::int8 as c, lag((data->>'total_received')::int8) over w as c_lag,\n time, lag(time) over w as time_lag, data->>'database' as database\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1, 2\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "total_received"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "1s"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "2m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "Bps",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 2,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": true,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "DB Size"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "#2F575E",
+ "mode": "palette-classic"
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Incoming byterate"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "#65c5db",
+ "mode": "fixed"
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Incoming rate"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "#6ed0e0",
+ "mode": "palette-classic"
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "WAL rate"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "#0A50A1",
+ "mode": "fixed"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-11": {
+ "kind": "Panel",
+ "spec": {
+ "id": 11,
+ "title": "Avg. query runtime",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "Avg. runtime",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "select\n$__timeGroup(time, $__interval),\ndatabase,\navg((tt-tt_lag)::numeric / (c-c_lag)) as \"Avg. runtime\"\nfrom (\n\n select \n (data->>'total_query_time')::float8 as tt, lag((data->>'total_query_time')::float8) over w as tt_lag,\n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time,\n data->>'database' as database\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1, 2\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "2m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "µs",
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "normal"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Avg. runtime"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "#ef843c",
+ "mode": "palette-classic"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-12": {
+ "kind": "Panel",
+ "spec": {
+ "id": 12,
+ "title": "Outgoing traffic rate",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "Outgoing rate",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "pgbouncer_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $__interval),\n database,\n avg((c - c_lag) / extract(epoch from time - time_lag)) as \"Outgoing rate\"\nfrom (\n select \n (data->>'total_sent')::int8 as c, lag((data->>'total_sent')::int8) over w as c_lag,\n time, lag(time) over w as time_lag, data->>'database' as database\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1, 2\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "total_sent"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "1s"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "2m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "Bps",
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 2,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Outgoing byterate"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "#e24d42",
+ "mode": "palette-classic"
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Outgoing rate"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "#e24d42",
+ "mode": "palette-classic"
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "load_5"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "#BA43A9",
+ "mode": "palette-classic"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-14": {
+ "kind": "Panel",
+ "spec": {
+ "id": 14,
+ "title": "",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "text",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "code": {
+ "language": "plaintext",
+ "showLineNumbers": false,
+ "showMiniMap": false
+ },
+ "content": "### Brought to you by\n\n[](https://www.cybertec-postgresql.com/en/)\n",
+ "mode": "markdown"
+ },
+ "fieldConfig": {
+ "defaults": {},
+ "overrides": []
+ }
+ }
+ },
+ "transparent": true
+ }
+ },
+ "panel-2": {
+ "kind": "Panel",
+ "spec": {
+ "id": 2,
+ "title": "QPS - $databases",
+ "description": "Current \"Queries Per Second\" based on total_query_count",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "QPS",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "pgbouncer_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $__interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as tps\nfrom (\n select \n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "total_query_count"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "1s"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$databases$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "timeFrom": "15m",
+ "maxDataPoints": 100,
+ "interval": "2m",
+ "hideTimeOverride": true
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "stat",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "colorMode": "value",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "percentChangeColorMode": "standard",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "decimals": 1,
+ "mappings": [
+ {
+ "type": "special",
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ }
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-3": {
+ "kind": "Panel",
+ "spec": {
+ "id": 3,
+ "title": "Avg. query runtime - $databases",
+ "description": "Current value based on derivative of total_query_time / total_query_count",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "avg_query_runtime",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "select\n$__timeGroup(time, $__interval),\navg((tt-tt_lag)::numeric / (c-c_lag))\n\nfrom (\n\n select \n (data->>'total_query_time')::float8 as tt, lag((data->>'total_query_time')::float8) over w as tt_lag,\n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "timeFrom": "15m",
+ "maxDataPoints": 100,
+ "interval": "2m",
+ "hideTimeOverride": true
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "stat",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "colorMode": "value",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "percentChangeColorMode": "standard",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "µs",
+ "decimals": 1,
+ "mappings": [
+ {
+ "type": "special",
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ }
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-4": {
+ "kind": "Panel",
+ "spec": {
+ "id": 4,
+ "title": "Pool wait time - $databases",
+ "description": "Current avg. wait time to get a connection, per query",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "db_size_change_last_hour",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "pgbouncer_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "select\n$__timeGroup(time, $__interval),\navg((tt-tt_lag)::numeric / (c-c_lag))\n\nfrom (\n\n select \n (data->>'total_wait_time')::float8 as tt, lag((data->>'total_wait_time')::float8) over w as tt_lag,\n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "total_wait_time"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "last"
+ },
+ {
+ "params": [
+ "1m"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$databases$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "timeFrom": "1h",
+ "maxDataPoints": 100,
+ "interval": "2m",
+ "hideTimeOverride": true
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "stat",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "colorMode": "value",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "percentChangeColorMode": "standard",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "µs",
+ "decimals": 1,
+ "mappings": [
+ {
+ "type": "special",
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ }
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-5": {
+ "kind": "Panel",
+ "spec": {
+ "id": 5,
+ "title": "Incoming traffic - $databases",
+ "description": "Current Incoming traffic based on total_received.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "bytes_received",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "pgbouncer_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $__interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as tps\nfrom (\n select \n (data->>'total_received')::int8 as c, lag((data->>'total_received')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "total_received"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "1s"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$databases$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "timeFrom": "15m",
+ "maxDataPoints": 100,
+ "interval": "2m",
+ "hideTimeOverride": true
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "stat",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "colorMode": "value",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "percentChangeColorMode": "standard",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "Bps",
+ "decimals": 1,
+ "mappings": [
+ {
+ "type": "special",
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ }
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-6": {
+ "kind": "Panel",
+ "spec": {
+ "id": 6,
+ "title": "Outgoing traffic - $databases",
+ "description": "Based on total_sent",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "pgbouncer_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $__interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as tps\nfrom (\n select \n (data->>'total_sent')::int8 as c, lag((data->>'total_sent')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "total_sent"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "1s"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$databases$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "timeFrom": "15m",
+ "maxDataPoints": 100,
+ "interval": "2m",
+ "hideTimeOverride": true
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "stat",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "colorMode": "value",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "percentChangeColorMode": "standard",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "Bps",
+ "decimals": 1,
+ "mappings": [
+ {
+ "type": "special",
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ }
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-7": {
+ "kind": "Panel",
+ "spec": {
+ "id": 7,
+ "title": "TPS",
+ "description": "Based on total_query_count",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "TPS",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "pgbouncer_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $__interval), \n database,\n avg((c - c_lag) / extract(epoch from time - time_lag)) as \"TPS\"\nfrom (\n select \n (data->>'total_xact_count')::int8 as c, lag((data->>'total_xact_count')::int8) over w as c_lag,\n time, lag(time) over w as time_lag, data->>'database' as database\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1, 2\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "total_xact_count"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "1s"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$databases$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "2m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 2,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": true,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "TPS"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "#584477",
+ "mode": "palette-classic"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-8": {
+ "kind": "Panel",
+ "spec": {
+ "id": 8,
+ "title": "Pool wait time per Query",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "Pool wait time",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "db_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "select\n$__timeGroup(time, $__interval),\ndatabase,\navg((tt-tt_lag)::numeric / (c-c_lag)) as \"Pool wait time\"\n\nfrom (\n\n select \n (data->>'total_wait_time')::float8 as tt, lag((data->>'total_wait_time')::float8) over w as tt_lag,\n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time, data->>'database' as database\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1, 2\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "blks_hit"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "2m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "µs",
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 2,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": true,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Pool wait time"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "#890f02",
+ "mode": "palette-classic"
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "TX rollback ratio"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "#890F02",
+ "mode": "palette-classic"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-9": {
+ "kind": "Panel",
+ "spec": {
+ "id": 9,
+ "title": "QPS",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "QPS",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "pgbouncer_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $__interval),\n database,\n avg((c - c_lag) / extract(epoch from time - time_lag)) as \"QPS\"\nfrom (\n select \n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time, lag(time) over w as time_lag, data->>'database' as database\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1, 2\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "total_query_count"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "1s"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "2m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 2,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": true,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "#Backends"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "#F9E2D2",
+ "mode": "palette-classic"
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Deadlocks (1h rate)"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "#BF1B00",
+ "mode": "palette-classic"
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "QPS"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "#508642",
+ "mode": "palette-classic"
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Temp bytes written"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "Bps"
+ },
+ {
+ "id": "custom.axisPlacement",
+ "value": "hidden"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ }
+ },
+ "layout": {
+ "kind": "GridLayout",
+ "spec": {
+ "items": [
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 0,
+ "width": 4,
+ "height": 3,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-1"
+ },
+ "repeat": {
+ "mode": "variable",
+ "value": "databases",
+ "direction": "v"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 4,
+ "y": 0,
+ "width": 4,
+ "height": 3,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-2"
+ },
+ "repeat": {
+ "mode": "variable",
+ "value": "databases",
+ "direction": "v"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 8,
+ "y": 0,
+ "width": 4,
+ "height": 3,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-3"
+ },
+ "repeat": {
+ "mode": "variable",
+ "value": "databases",
+ "direction": "v"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 12,
+ "y": 0,
+ "width": 4,
+ "height": 3,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-4"
+ },
+ "repeat": {
+ "mode": "variable",
+ "value": "databases",
+ "direction": "v"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 16,
+ "y": 0,
+ "width": 4,
+ "height": 3,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-5"
+ },
+ "repeat": {
+ "mode": "variable",
+ "value": "databases",
+ "direction": "v"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 20,
+ "y": 0,
+ "width": 4,
+ "height": 3,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-6"
+ },
+ "repeat": {
+ "mode": "variable",
+ "value": "databases",
+ "direction": "v"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 9,
+ "width": 12,
+ "height": 6,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-7"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 12,
+ "y": 9,
+ "width": 12,
+ "height": 6,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-8"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 15,
+ "width": 12,
+ "height": 6,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-9"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 12,
+ "y": 15,
+ "width": 12,
+ "height": 6,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-10"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 21,
+ "width": 12,
+ "height": 6,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-11"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 12,
+ "y": 21,
+ "width": 12,
+ "height": 6,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-12"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 27,
+ "width": 12,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-14"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "links": [],
+ "liveNow": false,
+ "preload": false,
+ "tags": [
+ "pgwatch"
+ ],
+ "timeSettings": {
+ "timezone": "browser",
+ "from": "now-6h",
+ "to": "now",
+ "autoRefresh": "",
+ "autoRefreshIntervals": [
+ "5s",
+ "10s",
+ "30s",
+ "1m",
+ "5m",
+ "15m",
+ "30m",
+ "1h",
+ "2h",
+ "1d"
+ ],
+ "hideTimepicker": false,
+ "fiscalYearStartMonth": 0
+ },
+ "title": "PgBouncer stats",
+ "variables": [
+ {
+ "kind": "QueryVariable",
+ "spec": {
+ "name": "monitoredsource",
+ "current": {
+ "text": "",
+ "value": ""
+ },
+ "label": "Monitored Source",
+ "hide": "dontHide",
+ "refresh": "onDashboardLoad",
+ "skipUrlSync": false,
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "__legacyStringValue": "select dbname as monitoredsource from admin.all_distinct_dbname_metrics where metric = 'pgbouncer_stats';"
+ }
+ },
+ "regex": "",
+ "sort": "alphabeticalAsc",
+ "definition": "select dbname as monitoredsource from admin.all_distinct_dbname_metrics where metric = 'pgbouncer_stats';",
+ "options": [],
+ "multi": false,
+ "includeAll": false,
+ "allowCustomValue": false
+ }
+ },
+ {
+ "kind": "QueryVariable",
+ "spec": {
+ "name": "databases",
+ "current": {
+ "text": "",
+ "value": ""
+ },
+ "label": "Databases",
+ "hide": "dontHide",
+ "refresh": "onTimeRangeChanged",
+ "skipUrlSync": false,
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "__legacyStringValue": "select distinct (data->>'database') as database from pgbouncer_stats where dbname = '$monitoredsource' and $__timeFilter(time);"
+ }
+ },
+ "regex": "",
+ "sort": "alphabeticalAsc",
+ "definition": "select distinct (data->>'database') as database from pgbouncer_stats where dbname = '$monitoredsource' and $__timeFilter(time) ;",
+ "options": [],
+ "multi": true,
+ "includeAll": true,
+ "allowCustomValue": false
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/grafana/postgres/v13/pgpool-stats.json b/grafana/postgres/v13/pgpool-stats.json
new file mode 100644
index 0000000000..d9cc2d455c
--- /dev/null
+++ b/grafana/postgres/v13/pgpool-stats.json
@@ -0,0 +1,561 @@
+{
+ "apiVersion": "dashboard.grafana.app/v2",
+ "kind": "Dashboard",
+ "metadata": {
+ "name": "pgpool-stats"
+ },
+ "spec": {
+ "annotations": [
+ {
+ "kind": "AnnotationQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "grafana"
+ },
+ "spec": {}
+ },
+ "enable": true,
+ "hide": true,
+ "iconColor": "rgba(0, 211, 255, 1)",
+ "name": "Annotations & Alerts",
+ "builtIn": true,
+ "legacyOptions": {
+ "type": "dashboard"
+ }
+ }
+ }
+ ],
+ "cursorSync": "Off",
+ "editable": true,
+ "elements": {
+ "panel-2": {
+ "kind": "Panel",
+ "spec": {
+ "id": 2,
+ "title": "Pool node status",
+ "description": "Based on \"SHOW POOL_NODES\" and \"SHOW POOL_PROCESSES\".",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n dbname,\n tag_data->>'node_id' as node_id,\n data->>'role' as role,\n data->>'status' as status,\n case when data->>'status' = 'up' then 1 else 0 end as status_num,\n data->>'hostname' as hostname,\n data->>'port' as port,\n data->>'lb_weight' as lb_weight,\n data->>'load_balance_node' as load_balance_node,\n data->>'replication_delay' as replication_delay,\n data->>'select_cnt' as select_cnt, \n data->>'last_status_change' as last_status_change, \n time::text as \"updated\"\nfrom\n pgpool_stats\nwhere\n time = (select max(time) from pgpool_stats where dbname in ($dbname) and $__timeFilter(time) group by dbname)\n and dbname in ($dbname)\norder by\n dbname,\n node_id,\n time desc\n",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "footer": {
+ "countRows": false,
+ "fields": "",
+ "reducer": [
+ "sum"
+ ],
+ "show": false
+ },
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "status_num"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "custom.cellOptions",
+ "value": {
+ "type": "color-background"
+ }
+ },
+ {
+ "id": "custom.align"
+ },
+ {
+ "id": "thresholds",
+ "value": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "rgba(245, 54, 54, 0.9)",
+ "value": 0
+ },
+ {
+ "color": "rgba(237, 129, 40, 0.89)",
+ "value": 1
+ },
+ {
+ "color": "rgba(50, 172, 45, 0.97)",
+ "value": 1
+ }
+ ]
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "replication_delay"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "bytes"
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-4": {
+ "kind": "Panel",
+ "spec": {
+ "id": 4,
+ "title": "",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "text",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "code": {
+ "language": "plaintext",
+ "showLineNumbers": false,
+ "showMiniMap": false
+ },
+ "content": "### Brought to you by\n\n[](https://www.cybertec-postgresql.com/en/)\n",
+ "mode": "markdown"
+ },
+ "fieldConfig": {
+ "defaults": {},
+ "overrides": []
+ }
+ }
+ },
+ "transparent": true
+ }
+ },
+ "panel-6": {
+ "kind": "Panel",
+ "spec": {
+ "id": 6,
+ "title": "SELECT load balancing per node ($agg_interval avg.)",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n (max((data->>'select_cnt')::int8) - min((data->>'select_cnt')::int8))::int8 as select_cnt,\n dbname || ' (node: ' || (tag_data->>'node_id')::text || ')' as node_id\nFROM\n pgpool_stats\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY\n 1, 3\nORDER BY\n 1\n",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ }
+ },
+ "layout": {
+ "kind": "GridLayout",
+ "spec": {
+ "items": [
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 0,
+ "width": 24,
+ "height": 8,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-2"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 8,
+ "width": 24,
+ "height": 11,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-6"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 19,
+ "width": 10,
+ "height": 4,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-4"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "links": [],
+ "liveNow": false,
+ "preload": false,
+ "tags": [
+ "pgwatch"
+ ],
+ "timeSettings": {
+ "from": "now-6h",
+ "to": "now",
+ "autoRefresh": "",
+ "autoRefreshIntervals": [
+ "5s",
+ "10s",
+ "30s",
+ "1m",
+ "5m",
+ "15m",
+ "30m",
+ "1h",
+ "2h",
+ "1d"
+ ],
+ "hideTimepicker": false,
+ "fiscalYearStartMonth": 0
+ },
+ "title": "Pgpool Stats",
+ "variables": [
+ {
+ "kind": "QueryVariable",
+ "spec": {
+ "name": "dbname",
+ "current": {
+ "text": "All",
+ "value": "$__all"
+ },
+ "hide": "dontHide",
+ "refresh": "onDashboardLoad",
+ "skipUrlSync": false,
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "__legacyStringValue": "select distinct dbname from admin.all_distinct_dbname_metrics where metric = 'pgpool_stats';"
+ }
+ },
+ "regex": "",
+ "sort": "disabled",
+ "definition": "select distinct dbname from admin.all_distinct_dbname_metrics where metric = 'pgpool_stats';",
+ "options": [],
+ "multi": true,
+ "includeAll": true,
+ "allowCustomValue": true
+ }
+ },
+ {
+ "kind": "IntervalVariable",
+ "spec": {
+ "name": "agg_interval",
+ "query": "1m,2m,3m,5m,10m,15m,30m,1h,6h,12h,1d",
+ "current": {
+ "text": "10m",
+ "value": "10m"
+ },
+ "options": [
+ {
+ "selected": false,
+ "text": "1m",
+ "value": "1m"
+ },
+ {
+ "selected": false,
+ "text": "2m",
+ "value": "2m"
+ },
+ {
+ "selected": false,
+ "text": "3m",
+ "value": "3m"
+ },
+ {
+ "selected": false,
+ "text": "5m",
+ "value": "5m"
+ },
+ {
+ "selected": true,
+ "text": "10m",
+ "value": "10m"
+ },
+ {
+ "selected": false,
+ "text": "15m",
+ "value": "15m"
+ },
+ {
+ "selected": false,
+ "text": "30m",
+ "value": "30m"
+ },
+ {
+ "selected": false,
+ "text": "1h",
+ "value": "1h"
+ },
+ {
+ "selected": false,
+ "text": "6h",
+ "value": "6h"
+ },
+ {
+ "selected": false,
+ "text": "12h",
+ "value": "12h"
+ },
+ {
+ "selected": false,
+ "text": "1d",
+ "value": "1d"
+ }
+ ],
+ "auto": false,
+ "auto_min": "10s",
+ "auto_count": 30,
+ "refresh": "onTimeRangeChanged",
+ "hide": "dontHide",
+ "skipUrlSync": false
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/grafana/postgres/v13/postgres-version-overview.json b/grafana/postgres/v13/postgres-version-overview.json
new file mode 100644
index 0000000000..c4fac3e40d
--- /dev/null
+++ b/grafana/postgres/v13/postgres-version-overview.json
@@ -0,0 +1,381 @@
+{
+ "apiVersion": "dashboard.grafana.app/v2",
+ "kind": "Dashboard",
+ "metadata": {
+ "name": "postgres-version-overview"
+ },
+ "spec": {
+ "annotations": [
+ {
+ "kind": "AnnotationQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "grafana"
+ },
+ "spec": {}
+ },
+ "enable": true,
+ "hide": true,
+ "iconColor": "rgba(0, 211, 255, 1)",
+ "name": "Annotations & Alerts",
+ "builtIn": true,
+ "legacyOptions": {
+ "type": "dashboard"
+ }
+ }
+ }
+ ],
+ "cursorSync": "Off",
+ "editable": true,
+ "elements": {
+ "panel-2": {
+ "kind": "Panel",
+ "spec": {
+ "id": 2,
+ "title": "Monitored DBs by version",
+ "description": "As per \"settings\" metric.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "sproc_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "SELECT top(\"spread\", \"function_full_name\", \"oid\", $top) FROM (SELECT spread(\"total_time\") FROM \"sproc_stats\" WHERE $timeFilter AND \"dbname\" = '$dbname' GROUP BY time(3650d), \"function_full_name\", \"oid\" fill(none) ) WHERE spread > 0",
+ "rawQuery": true,
+ "rawSql": "SELECT\n split_part(data->>'server_version'::text, ' ', 1) as server_version,\n (data->>'server_version_num')::int8 as server_version_num,\n string_agg(DISTINCT dbname, ', ') as dbname \nFROM\n settings\nWHERE\n $__timeFilter(time)\n AND dbname IN ($dbname)\n AND (data->>'server_version_num')::int8 <= $lower_than_server_version_num\nGROUP BY 1, 2\nORDER BY 1",
+ "resultFormat": "table",
+ "select": [
+ [
+ {
+ "params": [
+ "total_time"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "footer": {
+ "countRows": false,
+ "fields": "",
+ "reducer": [
+ "sum"
+ ],
+ "show": false
+ },
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "server_version_num"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "none"
+ },
+ {
+ "id": "custom.cellOptions",
+ "value": {
+ "type": "color-background"
+ }
+ },
+ {
+ "id": "custom.align",
+ "value": "left"
+ },
+ {
+ "id": "thresholds",
+ "value": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "rgba(245, 54, 54, 0.9)"
+ },
+ {
+ "color": "rgba(237, 129, 40, 0.89)",
+ "value": 90400
+ },
+ {
+ "color": "rgba(50, 172, 45, 0.97)",
+ "value": 90600
+ }
+ ]
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-8": {
+ "kind": "Panel",
+ "spec": {
+ "id": 8,
+ "title": "",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "text",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "code": {
+ "language": "plaintext",
+ "showLineNumbers": false,
+ "showMiniMap": false
+ },
+ "content": "### Brought to you by\n\n[](https://www.cybertec-postgresql.com/en/)\n",
+ "mode": "markdown"
+ },
+ "fieldConfig": {
+ "defaults": {},
+ "overrides": []
+ }
+ }
+ },
+ "transparent": true
+ }
+ }
+ },
+ "layout": {
+ "kind": "GridLayout",
+ "spec": {
+ "items": [
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 0,
+ "width": 24,
+ "height": 14,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-2"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 14,
+ "width": 12,
+ "height": 8,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-8"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "links": [],
+ "liveNow": false,
+ "preload": false,
+ "tags": [
+ "pgwatch"
+ ],
+ "timeSettings": {
+ "from": "now-6h",
+ "to": "now",
+ "autoRefresh": "",
+ "autoRefreshIntervals": [
+ "5s",
+ "10s",
+ "30s",
+ "1m",
+ "5m",
+ "15m",
+ "30m",
+ "1h",
+ "2h",
+ "1d"
+ ],
+ "hideTimepicker": false,
+ "fiscalYearStartMonth": 0
+ },
+ "title": "Postgres Version Overview",
+ "variables": [
+ {
+ "kind": "QueryVariable",
+ "spec": {
+ "name": "dbname",
+ "current": {
+ "text": "All",
+ "value": [
+ "$__all"
+ ]
+ },
+ "hide": "dontHide",
+ "refresh": "onDashboardLoad",
+ "skipUrlSync": false,
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "__legacyStringValue": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'settings' ORDER BY 1;"
+ }
+ },
+ "regex": "",
+ "sort": "disabled",
+ "definition": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'settings' ORDER BY 1;",
+ "options": [],
+ "multi": true,
+ "includeAll": true,
+ "allowCustomValue": true
+ }
+ },
+ {
+ "kind": "QueryVariable",
+ "spec": {
+ "name": "lower_than_server_version_num",
+ "current": {
+ "text": "",
+ "value": ""
+ },
+ "hide": "dontHide",
+ "refresh": "onDashboardLoad",
+ "skipUrlSync": false,
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "__legacyStringValue": "SELECT DISTINCT (data->>'server_version_num')::int FROM settings WHERE time > now() - '24h'::interval ORDER BY 1 DESC"
+ }
+ },
+ "regex": "",
+ "sort": "disabled",
+ "definition": "SELECT DISTINCT (data->>'server_version_num')::int FROM settings WHERE time > now() - '24h'::interval ORDER BY 1 DESC",
+ "options": [],
+ "multi": false,
+ "includeAll": false,
+ "allowCustomValue": true
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/grafana/postgres/v13/recommendations.json b/grafana/postgres/v13/recommendations.json
new file mode 100644
index 0000000000..746e7a1c6f
--- /dev/null
+++ b/grafana/postgres/v13/recommendations.json
@@ -0,0 +1,921 @@
+{
+ "apiVersion": "dashboard.grafana.app/v2",
+ "kind": "Dashboard",
+ "metadata": {
+ "name": "recommendations"
+ },
+ "spec": {
+ "annotations": [
+ {
+ "kind": "AnnotationQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "grafana"
+ },
+ "spec": {}
+ },
+ "enable": true,
+ "hide": true,
+ "iconColor": "rgba(0, 211, 255, 1)",
+ "name": "Annotations & Alerts",
+ "builtIn": true,
+ "legacyOptions": {
+ "type": "dashboard"
+ }
+ }
+ }
+ ],
+ "cursorSync": "Off",
+ "description": "Needs \"recommendations\" metric to be enabled",
+ "editable": true,
+ "elements": {
+ "panel-1": {
+ "kind": "Panel",
+ "spec": {
+ "id": 1,
+ "title": "Database Recommendations",
+ "description": "All database recommendations from automated analysis",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "editorMode": "code",
+ "format": "table",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT\n dbname AS \"Source\",\n tag_data->>'reco_topic' AS \"Category\",\n tag_data->>'object_name' AS \"Objects\",\n data->>'recommendation' AS \"Recommendation\",\n data->>'extra_info' AS \"Additional Info\"\nFROM\n $table_name\nWHERE\n time IN (SELECT max(time) FROM $table_name WHERE $__timeFilter(time) GROUP BY dbname, tag_data->>'reco_topic')\n AND dbname IN ($dbname)\n AND tag_data->>'reco_topic' IS NOT NULL\nORDER BY\n dbname, tag_data->>'reco_topic'",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "cellHeight": "md",
+ "footer": {
+ "countRows": true,
+ "enablePagination": false,
+ "fields": "",
+ "reducer": [
+ "count"
+ ],
+ "show": false
+ },
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto",
+ "wrapText": false
+ },
+ "inspect": true
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Database"
+ },
+ "properties": [
+ {
+ "id": "custom.width",
+ "value": 120
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Category"
+ },
+ "properties": [
+ {
+ "id": "custom.width",
+ "value": 150
+ },
+ {
+ "id": "mappings",
+ "value": [
+ {
+ "options": {
+ "add_index": {
+ "text": "Missing Indexes"
+ },
+ "create_index": {
+ "text": "Missing Indexes"
+ },
+ "default_public_schema_privs": {
+ "text": "Security: Public Schema"
+ },
+ "disabled_triggers": {
+ "text": "Disabled Triggers"
+ },
+ "drop_index": {
+ "text": "Unused Indexes"
+ },
+ "overly_nested_views": {
+ "text": "Complex Views"
+ },
+ "partial_index_candidates": {
+ "text": "Partial Index Opportunities"
+ },
+ "sprocs_wo_search_path": {
+ "text": "Security: Search Path"
+ },
+ "superuser_count": {
+ "text": "Security: Superusers"
+ },
+ "superusers": {
+ "text": "Security: Superusers"
+ }
+ },
+ "type": "value"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Objects"
+ },
+ "properties": [
+ {
+ "id": "custom.width",
+ "value": 200
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Recommendation"
+ },
+ "properties": [
+ {
+ "id": "custom.width",
+ "value": 300
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-10": {
+ "kind": "Panel",
+ "spec": {
+ "id": 10,
+ "title": "Possible AUTOVACUUM problems",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "editorMode": "code",
+ "format": "table",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT\n dbname AS \"Source\",\n (select data->>'server_version' from settings s where s.dbname = x.dbname order by time desc limit 1) AS \"PostgreSQL Version\",\n 'AUTOVACUUM Workers' AS \"Category\",\n 'If most / all autovacuum worker slots are busy or AV runs for hours then this could hint at incorrect AV params or too much workload' AS \"Recommendation\",\n 'Max. active autovacuum workers: ' || max_av_workers || ' (of total ' || (select (data->>'autovacuum_max_workers')::int from settings s where s.dbname = x.dbname order by time desc limit 1) || '); Max. AV duration (seconds): ' || longest_autovacuum_seconds AS \"Additional Info\"\nFROM (\nSELECT\n dbname,\n max((data->>'av_workers')::int) as max_av_workers,\n coalesce(max((data->>'longest_autovacuum_seconds')::int), 0) as longest_autovacuum_seconds\nFROM\n backends\nWHERE\n $__timeFilter(time)\n AND dbname IN ($dbname)\nGROUP BY\n dbname\n) x\nWHERE\n (max_av_workers > 1 AND max_av_workers::numeric / (select (data->>'autovacuum_max_workers')::int from settings s where s.dbname = x.dbname order by time desc limit 1) >= 0.6)\n OR\n (longest_autovacuum_seconds > 1800)",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "footer": {
+ "countRows": false,
+ "fields": "",
+ "reducer": [
+ "sum"
+ ],
+ "show": false
+ },
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Time"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Time"
+ },
+ {
+ "id": "unit",
+ "value": "time: YYYY-MM-DD HH:mm:ss"
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-11": {
+ "kind": "Panel",
+ "spec": {
+ "id": 11,
+ "title": "Checkpoints requested too often",
+ "description": "More often than checkpoint_timeout / 2. To improve increase checkpoint_timeout or max_wal_size, which will reduce total IO amount done due to the way how Full Page Writes are handled.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "editorMode": "code",
+ "format": "table",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT\n dbname AS \"Source\",\n (select data->>'server_version' from settings s where s.dbname = y.dbname order by s.time desc limit 1) AS \"PostgreSQL Version\",\n 'Global Server Settings' AS \"Category\",\n 'Increase checkpoint_timeout or max_wal_size for more infrequent checkpoints, thereby reducing total IO' AS \"Recommendation\",\n 'Avg. seconds between checkpoint requests: ' || avg_seconds_between_checkpoints_reqs::int8 AS \"Additional Info\"\nFROM (\nSELECT\n dbname,\n round((extract(epoch from max_time - min_time) / (max_req - min_req))::numeric, 1) as avg_seconds_between_checkpoints_reqs\nFROM (\n SELECT\n dbname,\n min(time) as min_time,\n max(time) as max_time,\n min((data->>'checkpoints_req')::int8) as min_req,\n max((data->>'checkpoints_req')::int8) as max_req\n FROM\n bgwriter\n WHERE\n $__timeFilter(time)\n AND dbname IN ($dbname)\nGROUP BY\n dbname\nHAVING\n max((data->>'checkpoints_req')::int8) > min((data->>'checkpoints_req')::int8)\n) x\n) y\nWHERE\n avg_seconds_between_checkpoints_reqs < (select extract(epoch from (data->>'checkpoint_timeout')::interval) / 2.0 from settings s where s.dbname = y.dbname order by s.time desc limit 1)\nORDER BY\n avg_seconds_between_checkpoints_reqs\nLIMIT\n 25",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "footer": {
+ "countRows": false,
+ "fields": "",
+ "reducer": [
+ "sum"
+ ],
+ "show": false
+ },
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Time"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Time"
+ },
+ {
+ "id": "unit",
+ "value": "time: YYYY-MM-DD HH:mm:ss"
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-4": {
+ "kind": "Panel",
+ "spec": {
+ "id": 4,
+ "title": "Longest query runtime",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "editorMode": "code",
+ "format": "table",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT\n dbname AS \"Source\",\n 'Performance Issue' AS \"Category\",\n 'Long Running Queries' AS \"Objects\",\n 'Long running queries block autovacuum and thereby cause bloat' AS \"Recommendation\",\n 'Longest query duration: '|| max((data->>'longest_query_seconds')::int)::text || ' seconds' AS \"Additional Info\"\nFROM\n backends\nWHERE\n $__timeFilter(time)\n AND dbname IN ($dbname)\n AND (data->>'longest_query_seconds')::int > 0\nGROUP BY\n dbname\nORDER BY\n max((data->>'longest_query_seconds')::int) DESC NULLS LAST, dbname",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "footer": {
+ "countRows": false,
+ "fields": "",
+ "reducer": [
+ "sum"
+ ],
+ "show": false
+ },
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Time"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Time"
+ },
+ {
+ "id": "unit",
+ "value": "time: YYYY-MM-DD HH:mm:ss"
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-9": {
+ "kind": "Panel",
+ "spec": {
+ "id": 9,
+ "title": "",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "text",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "code": {
+ "language": "plaintext",
+ "showLineNumbers": false,
+ "showMiniMap": false
+ },
+ "content": "### Brought to you by\n\n[](https://www.cybertec-postgresql.com/en/)\n",
+ "mode": "markdown"
+ },
+ "fieldConfig": {
+ "defaults": {},
+ "overrides": []
+ }
+ }
+ },
+ "transparent": true
+ }
+ }
+ },
+ "layout": {
+ "kind": "GridLayout",
+ "spec": {
+ "items": [
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 0,
+ "width": 24,
+ "height": 20,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-1"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 20,
+ "width": 24,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-10"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 25,
+ "width": 24,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-4"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 30,
+ "width": 24,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-11"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 35,
+ "width": 9,
+ "height": 4,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-9"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "links": [],
+ "liveNow": false,
+ "preload": false,
+ "tags": [
+ "pgwatch"
+ ],
+ "timeSettings": {
+ "from": "now-24h",
+ "to": "now",
+ "autoRefresh": "",
+ "autoRefreshIntervals": [
+ "5s",
+ "10s",
+ "30s",
+ "1m",
+ "5m",
+ "15m",
+ "30m",
+ "1h",
+ "2h",
+ "1d"
+ ],
+ "hideTimepicker": false,
+ "fiscalYearStartMonth": 0
+ },
+ "title": "Recommendations",
+ "variables": [
+ {
+ "kind": "QueryVariable",
+ "spec": {
+ "name": "dbname",
+ "current": {
+ "text": "All",
+ "value": [
+ "$__all"
+ ]
+ },
+ "label": "Monitored Source",
+ "hide": "dontHide",
+ "refresh": "onDashboardLoad",
+ "skipUrlSync": false,
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "__legacyStringValue": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics ORDER BY 1;"
+ }
+ },
+ "regex": "",
+ "sort": "disabled",
+ "definition": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics ORDER BY 1;",
+ "options": [],
+ "multi": true,
+ "includeAll": true,
+ "allowCustomValue": true
+ }
+ },
+ {
+ "kind": "QueryVariable",
+ "spec": {
+ "name": "table_name",
+ "current": {
+ "text": "(SELECT NULL time, NULL dbname, NULL::json data, NULL::jsonb tag_data WHERE false)",
+ "value": "(SELECT NULL time, NULL dbname, NULL::json data, NULL::jsonb tag_data WHERE false)"
+ },
+ "hide": "hideVariable",
+ "refresh": "onDashboardLoad",
+ "skipUrlSync": false,
+ "query": {
+ "kind": "DataQuery",
+ "group": "postgres",
+ "version": "v0",
+ "spec": {
+ "__legacyStringValue": "SELECT COALESCE (to_regclass('recommendations')::text, '(SELECT NULL time, NULL dbname, NULL::json data, NULL::jsonb tag_data WHERE false)')"
+ }
+ },
+ "regex": "",
+ "sort": "disabled",
+ "definition": "SELECT COALESCE (to_regclass('recommendations')::text, '(SELECT NULL time, NULL dbname, NULL::json data, NULL::jsonb tag_data WHERE false)')",
+ "options": [],
+ "multi": false,
+ "includeAll": false,
+ "allowCustomValue": true
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/grafana/postgres/v13/replication.json b/grafana/postgres/v13/replication.json
new file mode 100644
index 0000000000..e137421668
--- /dev/null
+++ b/grafana/postgres/v13/replication.json
@@ -0,0 +1,2265 @@
+{
+ "apiVersion": "dashboard.grafana.app/v2",
+ "kind": "Dashboard",
+ "metadata": {
+ "name": "replication"
+ },
+ "spec": {
+ "annotations": [
+ {
+ "kind": "AnnotationQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "grafana"
+ },
+ "spec": {}
+ },
+ "enable": true,
+ "hide": true,
+ "iconColor": "rgba(0, 211, 255, 1)",
+ "name": "Annotations & Alerts",
+ "builtIn": true,
+ "legacyOptions": {
+ "type": "dashboard"
+ }
+ }
+ }
+ ],
+ "cursorSync": "Off",
+ "editable": true,
+ "elements": {
+ "panel-10": {
+ "kind": "Panel",
+ "spec": {
+ "id": 10,
+ "title": "Repl. slot XMIN age (in transactions)",
+ "description": "Based on \"pg_replication_slots.xmin\". The oldest transaction that this slot needs the database to retain. VACUUM cannot remove tuples deleted by any later transaction.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "[[tag_dbname]] [[tag_slot_name]]",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "dbname"
+ ],
+ "type": "tag"
+ },
+ {
+ "params": [
+ "plugin"
+ ],
+ "type": "tag"
+ },
+ {
+ "params": [
+ "slot_name"
+ ],
+ "type": "tag"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "replication_slots",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "",
+ "rawQuery": true,
+ "rawSql": "SELECT\n $__timeGroup(time, $__interval),\n dbname,\n avg((data->>'xmin_age_tx')::int8)\nFROM\n replication_slots\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY 1, 2\nORDER BY 1, 2",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "xmin_age_tx"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$dbname$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "B",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "5m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-12": {
+ "kind": "Panel",
+ "spec": {
+ "id": 12,
+ "title": "",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "text",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "code": {
+ "language": "plaintext",
+ "showLineNumbers": false,
+ "showMiniMap": false
+ },
+ "content": "### Brought to you by\n\n[](https://www.cybertec-postgresql.com/en/)\n",
+ "mode": "markdown"
+ },
+ "fieldConfig": {
+ "defaults": {},
+ "overrides": []
+ }
+ }
+ },
+ "transparent": true
+ }
+ },
+ "panel-13": {
+ "kind": "Panel",
+ "spec": {
+ "id": 13,
+ "title": "Active repl. slots",
+ "description": "Based on last 5m data. FYI - no thresholds defined",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "1m"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "replication_slots",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "select count(\"active\") from (select last(\"active\") as \"active\" FROM \"replication_slots\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter group by \"dbname\", \"slot_name\") WHERE \"active\" = true",
+ "rawQuery": true,
+ "rawSql": "SELECT\n 0 as time,\n count(*) filter (where data->>'non_active_int' = '0')\nFROM\n replication_slots\nWHERE\n time in (select max(time) from replication_slots where $__timeFilter(time) AND dbname in ($dbname) group by dbname)\n AND dbname in ($dbname)\n",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "active"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "last"
+ }
+ ]
+ ],
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "timeFrom": "5m",
+ "maxDataPoints": 100,
+ "hideTimeOverride": true
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "stat",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "colorMode": "none",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "percentChangeColorMode": "standard",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "none",
+ "decimals": 0,
+ "mappings": [
+ {
+ "type": "special",
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ }
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "#299c46"
+ },
+ {
+ "value": 1,
+ "color": "#bf1b00"
+ },
+ {
+ "value": 1000,
+ "color": "#d44a3a"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-14": {
+ "kind": "Panel",
+ "spec": {
+ "id": 14,
+ "title": "Active replicas",
+ "description": "Data is available only on connected replicas. No thresholds by default",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "1d"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "replication",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "select count(\"last\") from (SELECT last(\"state\") FROM \"replication\" WHERE (\"dbname\" =~ /^$dbname$/) AND $timeFilter GROUP BY time(1d), dbname, client_info fill(none)) where \"last\" = 'streaming'",
+ "rawQuery": true,
+ "rawSql": "SELECT\n 0 as time,\n count(*)\nFROM\n replication\nWHERE\n time in (select max(time) from replication where $__timeFilter(time) AND dbname in ($dbname) group by dbname)\n AND dbname in ($dbname)\n",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "replay_lag_b"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "count"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$dbname$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "timeFrom": "5m",
+ "maxDataPoints": 100,
+ "hideTimeOverride": true
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "stat",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "colorMode": "none",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "percentChangeColorMode": "standard",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "decimals": 0,
+ "mappings": [
+ {
+ "type": "special",
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ }
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "#299c46"
+ },
+ {
+ "value": 100000000,
+ "color": "rgba(237, 129, 40, 0.89)"
+ },
+ {
+ "value": 1000000000,
+ "color": "#d44a3a"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-15": {
+ "kind": "Panel",
+ "spec": {
+ "id": 15,
+ "title": "Active \"sync\" replicas",
+ "description": "Data is available only on connected replicas. No thresholds by default",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "1d"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "replication",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "select sum(\"last\") from (SELECT last(\"is_sync_int\") FROM \"replication\" WHERE (\"dbname\" =~ /^$dbname$/) AND $timeFilter GROUP BY time(1d), dbname, client_info fill(none))",
+ "rawQuery": true,
+ "rawSql": "SELECT\n 0 as time,\n count(*) filter (where data->>'is_sync_int' = '1') \nFROM\n replication\nWHERE\n time in (select max(time) from replication where $__timeFilter(time) AND dbname in ($dbname) group by dbname)\n AND dbname in ($dbname)\n",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "replay_lag_b"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "count"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$dbname$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "timeFrom": "5m",
+ "maxDataPoints": 100,
+ "hideTimeOverride": true
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "stat",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "colorMode": "none",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "percentChangeColorMode": "standard",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "decimals": 0,
+ "mappings": [
+ {
+ "type": "special",
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ }
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-16": {
+ "kind": "Panel",
+ "spec": {
+ "id": 16,
+ "title": "Max. flush lag",
+ "description": "Data is available only on connected replicas! Based on last 5m data.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "1d"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "replication",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "SELECT max(\"write_lag_b\") FROM \"replication\" WHERE $timeFilter GROUP BY time($__interval) fill(none)",
+ "rawQuery": true,
+ "rawSql": "SELECT\n 0 as time,\n max((data->>'flush_lag_b')::int8)\nFROM\n replication\nWHERE\n time in (select max(time) from replication where $__timeFilter(time) AND dbname in ($dbname) group by dbname)\n AND dbname in ($dbname)\n\n",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "flush_lag_b"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "max"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$dbname$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "timeFrom": "5m",
+ "maxDataPoints": 100,
+ "hideTimeOverride": true
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "stat",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "colorMode": "value",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "percentChangeColorMode": "standard",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "bytes",
+ "decimals": 1,
+ "mappings": [
+ {
+ "type": "special",
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ }
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "#299c46"
+ },
+ {
+ "value": 100000000,
+ "color": "rgba(237, 129, 40, 0.89)"
+ },
+ {
+ "value": 1000000000,
+ "color": "#d44a3a"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-17": {
+ "kind": "Panel",
+ "spec": {
+ "id": 17,
+ "title": "Replication flush lag",
+ "description": "Based on pg_stat_replication on primaries. Data is available only on connected replicas!",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "[[tag_dbname]] [[tag_application_name]] [[tag_client_info]]",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "dbname"
+ ],
+ "type": "tag"
+ },
+ {
+ "params": [
+ "client_info"
+ ],
+ "type": "tag"
+ },
+ {
+ "params": [
+ "application_name"
+ ],
+ "type": "tag"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "replication",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "SELECT mean(\"write_lag_b\") FROM \"replication\" WHERE (\"dbname\" =~ /^$dbname$/) AND $timeFilter GROUP BY time($__interval), \"dbname\", \"client_info\", \"application_name\" fill(none)",
+ "rawQuery": true,
+ "rawSql": "SELECT\n $__timeGroup(time, $__interval),\n dbname,\n avg((data->>'flush_lag_b')::int8)\nFROM\n replication\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY\n 1, 2\nORDER BY\n 1, 2\n \n",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "flush_lag_b"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$dbname$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "B",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "2m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "bytes",
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-2": {
+ "kind": "Panel",
+ "spec": {
+ "id": 2,
+ "title": "Replication slot restart_lsn lag (primary extra WAL size)",
+ "description": "Based on pg_replication_slots. Primary only",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "[[tag_dbname]] slot=[[tag_slot_name]]",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "dbname"
+ ],
+ "type": "tag"
+ },
+ {
+ "params": [
+ "slot_name"
+ ],
+ "type": "tag"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "replication_slots",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "",
+ "rawQuery": true,
+ "rawSql": "SELECT\n $__timeGroup(time, $__interval),\n dbname,\n max((data->>'restart_lsn_lag_b')::int8)\nFROM\n replication_slots\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY 1, 2\nORDER BY 1, 2\n\n",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "restart_lsn_lag_b"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$dbname$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "5m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "bytes",
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-4": {
+ "kind": "Panel",
+ "spec": {
+ "id": 4,
+ "title": "Inactive repl. slots",
+ "description": "Based on last 5m data. > 1 ~ Error. Causes WAL accumulation on the master and possibly autovacuum inefficiencies",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "1m"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "replication_slots",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "select sum(\"last\") from (select last(\"non_active_int\") FROM \"replication_slots\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter group by \"dbname\", \"slot_name\")",
+ "rawQuery": true,
+ "rawSql": "SELECT\n 0 as time,\n sum((data->>'non_active_int')::int)\nFROM\n replication_slots\nWHERE\n time in (select max(time) from replication_slots where $__timeFilter(time) AND dbname in ($dbname) group by dbname)\n AND dbname in ($dbname)\n",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "active"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "last"
+ }
+ ]
+ ],
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "timeFrom": "5m",
+ "maxDataPoints": 100,
+ "hideTimeOverride": true
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "stat",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "colorMode": "background",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "percentChangeColorMode": "standard",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "none",
+ "decimals": 0,
+ "mappings": [
+ {
+ "type": "special",
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ }
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "#299c46"
+ },
+ {
+ "value": 1,
+ "color": "#bf1b00"
+ },
+ {
+ "value": 1000,
+ "color": "#d44a3a"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-6": {
+ "kind": "Panel",
+ "spec": {
+ "id": 6,
+ "title": "Max. write lag",
+ "description": "Data is available only on connected replicas! Based on last 5m data.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "1d"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "replication",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "SELECT max(\"write_lag_b\") FROM \"replication\" WHERE $timeFilter GROUP BY time($__interval) fill(none)",
+ "rawQuery": true,
+ "rawSql": "SELECT\n 0 as time,\n max((data->>'write_lag_b')::int8)\nFROM\n replication\nWHERE\n time in (select max(time) from replication where $__timeFilter(time) AND dbname in ($dbname) group by dbname)\n AND dbname in ($dbname)\n\n",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "write_lag_b"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "max"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$dbname$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "timeFrom": "5m",
+ "maxDataPoints": 100,
+ "hideTimeOverride": true
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "stat",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "colorMode": "value",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "percentChangeColorMode": "standard",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "bytes",
+ "decimals": 1,
+ "mappings": [
+ {
+ "type": "special",
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ }
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "#299c46"
+ },
+ {
+ "value": 100000000,
+ "color": "rgba(237, 129, 40, 0.89)"
+ },
+ {
+ "value": 1000000000,
+ "color": "#d44a3a"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-7": {
+ "kind": "Panel",
+ "spec": {
+ "id": 7,
+ "title": "Slot max. restart_lsn lag",
+ "description": "Based on last 5m of \"pg_replication_slots.restart_lsn\" and translates to \"overhead\" WAL folder size",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "replication_slots",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "SELECT max(\"restart_lsn_lag_b\") FROM \"replication_slots\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY time(1d) fill(none)",
+ "rawQuery": true,
+ "rawSql": "SELECT\n 0 as time,\n max((data->>'restart_lsn_lag_b')::int8)\nFROM\n replication_slots\nWHERE\n time in (select max(time) from replication_slots where $__timeFilter(time) AND dbname in ($dbname) group by dbname)\n AND dbname in ($dbname)\n\n",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "restart_lsn_lag_b"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "max"
+ }
+ ]
+ ],
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "timeFrom": "5m",
+ "maxDataPoints": 100,
+ "hideTimeOverride": true
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "stat",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "colorMode": "background",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "percentChangeColorMode": "standard",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "bytes",
+ "decimals": 1,
+ "mappings": [
+ {
+ "type": "special",
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ }
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "#299c46"
+ },
+ {
+ "value": 16000000,
+ "color": "rgba(237, 129, 40, 0.89)"
+ },
+ {
+ "value": 1000000000,
+ "color": "#d44a3a"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-8": {
+ "kind": "Panel",
+ "spec": {
+ "id": 8,
+ "title": "Replication replay lag",
+ "description": "Based on pg_stat_replication on primaries. Data is available only on connected replicas!",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "[[tag_dbname]] [[tag_application_name]] [[tag_client_info]]",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "dbname"
+ ],
+ "type": "tag"
+ },
+ {
+ "params": [
+ "client_info"
+ ],
+ "type": "tag"
+ },
+ {
+ "params": [
+ "application_name"
+ ],
+ "type": "tag"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "replication",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "",
+ "rawQuery": true,
+ "rawSql": "SELECT\n $__timeGroup(time, $__interval),\n dbname,\n avg((data->>'replay_lag_b')::int8)\nFROM\n replication\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY\n 1, 2\nORDER BY\n 1, 2\n \n",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "replay_lag_b"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$dbname$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "B",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "15m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "bytes",
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-9": {
+ "kind": "Panel",
+ "spec": {
+ "id": 9,
+ "title": "Max. replay lag",
+ "description": "Data is available only on connected replicas! Based on last 5m data.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "1d"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "replication",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "SELECT max(\"replay_lag_b\") FROM \"replication\" WHERE (\"dbname\" =~ /^$dbname$/) AND $timeFilter GROUP BY time($__interval) fill(none)",
+ "rawQuery": true,
+ "rawSql": "SELECT\n 0 as time,\n max((data->>'replay_lag_b')::int8)\nFROM\n replication\nWHERE\n time in (select max(time) from replication where $__timeFilter(time) AND dbname in ($dbname) group by dbname)\n AND dbname in ($dbname)\n\n",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "replay_lag_b"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "max"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$dbname$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "timeFrom": "5m",
+ "maxDataPoints": 100,
+ "hideTimeOverride": true
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "stat",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "colorMode": "value",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "percentChangeColorMode": "standard",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "bytes",
+ "decimals": 1,
+ "mappings": [
+ {
+ "type": "special",
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ }
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "#299c46"
+ },
+ {
+ "value": 100000000,
+ "color": "rgba(237, 129, 40, 0.89)"
+ },
+ {
+ "value": 1000000000,
+ "color": "#d44a3a"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ }
+ },
+ "layout": {
+ "kind": "GridLayout",
+ "spec": {
+ "items": [
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 0,
+ "width": 3,
+ "height": 2,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-4"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 3,
+ "y": 0,
+ "width": 3,
+ "height": 2,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-13"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 6,
+ "y": 0,
+ "width": 3,
+ "height": 2,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-14"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 9,
+ "y": 0,
+ "width": 3,
+ "height": 2,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-15"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 12,
+ "y": 0,
+ "width": 3,
+ "height": 2,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-7"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 15,
+ "y": 0,
+ "width": 3,
+ "height": 2,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-6"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 18,
+ "y": 0,
+ "width": 3,
+ "height": 2,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-16"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 21,
+ "y": 0,
+ "width": 3,
+ "height": 2,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-9"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 2,
+ "width": 24,
+ "height": 4,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-2"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 6,
+ "width": 24,
+ "height": 4,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-17"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 10,
+ "width": 24,
+ "height": 4,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-8"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 14,
+ "width": 24,
+ "height": 4,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-10"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 18,
+ "width": 24,
+ "height": 4,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-12"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "links": [],
+ "liveNow": false,
+ "preload": false,
+ "tags": [
+ "pgwatch"
+ ],
+ "timeSettings": {
+ "timezone": "browser",
+ "from": "now-3h",
+ "to": "now",
+ "autoRefresh": "",
+ "autoRefreshIntervals": [
+ "5s",
+ "10s",
+ "30s",
+ "1m",
+ "5m",
+ "15m",
+ "30m",
+ "1h",
+ "2h",
+ "1d"
+ ],
+ "hideTimepicker": false,
+ "fiscalYearStartMonth": 0
+ },
+ "title": "Replication",
+ "variables": [
+ {
+ "kind": "QueryVariable",
+ "spec": {
+ "name": "dbname",
+ "current": {
+ "text": "All",
+ "value": [
+ "$__all"
+ ]
+ },
+ "hide": "dontHide",
+ "refresh": "onDashboardLoad",
+ "skipUrlSync": false,
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "__legacyStringValue": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric IN ('replication', 'replication_slots') ORDER BY 1;"
+ }
+ },
+ "regex": "",
+ "sort": "disabled",
+ "definition": "",
+ "options": [],
+ "multi": true,
+ "includeAll": true,
+ "allowCustomValue": true
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/grafana/postgres/v13/server-log-events.json b/grafana/postgres/v13/server-log-events.json
new file mode 100644
index 0000000000..e4b28170fb
--- /dev/null
+++ b/grafana/postgres/v13/server-log-events.json
@@ -0,0 +1,965 @@
+{
+ "apiVersion": "dashboard.grafana.app/v2",
+ "kind": "Dashboard",
+ "metadata": {
+ "name": "server-log-events"
+ },
+ "spec": {
+ "annotations": [
+ {
+ "kind": "AnnotationQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "grafana"
+ },
+ "spec": {}
+ },
+ "enable": true,
+ "hide": true,
+ "iconColor": "rgba(0, 211, 255, 1)",
+ "name": "Annotations & Alerts",
+ "builtIn": true,
+ "legacyOptions": {
+ "type": "dashboard"
+ }
+ }
+ }
+ ],
+ "cursorSync": "Off",
+ "description": "Assumes local (on DB server) setup and CSVLOG output format",
+ "editable": true,
+ "elements": {
+ "panel-2": {
+ "kind": "Panel",
+ "spec": {
+ "id": 2,
+ "title": "Server log events (DB)",
+ "description": "Based on 'server_log_event_counts' metric. Assumes local (on DB server) setup and CSVLOG output format",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n sum((data->>'debug')::int8) as debug,\n sum((data->>'log')::int8) as log,\n sum((data->>'notice')::int8) as notice, \n sum((data->>'warning')::int8) as warning,\n sum((data->>'error')::int8) as error,\n sum((data->>'fatal')::int8) as fatal,\n sum((data->>'panic')::int8) as panic\nFROM\n server_log_event_counts\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY\n 1\nORDER BY\n 1\n",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "fatal"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "super-light-red",
+ "mode": "fixed"
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "panic"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "dark-purple",
+ "mode": "fixed"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-3": {
+ "kind": "Panel",
+ "spec": {
+ "id": 3,
+ "title": "Server log events (whole instance)",
+ "description": "Based on 'server_log_event_counts' metric. Assumes local (on DB server) setup and CSVLOG output format",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n sum((data->>'debug_total')::int8) as debug,\n sum((data->>'log_total')::int8) as log,\n sum((data->>'notice_total')::int8) as notice, \n sum((data->>'warning_total')::int8) as warning,\n sum((data->>'error_total')::int8) as error,\n sum((data->>'fatal_total')::int8) as fatal,\n sum((data->>'panic_total')::int8) as panic\nFROM\n server_log_event_counts\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY\n 1\nORDER BY\n 1\n",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "fatal"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "super-light-red",
+ "mode": "fixed"
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "panic"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "dark-purple",
+ "mode": "fixed"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-5": {
+ "kind": "Panel",
+ "spec": {
+ "id": 5,
+ "title": "Top ERROR generating DBs",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT\n dbname,\n sum((data->>'error')::int8) as \"ERROR\",\n sum((data->>'error_total')::int8) as \"ERROR_TOTAL\",\n sum((data->>'fatal')::int8) as \"FATAL\", \n sum((data->>'fatal_total')::int8) as \"FATAL_TOTAL\"\nFROM\n server_log_event_counts\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY\n 1\nORDER BY\n 2 DESC\nLIMIT\n 20\n",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "footer": {
+ "countRows": false,
+ "fields": "",
+ "reducer": [
+ "sum"
+ ],
+ "show": false
+ },
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Time"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Time"
+ },
+ {
+ "id": "unit",
+ "value": "time: YYYY-MM-DD HH:mm:ss"
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byRegexp",
+ "options": "/ERROR|FATAL/"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "dbname"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": true,
+ "title": "Go to DB overview dash",
+ "url": "/d/db-overview?var-dbname=${__data.fields[\"dbname\"]}"
+ }
+ ]
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-6": {
+ "kind": "Panel",
+ "spec": {
+ "id": 6,
+ "title": "Top FATAL generating instances",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT\n dbname,\n sum((data->>'fatal_total')::int8) as \"FATAL_TOTAL\",\n sum((data->>'fatal')::int8) as \"FATAL\",\n sum((data->>'error_total')::int8) as \"ERROR_TOTAL\",\n sum((data->>'error')::int8) as \"ERROR\"\nFROM\n server_log_event_counts\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY\n 1\nORDER BY\n 2 DESC\nLIMIT\n 20\n",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "footer": {
+ "countRows": false,
+ "fields": "",
+ "reducer": [
+ "sum"
+ ],
+ "show": false
+ },
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Time"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Time"
+ },
+ {
+ "id": "unit",
+ "value": "time: YYYY-MM-DD HH:mm:ss"
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byRegexp",
+ "options": "/ERROR|FATAL/"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "dbname"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": true,
+ "title": "Go to DB overview dash",
+ "url": "/d/db-overview?var-dbname=${__data.fields[\"dbname\"]}"
+ }
+ ]
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-8": {
+ "kind": "Panel",
+ "spec": {
+ "id": 8,
+ "title": "",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "text",
+ "version": "10.4.1",
+ "spec": {
+ "options": {
+ "code": {
+ "language": "plaintext",
+ "showLineNumbers": false,
+ "showMiniMap": false
+ },
+ "content": "### Brought to you by\n\n[](https://www.cybertec-postgresql.com/en/)\n",
+ "mode": "markdown"
+ },
+ "fieldConfig": {
+ "defaults": {},
+ "overrides": []
+ }
+ }
+ },
+ "transparent": true
+ }
+ }
+ },
+ "layout": {
+ "kind": "GridLayout",
+ "spec": {
+ "items": [
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 0,
+ "width": 24,
+ "height": 10,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-2"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 10,
+ "width": 24,
+ "height": 10,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-3"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 20,
+ "width": 12,
+ "height": 8,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-5"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 12,
+ "y": 20,
+ "width": 12,
+ "height": 8,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-6"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 28,
+ "width": 12,
+ "height": 8,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-8"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "links": [],
+ "liveNow": false,
+ "preload": false,
+ "tags": [
+ "pgwatch"
+ ],
+ "timeSettings": {
+ "from": "now-6h",
+ "to": "now",
+ "autoRefresh": "",
+ "autoRefreshIntervals": [
+ "5s",
+ "10s",
+ "30s",
+ "1m",
+ "5m",
+ "15m",
+ "30m",
+ "1h",
+ "2h",
+ "1d"
+ ],
+ "hideTimepicker": false,
+ "fiscalYearStartMonth": 0
+ },
+ "title": "Server Log Events",
+ "variables": [
+ {
+ "kind": "QueryVariable",
+ "spec": {
+ "name": "dbname",
+ "current": {
+ "text": "All",
+ "value": [
+ "$__all"
+ ]
+ },
+ "hide": "dontHide",
+ "refresh": "onDashboardLoad",
+ "skipUrlSync": false,
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "__legacyStringValue": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'server_log_event_counts' ORDER BY 1;"
+ }
+ },
+ "regex": "",
+ "sort": "disabled",
+ "definition": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'server_log_event_counts' ORDER BY 1;",
+ "options": [],
+ "multi": true,
+ "includeAll": true,
+ "allowCustomValue": true
+ }
+ },
+ {
+ "kind": "IntervalVariable",
+ "spec": {
+ "name": "agg_interval",
+ "query": "1m,5m,10m,15m,30m,1h,6h,12h,1d",
+ "current": {
+ "text": "5m",
+ "value": "5m"
+ },
+ "options": [
+ {
+ "selected": false,
+ "text": "1m",
+ "value": "1m"
+ },
+ {
+ "selected": true,
+ "text": "5m",
+ "value": "5m"
+ },
+ {
+ "selected": false,
+ "text": "10m",
+ "value": "10m"
+ },
+ {
+ "selected": false,
+ "text": "15m",
+ "value": "15m"
+ },
+ {
+ "selected": false,
+ "text": "30m",
+ "value": "30m"
+ },
+ {
+ "selected": false,
+ "text": "1h",
+ "value": "1h"
+ },
+ {
+ "selected": false,
+ "text": "6h",
+ "value": "6h"
+ },
+ {
+ "selected": false,
+ "text": "12h",
+ "value": "12h"
+ },
+ {
+ "selected": false,
+ "text": "1d",
+ "value": "1d"
+ }
+ ],
+ "auto": false,
+ "auto_min": "10s",
+ "auto_count": 30,
+ "refresh": "onTimeRangeChanged",
+ "hide": "dontHide",
+ "skipUrlSync": false
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/grafana/postgres/v13/sessions-overview.json b/grafana/postgres/v13/sessions-overview.json
new file mode 100644
index 0000000000..ddb714904c
--- /dev/null
+++ b/grafana/postgres/v13/sessions-overview.json
@@ -0,0 +1,1820 @@
+{
+ "apiVersion": "dashboard.grafana.app/v2",
+ "kind": "Dashboard",
+ "metadata": {
+ "name": "sessions-overview"
+ },
+ "spec": {
+ "annotations": [
+ {
+ "kind": "AnnotationQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "grafana"
+ },
+ "spec": {}
+ },
+ "enable": true,
+ "hide": true,
+ "iconColor": "rgba(0, 211, 255, 1)",
+ "name": "Annotations & Alerts",
+ "builtIn": true,
+ "legacyOptions": {
+ "type": "dashboard"
+ }
+ }
+ }
+ ],
+ "cursorSync": "Off",
+ "editable": true,
+ "elements": {
+ "panel-10": {
+ "kind": "Panel",
+ "spec": {
+ "id": 10,
+ "title": "Sessions by state",
+ "description": "Max. value per $agg_interval",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n max((data->>'active')::int8) as active,\n max((data->>'total')::int8) as total_db,\n max((data->>'idleintransaction')::int8) as idleintransaction,\n max((data->>'waiting')::int8) as waiting\nfrom backends\nwhere dbname = '$dbname' and $__timeFilter(time)\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "decimals": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-11": {
+ "kind": "Panel",
+ "spec": {
+ "id": 11,
+ "title": "Instance total connections",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n max((data->>'instance_total')::int8) as instance_total,\n max((data->>'max_connections')::int8) as max_connections\nfrom backends\nwhere dbname = '$dbname' and $__timeFilter(time)\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "B",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "decimals": 0,
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "max_connections"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "dark-red",
+ "mode": "fixed"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-13": {
+ "kind": "Panel",
+ "spec": {
+ "id": 13,
+ "title": "",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "text",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "code": {
+ "language": "plaintext",
+ "showLineNumbers": false,
+ "showMiniMap": false
+ },
+ "content": "### Brought to you by\n\n[](https://www.cybertec-postgresql.com/en/)\n",
+ "mode": "markdown"
+ },
+ "fieldConfig": {
+ "defaults": {},
+ "overrides": []
+ }
+ }
+ },
+ "transparent": true
+ }
+ },
+ "panel-14": {
+ "kind": "Panel",
+ "spec": {
+ "id": 14,
+ "title": "Connections Overview",
+ "description": "- Total number of sessions established to this database. \n- Number of database sessions to this database that were terminated because connection to the client was lost.\n- Number of database sessions to this database that were terminated by fatal errors.\n- Number of database sessions to this database that were terminated by operator intervention.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "editorMode": "code",
+ "format": "table",
+ "rawQuery": true,
+ "rawSql": "with sessions as (\r\n SELECT \r\n $__timeGroup(time, $agg_interval),\r\n (data->>'sessions')::int8 as sessions,\r\n lag((data->>'sessions')::int8) over w as lag_sessions,\r\n (data->>'sessions_abandoned')::int8 as sessions_abandoned,\r\n lag((data->>'sessions_abandoned')::int8) over w as lag_sessions_abandoned,\r\n (data->>'sessions_fatal')::int8 as sessions_fatal,\r\n lag((data->>'sessions_fatal')::int8) over w as lag_sessions_fatal,\r\n (data->>'sessions_killed')::int8 as sessions_killed,\r\n lag((data->>'sessions_killed')::int8) over w as lag_sessions_killed\r\nfrom db_stats \r\nwhere dbname = '$dbname' and $__timeFilter(time)\r\nwindow w as (order by time)\r\n)\r\nselect \r\n time,\r\n sum(sessions-lag_sessions) as established,\r\n sum(sessions_abandoned-lag_sessions_abandoned) as abandoned,\r\n sum(sessions_fatal-lag_sessions_fatal) as fatal,\r\n sum(sessions_killed-lag_sessions_killed) as killed\r\nfrom sessions \r\ngroup by time\r\norder by 1",
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ }
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "single",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ }
+ ]
+ },
+ "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",
+ "lineStyle": {
+ "fill": "solid"
+ },
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "auto",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-2": {
+ "kind": "Panel",
+ "spec": {
+ "id": 2,
+ "title": "Max. TPS / QPS",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n max(((c - c_lag) + (r - r_lag)) / extract(epoch from time - time_lag)) as \"TPS\"\nfrom (\n select \n (data->>'xact_commit')::int8 as c, lag((data->>'xact_commit')::int8) over w as c_lag,\n (data->>'xact_rollback')::int8 as r, lag((data->>'xact_rollback')::int8) over w as r_lag,\n time, lag(time) over w as time_lag\n from db_stats\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and r >= r_lag and time > time_lag\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ },
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n max((c - c_lag) / extract(epoch from time - time_lag)) as \"QPS\"\nfrom (\n select \n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from stat_statements_calls\n where dbname = '$dbname' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1\n",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "B",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-4": {
+ "kind": "Panel",
+ "spec": {
+ "id": 4,
+ "title": "Longest query duration",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n max((data->>'longest_query_seconds')::int8) as longest_query,\n max((data->>'avg_query_seconds')::float) as avg_query\nfrom backends\nwhere dbname = '$dbname' and $__timeFilter(time)\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "s",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "avg_query"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "super-light-purple",
+ "mode": "fixed"
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "longest_query"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "dark-orange",
+ "mode": "fixed"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-5": {
+ "kind": "Panel",
+ "spec": {
+ "id": 5,
+ "title": "Longest TX duration",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n max((data->>'longest_tx_seconds')::int8) as longest_tx,\n max((data->>'avg_tx_seconds')::float) as avg_tx\nfrom backends\nwhere dbname = '$dbname' and $__timeFilter(time)\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "max"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "s",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "avg_tx"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "light-blue",
+ "mode": "fixed"
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "longest_tx"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "dark-purple",
+ "mode": "fixed"
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "longest_tx_seconds"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "dark-purple",
+ "mode": "fixed"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-6": {
+ "kind": "Panel",
+ "spec": {
+ "id": 6,
+ "title": "Longest Autovacuum duration / # AV workers",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n max((data->>'longest_autovacuum_seconds')::int8) as longest_autovacuum_seconds\nfrom backends\nwhere dbname = '$dbname' and $__timeFilter(time)\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ },
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n max((data->>'av_workers')::int8) as max_av_workers\nfrom backends\nwhere dbname = '$dbname' and $__timeFilter(time)\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "B",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "max"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "s",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "longest_autovacuum_seconds"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "light-red",
+ "mode": "fixed"
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "max_av_workers"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "none"
+ },
+ {
+ "id": "decimals",
+ "value": 0
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-7": {
+ "kind": "Panel",
+ "spec": {
+ "id": 7,
+ "title": "Longest wait duration",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n max((data->>'longest_waiting_seconds')::int8) as longest_waiting,\n max((data->>'avg_waiting_seconds')::float) as avg_waiting\nfrom backends\nwhere dbname = '$dbname' and $__timeFilter(time)\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "max"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "s",
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "longest_waiting"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "dark-red",
+ "mode": "fixed"
+ }
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "longest_waiting_seconds"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "light-red",
+ "mode": "fixed"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-8": {
+ "kind": "Panel",
+ "spec": {
+ "id": 8,
+ "title": "Longest session duration",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select\n $__timeGroup(time, $agg_interval),\n max((data->>'longest_session_seconds')::int8) as longest_session,\n max((data->>'avg_session_seconds')::float) as avg_session\nfrom backends\nwhere dbname = '$dbname' and $__timeFilter(time)\ngroup by 1\norder by 1",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "max"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "s",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "longest_session_seconds"
+ },
+ "properties": [
+ {
+ "id": "color",
+ "value": {
+ "fixedColor": "dark-orange",
+ "mode": "fixed"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ }
+ },
+ "layout": {
+ "kind": "GridLayout",
+ "spec": {
+ "items": [
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 0,
+ "width": 24,
+ "height": 8,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-14"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 8,
+ "width": 24,
+ "height": 6,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-2"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 14,
+ "width": 24,
+ "height": 6,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-4"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 20,
+ "width": 24,
+ "height": 6,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-7"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 26,
+ "width": 24,
+ "height": 6,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-5"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 32,
+ "width": 24,
+ "height": 6,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-8"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 38,
+ "width": 24,
+ "height": 6,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-6"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 44,
+ "width": 24,
+ "height": 6,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-10"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 50,
+ "width": 24,
+ "height": 6,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-11"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 56,
+ "width": 9,
+ "height": 3,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-13"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "links": [],
+ "liveNow": false,
+ "preload": false,
+ "tags": [
+ "pgwatch"
+ ],
+ "timeSettings": {
+ "from": "now-12h",
+ "to": "now",
+ "autoRefresh": "",
+ "autoRefreshIntervals": [
+ "5s",
+ "10s",
+ "30s",
+ "1m",
+ "5m",
+ "15m",
+ "30m",
+ "1h",
+ "2h",
+ "1d"
+ ],
+ "hideTimepicker": false,
+ "fiscalYearStartMonth": 0
+ },
+ "title": "Sessions overview",
+ "variables": [
+ {
+ "kind": "QueryVariable",
+ "spec": {
+ "name": "dbname",
+ "current": {
+ "text": "",
+ "value": ""
+ },
+ "hide": "dontHide",
+ "refresh": "onDashboardLoad",
+ "skipUrlSync": false,
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "__legacyStringValue": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'backends' ORDER BY 1;"
+ }
+ },
+ "regex": "",
+ "sort": "disabled",
+ "definition": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'backends' ORDER BY 1;",
+ "options": [],
+ "multi": false,
+ "includeAll": false,
+ "allowCustomValue": true
+ }
+ },
+ {
+ "kind": "IntervalVariable",
+ "spec": {
+ "name": "agg_interval",
+ "query": "1s,1m,5m,10m,15m,30m,1h,6h,12h,1d,7d,14d,30d",
+ "current": {
+ "text": "5m",
+ "value": "5m"
+ },
+ "options": [
+ {
+ "selected": false,
+ "text": "1s",
+ "value": "1s"
+ },
+ {
+ "selected": false,
+ "text": "1m",
+ "value": "1m"
+ },
+ {
+ "selected": true,
+ "text": "5m",
+ "value": "5m"
+ },
+ {
+ "selected": false,
+ "text": "10m",
+ "value": "10m"
+ },
+ {
+ "selected": false,
+ "text": "15m",
+ "value": "15m"
+ },
+ {
+ "selected": false,
+ "text": "30m",
+ "value": "30m"
+ },
+ {
+ "selected": false,
+ "text": "1h",
+ "value": "1h"
+ },
+ {
+ "selected": false,
+ "text": "6h",
+ "value": "6h"
+ },
+ {
+ "selected": false,
+ "text": "12h",
+ "value": "12h"
+ },
+ {
+ "selected": false,
+ "text": "1d",
+ "value": "1d"
+ },
+ {
+ "selected": false,
+ "text": "7d",
+ "value": "7d"
+ },
+ {
+ "selected": false,
+ "text": "14d",
+ "value": "14d"
+ },
+ {
+ "selected": false,
+ "text": "30d",
+ "value": "30d"
+ }
+ ],
+ "auto": false,
+ "auto_min": "10s",
+ "auto_count": 30,
+ "refresh": "onTimeRangeChanged",
+ "hide": "dontHide",
+ "skipUrlSync": false
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/grafana/postgres/v13/single-query-details.json b/grafana/postgres/v13/single-query-details.json
new file mode 100644
index 0000000000..8fa18ce429
--- /dev/null
+++ b/grafana/postgres/v13/single-query-details.json
@@ -0,0 +1,2062 @@
+{
+ "apiVersion": "dashboard.grafana.app/v2",
+ "kind": "Dashboard",
+ "metadata": {
+ "name": "single-query-details"
+ },
+ "spec": {
+ "annotations": [
+ {
+ "kind": "AnnotationQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "grafana"
+ },
+ "spec": {}
+ },
+ "enable": true,
+ "hide": true,
+ "iconColor": "rgba(0, 211, 255, 1)",
+ "name": "Annotations & Alerts",
+ "builtIn": true,
+ "legacyOptions": {
+ "type": "dashboard"
+ }
+ }
+ }
+ ],
+ "cursorSync": "Off",
+ "description": "For one query",
+ "editable": true,
+ "elements": {
+ "panel-1": {
+ "kind": "Panel",
+ "spec": {
+ "id": 1,
+ "title": "SQL",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "text",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "code": {
+ "language": "sql",
+ "showLineNumbers": true,
+ "showMiniMap": false
+ },
+ "content": "$sql_text",
+ "mode": "code"
+ },
+ "fieldConfig": {
+ "defaults": {},
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Time"
+ },
+ "properties": []
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Metric"
+ },
+ "properties": []
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Value"
+ },
+ "properties": []
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-10": {
+ "kind": "Panel",
+ "spec": {
+ "id": 10,
+ "title": "Temp Bytes Read/Written per call",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "temp_blks_written",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "queryid"
+ ],
+ "type": "tag"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "stat_statements",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "with baseline as (\n select time\n from stat_statements\n where dbname = '$dbname'\n and tag_data @> '{\"queryid\": \"$queryid\"}'\n and time < $__timeFrom()::timestamptz\n order by time desc\n limit 1\n)\nselect\n $__timeGroup(time, $agg_interval),\n avg(case when c = c_lag then null else ((read - read_lag)::numeric * 8192) / nullif(c - c_lag, 0) end) as \"Temp Bytes read\",\n avg(case when c = c_lag then null else ((written - written_lag)::numeric * 8192) / nullif(c - c_lag, 0) end) as \"Temp Bytes written\"\nfrom (\n select\n (data->>'temp_blks_read')::int8 as read, lag((data->>'temp_blks_read')::int8) over w as read_lag,\n (data->>'temp_blks_written')::int8 as written, lag((data->>'temp_blks_written')::int8) over w as written_lag,\n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n time\n from stat_statements\n where dbname = '$dbname'\n and tag_data @> '{\"queryid\": \"$queryid\"}'\n and time <= $__timeTo()::timestamptz\n and time >= coalesce((select time from baseline), $__timeFrom()::timestamptz)\n window w as (order by time)\n) x\nwhere read >= read_lag and written >= written_lag and c >= c_lag\n and time >= $__timeFrom()::timestamptz\ngroup by 1\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "temp_blks_written"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "$rate_unit"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "queryid",
+ "operator": "=~",
+ "value": "/^$queryid$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "5m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean",
+ "max",
+ "min"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "bytes",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "showValues": false,
+ "spanNulls": 3600000,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-11": {
+ "kind": "Panel",
+ "spec": {
+ "id": 11,
+ "title": "Shared Buffers Hit Ratio",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "sb_hit_ratio",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "stat_statements",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "SELECT non_negative_derivative(mean(\"shared_blks_hit\")) / (non_negative_derivative(mean(\"shared_blks_hit\")) + non_negative_derivative(mean(\"shared_blks_read\"))) * 100 FROM \"stat_statements\" WHERE \"queryid\" =~ /^$queryid$/ AND $timeFilter GROUP BY time($__interval), \"queryid\" fill(null)",
+ "rawQuery": true,
+ "rawSql": "with baseline as (\n select time\n from stat_statements\n where dbname = '$dbname'\n and tag_data @> '{\"queryid\": \"$queryid\"}'\n and time < $__timeFrom()::timestamptz\n order by time desc\n limit 1\n)\nselect\n $__timeGroup(time, $agg_interval),\n avg(case when hit = hit_lag and read = read_lag then null else ((hit-hit_lag)::numeric * 100) / nullif((hit-hit_lag) + (read-read_lag), 0) end) as \"sb_hit_ratio\"\nfrom (\n select\n (data->>'shared_blks_hit')::int8 as hit, lag((data->>'shared_blks_hit')::int8) over w as hit_lag,\n (data->>'shared_blks_read')::int8 as read, lag((data->>'shared_blks_read')::int8) over w as read_lag,\n time\n from stat_statements\n where dbname = '$dbname'\n and tag_data @> '{\"queryid\": \"$queryid\"}'\n and time <= $__timeTo()::timestamptz\n and time >= coalesce((select time from baseline), $__timeFrom()::timestamptz)\n window w as (order by time)\n) x\nwhere hit >= hit_lag and read >= read_lag\n and time >= $__timeFrom()::timestamptz\ngroup by 1\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "shared_blks_hit"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "1h"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "queryid",
+ "operator": "=~",
+ "value": "/^$queryid$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "5m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean",
+ "max",
+ "min"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "displayName": "$queryid",
+ "unit": "percent",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "showValues": false,
+ "spanNulls": 3600000,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-2": {
+ "kind": "Panel",
+ "spec": {
+ "id": 2,
+ "title": "Calls",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "calls",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "queryid"
+ ],
+ "type": "tag"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "stat_statements",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "with baseline AS (\n select time\n from stat_statements\n where dbname = '$dbname'\n and tag_data @> '{\"queryid\": \"$queryid\"}'\n and time < $__timeFrom()::timestamptz\n order by time desc\n limit 1\n)\nselect\n $__timeGroup(time, $agg_interval),\n sum(c - c_lag) / nullif(extract(epoch from sum(time - time_lag)), 0) as \"calls_per_sec\"\nfrom (\n select\n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from stat_statements\n where dbname = '$dbname'\n and tag_data @> '{\"queryid\": \"$queryid\"}'\n and time <= $__timeTo()::timestamptz\n and time >= coalesce((select time from baseline), $__timeFrom()::timestamptz)\n window w as (order by time)\n) x\nwhere c >= c_lag\n and time >= $__timeFrom()::timestamptz\ngroup by 1\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "calls"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "$rate_unit"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "queryid",
+ "operator": "=~",
+ "value": "/^$queryid$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "5m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean",
+ "max",
+ "min"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "displayName": "$queryid",
+ "unit": "calls/s",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "showValues": false,
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-3": {
+ "kind": "Panel",
+ "spec": {
+ "id": 3,
+ "title": "Execution time per second",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "avg_runtime",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "stat_statements",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "SELECT non_negative_derivative(mean(\"total_time\")) / non_negative_derivative(mean(\"calls\")) FROM \"stat_statements\" WHERE \"queryid\" =~ /^$queryid$/ AND $timeFilter GROUP BY time($__interval), \"queryid\" fill(null)",
+ "rawQuery": true,
+ "rawSql": "with baseline as (\n select time\n from stat_statements\n where dbname = '$dbname'\n and tag_data @> '{\"queryid\": \"$queryid\"}'\n and time < $__timeFrom()::timestamptz\n order by time desc\n limit 1\n)\nselect\n $__timeGroup(time, $agg_interval),\n sum(tt - tt_lag) / nullif(extract(epoch from sum(time - time_lag)), 0) as \"total_time_per_sec\"\nfrom (\n select\n (data->>'total_time')::float8 as tt, lag((data->>'total_time')::float8) over w as tt_lag,\n time, lag(time) over w as time_lag\n from stat_statements\n where dbname = '$dbname'\n and tag_data @> '{\"queryid\": \"$queryid\"}'\n and time <= $__timeTo()::timestamptz\n and time >= coalesce((select time from baseline), $__timeFrom()::timestamptz)\n window w as (order by time)\n) x\nwhere tt >= tt_lag\n and time >= $__timeFrom()::timestamptz\ngroup by 1\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "total_time"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "1h"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "queryid",
+ "operator": "=~",
+ "value": "/^$queryid$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "5m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean",
+ "max",
+ "min"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "displayName": "$queryid",
+ "unit": "ms/s",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisGridShow": true,
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "showValues": false,
+ "spanNulls": true,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-4": {
+ "kind": "Panel",
+ "spec": {
+ "id": 4,
+ "title": "Execution time per call",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "avg_runtime",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "stat_statements",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "with baseline as (\n select time\n from stat_statements\n where dbname = '$dbname'\n and tag_data @> '{\"queryid\": \"$queryid\"}'\n and time < $__timeFrom()::timestamptz\n order by time desc\n limit 1\n)\nselect\n $__timeGroup(time, $agg_interval),\n avg(case when c = c_lag then null else (tt - tt_lag) / nullif(c - c_lag, 0) end) as \"time_per_call\"\nfrom (\n select\n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n (data->>'total_time')::float8 as tt, lag((data->>'total_time')::float8) over w as tt_lag,\n time\n from stat_statements\n where dbname = '$dbname'\n and tag_data @> '{\"queryid\": \"$queryid\"}'\n and time <= $__timeTo()::timestamptz\n and time >= coalesce((select time from baseline), $__timeFrom()::timestamptz)\n window w as (order by time)\n) x\nwhere c >= c_lag\n and time >= $__timeFrom()::timestamptz\ngroup by 1\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "total_time"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "1h"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "queryid",
+ "operator": "=~",
+ "value": "/^$queryid$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "5m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean",
+ "max",
+ "min"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "displayName": "$queryid",
+ "unit": "ms",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisGridShow": true,
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "showValues": false,
+ "spanNulls": 3600000,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-5": {
+ "kind": "Panel",
+ "spec": {
+ "id": 5,
+ "title": "Shared Buffers Hit/Read per call",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "sb_hit_ratio",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "stat_statements",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "SELECT non_negative_derivative(mean(\"shared_blks_hit\")) / (non_negative_derivative(mean(\"shared_blks_hit\")) + non_negative_derivative(mean(\"shared_blks_read\"))) * 100 FROM \"stat_statements\" WHERE \"queryid\" =~ /^$queryid$/ AND $timeFilter GROUP BY time($__interval), \"queryid\" fill(null)",
+ "rawQuery": true,
+ "rawSql": "with baseline as (\n select time\n from stat_statements\n where dbname = '$dbname'\n and tag_data @> '{\"queryid\": \"$queryid\"}'\n and time < $__timeFrom()::timestamptz\n order by time desc\n limit 1\n),\nbase_data as (\n select\n (data->>'shared_blks_hit')::int8 as hit, lag((data->>'shared_blks_hit')::int8) over w as hit_lag,\n (data->>'shared_blks_read')::int8 as read, lag((data->>'shared_blks_read')::int8) over w as read_lag,\n (data->>'calls')::int8 as c, lag((data->>'calls')::int8) over w as c_lag,\n time\n from stat_statements\n where dbname = '$dbname'\n and tag_data @> '{\"queryid\": \"$queryid\"}'\n and time <= $__timeTo()::timestamptz\n and time >= coalesce((select time from baseline), $__timeFrom()::timestamptz)\n window w as (order by time)\n)\nselect\n $__timeGroup(time, $agg_interval),\n avg(case when c = c_lag then null else ((hit - hit_lag)::numeric * 8192) / nullif(c - c_lag, 0) end) as \"Shared Buffers bytes hit\",\n avg(case when c = c_lag then null else ((read - read_lag)::numeric * 8192) / nullif(c - c_lag, 0) end) as \"Shared Buffers bytes read\"\nfrom base_data\nwhere hit >= hit_lag and read >= read_lag and c >= c_lag\n and time >= $__timeFrom()::timestamptz\ngroup by 1\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "shared_blks_hit"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "1h"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "queryid",
+ "operator": "=~",
+ "value": "/^$queryid$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "5m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean",
+ "max",
+ "min"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "displayName": "${__field.name}",
+ "unit": "bytes",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "showValues": false,
+ "spanNulls": 3600000,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-6": {
+ "kind": "Panel",
+ "spec": {
+ "id": 6,
+ "title": "Temp Bytes Read/Written per second",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "temp_blks_written",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "queryid"
+ ],
+ "type": "tag"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "stat_statements",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "with baseline as (\n select time\n from stat_statements\n where dbname = '$dbname'\n and tag_data @> '{\"queryid\": \"$queryid\"}'\n and time < $__timeFrom()::timestamptz\n order by time desc\n limit 1\n)\nselect\n $__timeGroup(time, $agg_interval),\n sum(read - read_lag) * 8192 / nullif(extract(epoch from sum(time - time_lag)), 0) as \"Temp Bytes read\",\n sum(written - written_lag) * 8192 / nullif(extract(epoch from sum(time - time_lag)), 0) as \"Temp Bytes written\"\nfrom (\n select\n (data->>'temp_blks_read')::int8 as read, lag((data->>'temp_blks_read')::int8) over w as read_lag,\n (data->>'temp_blks_written')::int8 as written, lag((data->>'temp_blks_written')::int8) over w as written_lag,\n time, lag(time) over w as time_lag\n from stat_statements\n where dbname = '$dbname'\n and tag_data @> '{\"queryid\": \"$queryid\"}'\n and time <= $__timeTo()::timestamptz\n and time >= coalesce((select time from baseline), $__timeFrom()::timestamptz)\n window w as (order by time)\n) x\nwhere read >= read_lag and written >= written_lag\n and time >= $__timeFrom()::timestamptz\ngroup by 1\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "temp_blks_written"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "$rate_unit"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "queryid",
+ "operator": "=~",
+ "value": "/^$queryid$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "5m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean",
+ "max",
+ "min"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "binBps",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "showValues": false,
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-7": {
+ "kind": "Panel",
+ "spec": {
+ "id": 7,
+ "title": "Backend block Read/Write time",
+ "description": "FYI - blk_write_time can easily be 0 as normally changes happen only in the shared buffers and are written out by the checkpointer / background writer.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "blk_read_time",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "queryid"
+ ],
+ "type": "tag"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "stat_statements",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "with baseline as (\n select time\n from stat_statements\n where dbname = '$dbname'\n and tag_data @> '{\"queryid\": \"$queryid\"}'\n and time < $__timeFrom()::timestamptz\n order by time desc\n limit 1\n)\nselect\n $__timeGroup(time, $agg_interval),\n sum(read - read_lag) / nullif(extract(epoch from sum(time - time_lag)), 0) as \"blk_read_time\",\n sum(write - write_lag) / nullif(extract(epoch from sum(time - time_lag)), 0) as \"blk_write_time\"\nfrom (\n select\n (data->>'blk_read_time')::numeric as read, lag((data->>'blk_read_time')::numeric) over w as read_lag,\n (data->>'blk_write_time')::numeric as write, lag((data->>'blk_write_time')::numeric) over w as write_lag,\n time, lag(time) over w as time_lag\n from stat_statements\n where dbname = '$dbname'\n and tag_data @> '{\"queryid\": \"$queryid\"}'\n and time <= $__timeTo()::timestamptz\n and time >= coalesce((select time from baseline), $__timeFrom()::timestamptz)\n window w as (order by time)\n) x\nwhere read >= read_lag and write >= write_lag\n and time >= $__timeFrom()::timestamptz\ngroup by 1\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "blk_read_time"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "$rate_unit"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "queryid",
+ "operator": "=~",
+ "value": "/^$queryid$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "5m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "desc"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "ms/s",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "showValues": false,
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-8": {
+ "kind": "Panel",
+ "spec": {
+ "id": 8,
+ "title": "% of total_time spent in direct IO ($agg_interval avg.)",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "io_time_pct",
+ "editorMode": "code",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "with baseline as (\n select time\n from stat_statements\n where dbname = '$dbname'\n and tag_data @> '{\"queryid\": \"$queryid\"}'\n and time < $__timeFrom()::timestamptz\n order by time desc\n limit 1\n)\nselect\n $__timeGroup(time, $agg_interval),\n avg(case when tt = tt_lag then null else (read - read_lag + write - write_lag)::numeric * 100 / nullif(tt - tt_lag, 0) end) as \"io_time_pct\"\nfrom (\n select\n (data->>'blk_read_time')::numeric as read, lag((data->>'blk_read_time')::numeric) over w as read_lag,\n (data->>'blk_write_time')::numeric as write, lag((data->>'blk_write_time')::numeric) over w as write_lag,\n (data->>'total_time')::numeric as tt, lag((data->>'total_time')::numeric) over w as tt_lag,\n time\n from stat_statements\n where dbname = '$dbname'\n and tag_data @> '{\"queryid\": \"$queryid\"}'\n and time <= $__timeTo()::timestamptz\n and time >= coalesce((select time from baseline), $__timeFrom()::timestamptz)\n window w as (order by time)\n) x\nwhere read >= read_lag and write >= write_lag\n and time >= $__timeFrom()::timestamptz\ngroup by 1\norder by 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "5m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean",
+ "max",
+ "min"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "percent",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": 0,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "showValues": false,
+ "spanNulls": 3600000,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-9": {
+ "kind": "Panel",
+ "spec": {
+ "id": 9,
+ "title": "",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "text",
+ "version": "12.3.1",
+ "spec": {
+ "options": {
+ "code": {
+ "language": "plaintext",
+ "showLineNumbers": false,
+ "showMiniMap": false
+ },
+ "content": "### Brought to you by\n\n[](https://www.cybertec-postgresql.com/en/)\n",
+ "mode": "markdown"
+ },
+ "fieldConfig": {
+ "defaults": {},
+ "overrides": []
+ }
+ }
+ },
+ "transparent": true
+ }
+ }
+ },
+ "layout": {
+ "kind": "GridLayout",
+ "spec": {
+ "items": [
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 0,
+ "width": 24,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-1"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 5,
+ "width": 24,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-2"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 10,
+ "width": 12,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-3"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 12,
+ "y": 10,
+ "width": 12,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-4"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 17,
+ "width": 12,
+ "height": 6,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-11"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 12,
+ "y": 17,
+ "width": 12,
+ "height": 6,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-5"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 23,
+ "width": 12,
+ "height": 6,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-6"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 12,
+ "y": 23,
+ "width": 12,
+ "height": 6,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-10"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 29,
+ "width": 24,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-7"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 34,
+ "width": 24,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-8"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 39,
+ "width": 11,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-9"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "links": [],
+ "liveNow": false,
+ "preload": false,
+ "tags": [
+ "pgwatch"
+ ],
+ "timeSettings": {
+ "timezone": "browser",
+ "from": "now-6h",
+ "to": "now",
+ "autoRefresh": "",
+ "autoRefreshIntervals": [
+ "5s",
+ "10s",
+ "30s",
+ "1m",
+ "5m",
+ "15m",
+ "30m",
+ "1h",
+ "2h",
+ "1d"
+ ],
+ "hideTimepicker": false,
+ "fiscalYearStartMonth": 0
+ },
+ "title": "Single query details",
+ "variables": [
+ {
+ "kind": "QueryVariable",
+ "spec": {
+ "name": "dbname",
+ "current": {
+ "text": "",
+ "value": ""
+ },
+ "label": "Database",
+ "hide": "dontHide",
+ "refresh": "onDashboardLoad",
+ "skipUrlSync": false,
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "__legacyStringValue": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'stat_statements' ORDER BY 1;"
+ }
+ },
+ "regex": "",
+ "sort": "disabled",
+ "definition": "",
+ "options": [],
+ "multi": false,
+ "includeAll": false,
+ "allowCustomValue": true
+ }
+ },
+ {
+ "kind": "TextVariable",
+ "spec": {
+ "name": "queryid",
+ "current": {
+ "text": "",
+ "value": ""
+ },
+ "query": "",
+ "label": "Query ID",
+ "hide": "dontHide",
+ "skipUrlSync": false
+ }
+ },
+ {
+ "kind": "IntervalVariable",
+ "spec": {
+ "name": "agg_interval",
+ "query": "3m,6m,9m,12m,15m,30m",
+ "current": {
+ "text": "3m",
+ "value": "3m"
+ },
+ "options": [
+ {
+ "selected": true,
+ "text": "3m",
+ "value": "3m"
+ },
+ {
+ "selected": false,
+ "text": "6m",
+ "value": "6m"
+ },
+ {
+ "selected": false,
+ "text": "9m",
+ "value": "9m"
+ },
+ {
+ "selected": false,
+ "text": "12m",
+ "value": "12m"
+ },
+ {
+ "selected": false,
+ "text": "15m",
+ "value": "15m"
+ },
+ {
+ "selected": false,
+ "text": "30m",
+ "value": "30m"
+ }
+ ],
+ "auto": false,
+ "auto_min": "10s",
+ "auto_count": 30,
+ "refresh": "onTimeRangeChanged",
+ "label": "Agg Interval",
+ "hide": "dontHide",
+ "skipUrlSync": false
+ }
+ },
+ {
+ "kind": "QueryVariable",
+ "spec": {
+ "name": "sql_text",
+ "current": {
+ "text": "",
+ "value": ""
+ },
+ "hide": "hideVariable",
+ "refresh": "onDashboardLoad",
+ "skipUrlSync": false,
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "__legacyStringValue": "select tag_data->>'query'\nfrom stat_statements\nwhere dbname = '$dbname'\n and tag_data @> '{\"queryid\": \"$queryid\"}'\norder by time desc\nlimit 1"
+ }
+ },
+ "regex": "",
+ "sort": "disabled",
+ "definition": "select tag_data->>'query'\nfrom stat_statements\nwhere dbname = '$dbname'\n and tag_data @> '{\"queryid\": \"$queryid\"}'\norder by time desc\nlimit 1",
+ "options": [],
+ "multi": false,
+ "includeAll": false,
+ "allowCustomValue": false
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/grafana/postgres/v13/sproc-details.json b/grafana/postgres/v13/sproc-details.json
new file mode 100644
index 0000000000..7e7f77aa92
--- /dev/null
+++ b/grafana/postgres/v13/sproc-details.json
@@ -0,0 +1,637 @@
+{
+ "apiVersion": "dashboard.grafana.app/v2",
+ "kind": "Dashboard",
+ "metadata": {
+ "name": "sproc-details"
+ },
+ "spec": {
+ "annotations": [
+ {
+ "kind": "AnnotationQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "grafana"
+ },
+ "spec": {}
+ },
+ "enable": true,
+ "hide": true,
+ "iconColor": "rgba(0, 211, 255, 1)",
+ "name": "Annotations & Alerts",
+ "builtIn": true,
+ "legacyOptions": {
+ "type": "dashboard"
+ }
+ }
+ }
+ ],
+ "cursorSync": "Off",
+ "editable": true,
+ "elements": {
+ "panel-1": {
+ "kind": "Panel",
+ "spec": {
+ "id": 1,
+ "title": "Calls ($agg_interval aggregate)",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "calls",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "sproc_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "SELECT\n time,\n sum(calls - calls_lag) as calls\nFROM (\nSELECT\n $__timeGroup(time, $agg_interval),\n (data->>'sp_calls')::int8 as calls,\n lag((data->>'sp_calls')::int8) OVER(order by time) as calls_lag\nFROM\n sproc_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n AND tag_data @> '{\"function_full_name\": \"$sproc_name\"}'\n) x\nWHERE calls >= calls_lag\nGROUP BY 1\nORDER BY 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "sp_calls"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "1h"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$dbname$/"
+ },
+ {
+ "condition": "AND",
+ "key": "function_full_name",
+ "operator": "=~",
+ "value": "/^$sproc_name$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "2m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "short",
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-2": {
+ "kind": "Panel",
+ "spec": {
+ "id": 2,
+ "title": "Avg. runtime ($agg_interval avg.)",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "alias": "total_time",
+ "format": "time_series",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "auto"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "sproc_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n avg( case when calls = calls_lag then null else (total_time - total_time_lag) / (calls - calls_lag) end) as total_time,\n avg( case when calls = calls_lag then null else (self_time - self_time_lag) / (calls - calls_lag) end) as self_time\nFROM (\n SELECT\n (data->>'sp_calls')::int8 as calls, lag((data->>'sp_calls')::int8) over w as calls_lag,\n (data->>'self_time')::float as self_time, lag((data->>'self_time')::float) over w as self_time_lag,\n (data->>'total_time')::float as total_time, lag((data->>'total_time')::float) over w as total_time_lag,\n time, lag(time) over w as time_lag\n FROM\n sproc_stats\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n AND tag_data @> jsonb_build_object('function_full_name', '$sproc_name')\n WINDOW w AS (order by time)\n) x\nWHERE time > time_lag AND calls >= calls_lag\nGROUP BY 1\nORDER BY 1",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "total_time"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ },
+ {
+ "params": [
+ "1h"
+ ],
+ "type": "non_negative_derivative"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "dbname",
+ "operator": "=~",
+ "value": "/^$dbname$/"
+ },
+ {
+ "condition": "AND",
+ "key": "function_full_name",
+ "operator": "=~",
+ "value": "/^$sproc_name$/"
+ }
+ ],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [],
+ "queryOptions": {
+ "interval": "2m"
+ }
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "timeseries",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "alertThreshold": true,
+ "legend": {
+ "calcs": [
+ "mean"
+ ],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "hideZeros": false,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "fieldConfig": {
+ "defaults": {
+ "unit": "ms",
+ "decimals": 3,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "barAlignment": 0,
+ "barWidthFactor": 0.6,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ }
+ },
+ "overrides": []
+ }
+ }
+ }
+ }
+ },
+ "panel-3": {
+ "kind": "Panel",
+ "spec": {
+ "id": 3,
+ "title": "",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "text",
+ "version": "12.1.0",
+ "spec": {
+ "options": {
+ "code": {
+ "language": "plaintext",
+ "showLineNumbers": false,
+ "showMiniMap": false
+ },
+ "content": "### Brought to you by\n\n[](https://www.cybertec-postgresql.com/en/)\n",
+ "mode": "markdown"
+ },
+ "fieldConfig": {
+ "defaults": {},
+ "overrides": []
+ }
+ }
+ },
+ "transparent": true
+ }
+ }
+ },
+ "layout": {
+ "kind": "GridLayout",
+ "spec": {
+ "items": [
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 0,
+ "width": 24,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-1"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 7,
+ "width": 24,
+ "height": 7,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-2"
+ }
+ }
+ },
+ {
+ "kind": "GridLayoutItem",
+ "spec": {
+ "x": 0,
+ "y": 14,
+ "width": 12,
+ "height": 5,
+ "element": {
+ "kind": "ElementReference",
+ "name": "panel-3"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "links": [],
+ "liveNow": false,
+ "preload": false,
+ "tags": [
+ "pgwatch"
+ ],
+ "timeSettings": {
+ "timezone": "browser",
+ "from": "now-3h",
+ "to": "now",
+ "autoRefresh": "",
+ "autoRefreshIntervals": [
+ "5s",
+ "10s",
+ "30s",
+ "1m",
+ "5m",
+ "15m",
+ "30m",
+ "1h",
+ "2h",
+ "1d"
+ ],
+ "hideTimepicker": false,
+ "fiscalYearStartMonth": 0
+ },
+ "title": "Sproc details",
+ "variables": [
+ {
+ "kind": "QueryVariable",
+ "spec": {
+ "name": "dbname",
+ "current": {
+ "text": "",
+ "value": ""
+ },
+ "hide": "dontHide",
+ "refresh": "onDashboardLoad",
+ "skipUrlSync": false,
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "__legacyStringValue": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics WHERE metric = 'sproc_stats' ORDER BY 1;"
+ }
+ },
+ "regex": "",
+ "sort": "disabled",
+ "definition": "",
+ "options": [],
+ "multi": false,
+ "includeAll": false,
+ "allowCustomValue": true
+ }
+ },
+ {
+ "kind": "QueryVariable",
+ "spec": {
+ "name": "sproc_name",
+ "current": {
+ "text": "",
+ "value": ""
+ },
+ "hide": "dontHide",
+ "refresh": "onDashboardLoad",
+ "skipUrlSync": false,
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "__legacyStringValue": "select distinct tag_data->>'function_full_name' from sproc_stats where time > current_date-7 and dbname = '$dbname' and tag_data ? 'function_full_name' order by 1;"
+ }
+ },
+ "regex": "",
+ "sort": "disabled",
+ "definition": "select distinct tag_data->>'function_full_name' from sproc_stats where time > current_date-7 and dbname = '$dbname' and tag_data ? 'function_full_name' order by 1;",
+ "options": [],
+ "multi": false,
+ "includeAll": false,
+ "allowCustomValue": true
+ }
+ },
+ {
+ "kind": "IntervalVariable",
+ "spec": {
+ "name": "agg_interval",
+ "query": "1m,5m,10m,15m,30m,1h,6h,12h,1d",
+ "current": {
+ "text": "10m",
+ "value": "10m"
+ },
+ "options": [
+ {
+ "selected": false,
+ "text": "1m",
+ "value": "1m"
+ },
+ {
+ "selected": false,
+ "text": "5m",
+ "value": "5m"
+ },
+ {
+ "selected": true,
+ "text": "10m",
+ "value": "10m"
+ },
+ {
+ "selected": false,
+ "text": "15m",
+ "value": "15m"
+ },
+ {
+ "selected": false,
+ "text": "30m",
+ "value": "30m"
+ },
+ {
+ "selected": false,
+ "text": "1h",
+ "value": "1h"
+ },
+ {
+ "selected": false,
+ "text": "6h",
+ "value": "6h"
+ },
+ {
+ "selected": false,
+ "text": "12h",
+ "value": "12h"
+ },
+ {
+ "selected": false,
+ "text": "1d",
+ "value": "1d"
+ }
+ ],
+ "auto": false,
+ "auto_min": "10s",
+ "auto_count": 30,
+ "refresh": "onTimeRangeChanged",
+ "hide": "dontHide",
+ "skipUrlSync": false
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/grafana/postgres/v13/sprocs-top.json b/grafana/postgres/v13/sprocs-top.json
new file mode 100644
index 0000000000..2281012fb2
--- /dev/null
+++ b/grafana/postgres/v13/sprocs-top.json
@@ -0,0 +1,1503 @@
+{
+ "apiVersion": "dashboard.grafana.app/v2",
+ "kind": "Dashboard",
+ "metadata": {
+ "name": "top-sprocs"
+ },
+ "spec": {
+ "annotations": [
+ {
+ "kind": "AnnotationQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "grafana"
+ },
+ "spec": {}
+ },
+ "enable": true,
+ "hide": true,
+ "iconColor": "rgba(0, 211, 255, 1)",
+ "name": "Annotations & Alerts",
+ "builtIn": true,
+ "legacyOptions": {
+ "type": "dashboard"
+ }
+ }
+ }
+ ],
+ "cursorSync": "Off",
+ "editable": true,
+ "elements": {
+ "panel-2": {
+ "kind": "Panel",
+ "spec": {
+ "id": 2,
+ "title": "By Total Runtime",
+ "description": "As per \"sproc_stats\" measurement. Needs track_functions parameter set to 'pl' on monitored DBs.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "sproc_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "SELECT top(\"spread\", \"function_full_name\", \"oid\", $top) FROM (SELECT spread(\"total_time\") FROM \"sproc_stats\" WHERE $timeFilter AND \"dbname\" = '$dbname' GROUP BY time(3650d), \"function_full_name\", \"oid\" fill(none) ) WHERE spread > 0",
+ "rawQuery": true,
+ "rawSql": "SELECT\n max((data->>'total_time')::float8) - min((data->>'total_time')::float8) as top,\n max((data->>'sp_calls')::int8) - min((data->>'sp_calls')::int8) as calls,\n tag_data->>'function_full_name' as function_full_name,\n tag_data->>'oid' as oid\nFROM\n sproc_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 3, 4\nORDER BY 1 DESC NULLS LAST\nLIMIT $top",
+ "resultFormat": "table",
+ "select": [
+ [
+ {
+ "params": [
+ "total_time"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "footer": {
+ "countRows": false,
+ "fields": "",
+ "reducer": [
+ "sum"
+ ],
+ "show": false
+ },
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Time"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Time"
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "top"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "total_runtime"
+ },
+ {
+ "id": "unit",
+ "value": "ms"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "function_full_name"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": true,
+ "title": "Opens 'Sproc details' dashboard for that sproc",
+ "url": "/d/sproc-details?var-dbname=$dbname&var-sproc_name=$__value&from=$__from&to=$__to"
+ }
+ ]
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "calls"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "oid"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-3": {
+ "kind": "Panel",
+ "spec": {
+ "id": 3,
+ "title": "By Avg. Runtime",
+ "description": "As per \"sproc_stats\" measurement. Needs track_functions parameter set to 'pl' on monitored DBs.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "sproc_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "select top(avg, \"function_full_name\", \"oid\", $top) AS top from (select mean(t) / mean(c) AS avg from (SELECT spread(\"total_time\") AS t, spread(\"sp_calls\") AS c FROM \"sproc_stats\" WHERE $timeFilter AND dbname = '$dbname' GROUP BY time(3650d), \"function_full_name\", \"oid\" fill(none) ) where $timeFilter AND c > 0 group by time(3650d), \"function_full_name\", \"oid\" )",
+ "rawQuery": true,
+ "rawSql": "SELECT\n total_time / calls as top,\n calls,\n function_full_name,\n oid\nFROM (\n SELECT\n tag_data->>'function_full_name' as function_full_name,\n tag_data->>'oid' as oid,\n max((data->>'total_time')::float8) - min((data->>'total_time')::float8) as total_time,\n max((data->>'sp_calls')::int8) - min((data->>'sp_calls')::int8) as calls\n FROM\n sproc_stats\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n GROUP BY 1, 2\n) x\nWHERE calls > 0\nORDER BY 1 DESC NULLS LAST\nLIMIT $top",
+ "resultFormat": "table",
+ "select": [
+ [
+ {
+ "params": [
+ "total_time"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "footer": {
+ "countRows": false,
+ "fields": "",
+ "reducer": [
+ "sum"
+ ],
+ "show": false
+ },
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Time"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Time"
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "top"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "avg_runtime"
+ },
+ {
+ "id": "unit",
+ "value": "ms"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "function_full_name"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": true,
+ "title": "Opens 'Sproc details' dashboard for that sproc",
+ "url": "/d/sproc-details?var-dbname=$dbname&var-sproc_name=$__value&from=$__from&to=$__to"
+ }
+ ]
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "calls"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "oid"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-4": {
+ "kind": "Panel",
+ "spec": {
+ "id": 4,
+ "title": "By Calls",
+ "description": "As per \"sproc_stats\" measurement. Needs track_functions parameter set to 'pl' on monitored DBs.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "sproc_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "SELECT top(\"spread\", \"function_full_name\", \"oid\", $top) FROM (SELECT spread(\"sp_calls\") FROM \"sproc_stats\" WHERE $timeFilter AND \"dbname\" = '$dbname' GROUP BY time(3650d), \"function_full_name\", \"oid\" fill(none) ) WHERE spread > 0",
+ "rawQuery": true,
+ "rawSql": "SELECT\n max((data->>'sp_calls')::int8) - min((data->>'sp_calls')::int8) as top,\n max((data->>'total_time')::float8) - min((data->>'total_time')::float8) as total_time,\n tag_data->>'function_full_name' as function_full_name,\n tag_data->>'oid' as oid\nFROM\n sproc_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 3, 4\nORDER BY 1 DESC NULLS LAST\nLIMIT $top",
+ "resultFormat": "table",
+ "select": [
+ [
+ {
+ "params": [
+ "total_time"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "footer": {
+ "countRows": false,
+ "fields": "",
+ "reducer": [
+ "sum"
+ ],
+ "show": false
+ },
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Time"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Time"
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "top"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "calls"
+ },
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "function_full_name"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": true,
+ "title": "Opens 'Sproc details' dashboard for that sproc",
+ "url": "/d/sproc-details?var-dbname=$dbname&var-sproc_name=$__value&from=$__from&to=$__to"
+ }
+ ]
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "total_time"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "ms"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "oid"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-5": {
+ "kind": "Panel",
+ "spec": {
+ "id": 5,
+ "title": "By Total Self Runtime",
+ "description": "As per \"sproc_stats\" measurement. Needs track_functions parameter set to 'pl' on monitored DBs.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "sproc_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "SELECT top(\"spread\", \"function_full_name\", \"oid\", $top) FROM (SELECT spread(\"self_time\") FROM \"sproc_stats\" WHERE $timeFilter AND \"dbname\" = '$dbname' GROUP BY time(3650d), \"function_full_name\", \"oid\" fill(none) ) WHERE spread > 0",
+ "rawQuery": true,
+ "rawSql": "SELECT\n max((data->>'self_time')::float8) - min((data->>'self_time')::float8) as top,\n max((data->>'sp_calls')::int8) - min((data->>'sp_calls')::int8) as calls, \n tag_data->>'function_full_name' as function_full_name,\n tag_data->>'oid' as oid\nFROM\n sproc_stats\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 3, 4\nORDER BY 1 DESC NULLS LAST\nLIMIT $top",
+ "resultFormat": "table",
+ "select": [
+ [
+ {
+ "params": [
+ "total_time"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "footer": {
+ "countRows": false,
+ "fields": "",
+ "reducer": [
+ "sum"
+ ],
+ "show": false
+ },
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Time"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Time"
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "top"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "total_runtime"
+ },
+ {
+ "id": "unit",
+ "value": "ms"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "function_full_name"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": true,
+ "title": "Opens 'Sproc details' dashboard for that sproc",
+ "url": "/d/sproc-details?var-dbname=$dbname&var-sproc_name=$__value&from=$__from&to=$__to"
+ }
+ ]
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "calls"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "oid"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-6": {
+ "kind": "Panel",
+ "spec": {
+ "id": 6,
+ "title": "By Avg. Self Runtime",
+ "description": "As per \"sproc_stats\" measurement. Needs track_functions parameter set to 'pl' on monitored DBs.",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [
+ {
+ "kind": "PanelQuery",
+ "spec": {
+ "query": {
+ "kind": "DataQuery",
+ "group": "grafana-postgresql-datasource",
+ "version": "v0",
+ "datasource": {
+ "name": "pgwatch-metrics"
+ },
+ "spec": {
+ "format": "table",
+ "group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "sproc_stats",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "select top(avg, \"function_full_name\", \"oid\", $top) AS top from (select mean(t) / mean(c) AS avg from (SELECT spread(\"self_time\") AS t, spread(\"sp_calls\") AS c FROM \"sproc_stats\" WHERE $timeFilter AND dbname = '$dbname' GROUP BY time(3650d), \"function_full_name\", \"oid\" fill(none) ) where $timeFilter AND c > 0 group by time(3650d), \"function_full_name\", \"oid\" )",
+ "rawQuery": true,
+ "rawSql": "SELECT\n total_time / calls as top,\n calls,\n function_full_name,\n oid\nFROM (\n SELECT\n tag_data->>'function_full_name' as function_full_name,\n tag_data->>'oid' as oid,\n max((data->>'self_time')::float8) - min((data->>'self_time')::float8) as total_time,\n max((data->>'sp_calls')::int8) - min((data->>'sp_calls')::int8) as calls\n FROM\n sproc_stats\n WHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\n GROUP BY 1, 2\n) x\nWHERE calls > 0\nORDER BY 1 DESC NULLS LAST\nLIMIT $top",
+ "resultFormat": "table",
+ "select": [
+ [
+ {
+ "params": [
+ "total_time"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
+ }
+ ]
+ ],
+ "tags": [],
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ },
+ "refId": "A",
+ "hidden": false
+ }
+ }
+ ],
+ "transformations": [
+ {
+ "kind": "Transformation",
+ "group": "merge",
+ "spec": {
+ "options": {
+ "reducers": []
+ }
+ }
+ }
+ ],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "table",
+ "version": "12.0.0",
+ "spec": {
+ "options": {
+ "cellHeight": "sm",
+ "footer": {
+ "countRows": false,
+ "fields": "",
+ "reducer": [
+ "sum"
+ ],
+ "show": false
+ },
+ "showHeader": true
+ },
+ "fieldConfig": {
+ "defaults": {
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "value": null,
+ "color": "green"
+ },
+ {
+ "value": 80,
+ "color": "red"
+ }
+ ]
+ },
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "align": "auto",
+ "cellOptions": {
+ "type": "auto"
+ },
+ "inspect": false
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Time"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Time"
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "top"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "avg_runtime"
+ },
+ {
+ "id": "unit",
+ "value": "ms"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "function_full_name"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "links",
+ "value": [
+ {
+ "targetBlank": true,
+ "title": "Opens 'Sproc details' dashboard for that sproc",
+ "url": "/d/sproc-details?var-dbname=$dbname&var-sproc_name=$__value&from=$__from&to=$__to"
+ }
+ ]
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "calls"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 1
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "oid"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "short"
+ },
+ {
+ "id": "decimals",
+ "value": 2
+ },
+ {
+ "id": "custom.align"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "panel-8": {
+ "kind": "Panel",
+ "spec": {
+ "id": 8,
+ "title": "",
+ "description": "",
+ "links": [],
+ "data": {
+ "kind": "QueryGroup",
+ "spec": {
+ "queries": [],
+ "transformations": [],
+ "queryOptions": {}
+ }
+ },
+ "vizConfig": {
+ "kind": "VizConfig",
+ "group": "text",
+ "version": "10.4.1",
+ "spec": {
+ "options": {
+ "code": {
+ "language": "plaintext",
+ "showLineNumbers": false,
+ "showMiniMap": false
+ },
+ "content": "