Skip to content

Commit b5894eb

Browse files
pashagolub0xgouda
andcommitted
[+] improve recommendation metrics, closes #764 (#921)
* [+] improve recommendation metrics, closes #764 Refactor PostgreSQL recommendation metrics to consolidate multiple findings per metric type. The changes consolidate all 8 recommendation metrics to use an aggregation pattern that combines multiple database objects into comma-separated strings instead of separate rows, limiting results to 50 items with overflow indicators, and actionable guidance templates were added to extra_info fields. * [-] fix `metric_storage_name` properties in YAML, fixes #920 * [+] improve "Recommendations" dashboard * [-] fix object name aggregation by @0xgouda * [-] tweak recommendations for `reco_add_index` metric Latest versions of pg_qualstats return not only CREATE INDEX but affected queries array. So use CREATE INDEX as is in recommendations, and output `queryids` if available in `extra_info`. Due to long recommendation text limit concatenated output to 10 items. Reported by @0xgouda. ------ Co-authored-by: Ahmed Gouda <[email protected]>
1 parent 8ea2191 commit b5894eb

File tree

6 files changed

+336
-940
lines changed

6 files changed

+336
-940
lines changed

contrib/sample.metrics.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# is_instance_level: true
2020
# node_status: primary
2121
# statement_timeout_seconds: 300
22-
# metric_storage_name: optional_metric_storage_name
22+
# storage_name: optional_metric_storage_name
2323
# presets:
2424
# preset_name:
2525
# description: custom preset for some metrics
@@ -61,7 +61,7 @@ metrics:
6161
gauges:
6262
- '*'
6363
is_instance_level: false
64-
metric_storage_name: buffer_cache_hit_ratio
64+
storage_name: buffer_cache_hit_ratio
6565
presets:
6666
default:
6767
description: minimal example preset

docker/compose.pgwatch.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ services:
88
container_name: pgwatch
99
environment:
1010
PW_SOURCES: postgresql://pgwatch@postgres:5432/pgwatch
11+
# PW_METRICS: /etc/pgwatch/metrics.yml
1112
command:
1213
- "--sink=postgresql://pgwatch@postgres:5432/pgwatch_metrics"
1314
- "--sink=prometheus://pgwatch:9187/pgwatch"
1415
ports:
1516
- "8080:8080"
1617
- "9187:9187"
1718
# - "6060:6060" # Uncomment for profiling
19+
volumes:
20+
- "../internal/metrics/metrics.yaml:/etc/pgwatch/metrics.yml"
1821
depends_on:
1922
postgres:
2023
condition: service_healthy

docker/compose.postgres.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ services:
1111
image: &pgimage postgres-plpython3u:latest
1212
container_name: postgres
1313
command:
14-
- "-cshared_preload_libraries=pg_stat_statements"
14+
- "-cshared_preload_libraries=pg_stat_statements,pg_qualstats"
1515
- "-cpg_stat_statements.track=all"
1616
- "-cpg_stat_statements.track_planning=on"
1717
- "-ctrack_io_timing=on"

docs/reference/metric_definitions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ Here is the structure of a metric definition in YAML format:
136136
is_instance_level: true
137137
node_status: primary/standby
138138
statement_timeout_seconds: 300
139-
metric_storage_name: some_other_metric_name
139+
storage_name: some_other_metric_name
140140
```
141141
142142
- *init_sql*
@@ -199,7 +199,7 @@ Here is the structure of a metric definition in YAML format:
199199
The maximum time in seconds the metric query is allowed to run
200200
before it's killed. The default is 5 seconds.
201201

202-
- *metric_storage_name*
202+
- *storage_name*
203203

204204
Enables dynamic "renaming" of metrics at the storage level, i.e.
205205
declaring almost similar metrics with different names, but the data

0 commit comments

Comments
 (0)