Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 81 additions & 8 deletions grafana/postgres/v12/0-health-check.json
Original file line number Diff line number Diff line change
Expand Up @@ -5115,24 +5115,97 @@
"type": "stat"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "pgwatch-metrics"
},
"description": "Total size of user indexes for the selected DB. requires db_size metric.",
"fieldConfig": {
"defaults": {},
"defaults": {
"decimals": 1,
"mappings": [],
"thresholds": {},
"unit": "bytes"
},
"overrides": []
},
"gridPos": {
"h": 2,
"w": 12,
"w": 6,
"x": 12,
"y": 18
},
"id": 48,
"id": 51,
"maxDataPoints": 100,
"options": {
"colorMode": "none",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "horizontal",
"percentChangeColorMode": "standard",
"reduceOptions": {
"calcs": [],
"fields": "",
"values": false
},
"showPercentChange": false,
"textMode": "auto",
"wideLayout": true
},
"pluginVersion": "12.1.0",
"targets": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "pgwatch-metrics"
},
"editorMode": "code",
"format": "table",
"group": [],
"groupBy": [],
"measurement": "db_size",
"metricColumn": "none",
"orderByTime": "ASC",
"policy": "default",
"rawQuery": true,
"rawSql": "SELECT\n (data->>'indexes_size_b')::int8\nFROM\n db_size\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nORDER BY time DESC\nLIMIT 1",
"refId": "A",
"resultFormat": "time_series",
"select": [],
"sql": {},
"tags": [],
"timeColumn": "time",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
}
]
}
],
"title": "Total index size",
"type": "stat"
},
{
"fieldConfig": {
"defaults": {},
"overrides": []
},
"gridPos": {
"h": 7,
"w": 12,
"x": 0,
"y": 20
},
"id": 12,
"options": {
"code": {
"language": "plaintext",
"showLineNumbers": false,
"showMiniMap": false
},
"content": "### The preset threshold values (green / yellow / red) should be reviewed / adjusted!",
"content": "### Brought to you by\n\n[![Cybertec – The PostgreSQL Database Company](https://www.cybertec-postgresql.com/wp-content/uploads/2025/02/cybertec-logo-white-blue.svg)](https://www.cybertec-postgresql.com/en/)\n",
"mode": "markdown"
},
"pluginVersion": "12.1.0",
Expand All @@ -5146,19 +5219,19 @@
"overrides": []
},
"gridPos": {
"h": 7,
"h": 2,
"w": 12,
"x": 0,
"x": 12,
"y": 20
},
"id": 12,
"id": 48,
"options": {
"code": {
"language": "plaintext",
"showLineNumbers": false,
"showMiniMap": false
},
"content": "### Brought to you by\n\n[![Cybertec – The PostgreSQL Database Company](https://www.cybertec-postgresql.com/wp-content/uploads/2025/02/cybertec-logo-white-blue.svg)](https://www.cybertec-postgresql.com/en/)\n",
"content": "### The preset threshold values (green / yellow / red) should be reviewed / adjusted!",
"mode": "markdown"
},
"pluginVersion": "12.1.0",
Expand Down
7 changes: 5 additions & 2 deletions internal/metrics/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,8 @@ metrics:
node_status: standby
db_size:
description: >
Retrieves the size of the current database and the size of the `pg_catalog` schema, providing insights into the storage usage of the database.
Retrieves the size of the current database, the size of the `pg_catalog` schema, and total indexes size
providing insights into the storage usage of the database.
It returns the size in bytes for both the current database and the catalog schema.
This metric helps administrators monitor database size and storage consumption.
sqls:
Expand All @@ -458,7 +459,9 @@ metrics:
(select sum(pg_total_relation_size(c.oid))::int8
from pg_class c join pg_namespace n on n.oid = c.relnamespace
where nspname = 'pg_catalog' and relkind = 'r'
) as catalog_size_b
) as catalog_size_b,
(select sum(pg_relation_size(indexrelid))::int8
from pg_stat_user_indexes) as indexes_size_b
gauges:
- '*'
statement_timeout_seconds: 300
Expand Down
Loading