Skip to content

Commit 1404fa2

Browse files
author
Dementii Priadko
committed
Merge branch 'pg_index_pilot_monitoring' into 'main'
pg_index_pilot monitoring support See merge request postgres-ai/postgres_ai!48
2 parents 9ad6e3f + d2853ed commit 1404fa2

File tree

2 files changed

+253
-1
lines changed

2 files changed

+253
-1
lines changed
Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
{
2+
"annotations": {
3+
"list": [
4+
{
5+
"builtIn": 1,
6+
"datasource": {
7+
"type": "grafana",
8+
"uid": "-- Grafana --"
9+
},
10+
"enable": true,
11+
"hide": true,
12+
"iconColor": "rgba(0, 211, 255, 1)",
13+
"name": "Annotations & Alerts",
14+
"type": "dashboard"
15+
}
16+
]
17+
},
18+
"editable": true,
19+
"fiscalYearStartMonth": 0,
20+
"graphTooltip": 0,
21+
"id": 10,
22+
"links": [],
23+
"panels": [
24+
{
25+
"datasource": {
26+
"type": "prometheus",
27+
"uid": "P7A0D6631BB10B34F"
28+
},
29+
"fieldConfig": {
30+
"defaults": {
31+
"color": {
32+
"mode": "palette-classic"
33+
},
34+
"custom": {
35+
"axisBorderShow": false,
36+
"axisCenteredZero": false,
37+
"axisColorMode": "text",
38+
"axisLabel": "",
39+
"axisPlacement": "auto",
40+
"barAlignment": 0,
41+
"barWidthFactor": 0.6,
42+
"drawStyle": "line",
43+
"fillOpacity": 0,
44+
"gradientMode": "none",
45+
"hideFrom": {
46+
"legend": false,
47+
"tooltip": false,
48+
"viz": false
49+
},
50+
"insertNulls": false,
51+
"lineInterpolation": "linear",
52+
"lineWidth": 1,
53+
"pointSize": 1,
54+
"scaleDistribution": {
55+
"type": "linear"
56+
},
57+
"showPoints": "auto",
58+
"spanNulls": false,
59+
"stacking": {
60+
"group": "A",
61+
"mode": "none"
62+
},
63+
"thresholdsStyle": {
64+
"mode": "off"
65+
}
66+
},
67+
"mappings": [],
68+
"thresholds": {
69+
"mode": "absolute",
70+
"steps": [
71+
{
72+
"color": "green"
73+
},
74+
{
75+
"color": "red",
76+
"value": 80
77+
}
78+
]
79+
}
80+
},
81+
"overrides": [
82+
{
83+
"matcher": {
84+
"id": "byName",
85+
"options": "Baseline Boguk ratio"
86+
},
87+
"properties": [
88+
{
89+
"id": "custom.lineStyle",
90+
"value": {
91+
"dash": [
92+
10,
93+
10
94+
],
95+
"fill": "dash"
96+
}
97+
},
98+
{
99+
"id": "color",
100+
"value": {
101+
"fixedColor": "dark-red",
102+
"mode": "fixed"
103+
}
104+
}
105+
]
106+
},
107+
{
108+
"matcher": {
109+
"id": "byName",
110+
"options": "Boguk ratio"
111+
},
112+
"properties": [
113+
{
114+
"id": "color",
115+
"value": {
116+
"fixedColor": "green",
117+
"mode": "fixed"
118+
}
119+
}
120+
]
121+
}
122+
]
123+
},
124+
"gridPos": {
125+
"h": 18,
126+
"w": 24,
127+
"x": 0,
128+
"y": 0
129+
},
130+
"id": 1,
131+
"options": {
132+
"legend": {
133+
"calcs": [],
134+
"displayMode": "table",
135+
"placement": "bottom",
136+
"showLegend": true
137+
},
138+
"tooltip": {
139+
"hideZeros": false,
140+
"mode": "single",
141+
"sort": "none"
142+
}
143+
},
144+
"pluginVersion": "12.0.2",
145+
"targets": [
146+
{
147+
"datasource": {
148+
"type": "prometheus",
149+
"uid": "P7A0D6631BB10B34F"
150+
},
151+
"editorMode": "code",
152+
"expr": "pgwatch_pg_index_pilot_index_size_bytes{indexrelname=\"$index_name\", schemaname=\"$schema_name\"}/pgwatch_pg_index_pilot_estimated_tuples{indexrelname=\"$index_name\", schemaname=\"$schema_name\"}",
153+
"interval": "",
154+
"legendFormat": "Current Boguk ratio",
155+
"range": true,
156+
"refId": "A"
157+
},
158+
{
159+
"datasource": {
160+
"type": "prometheus",
161+
"uid": "P7A0D6631BB10B34F"
162+
},
163+
"editorMode": "code",
164+
"expr": "pgwatch_pg_index_pilot_best_ratio{indexrelname=\"$index_name\", schemaname=\"$schema_name\"}",
165+
"hide": false,
166+
"instant": false,
167+
"legendFormat": "Best ratio",
168+
"range": true,
169+
"refId": "B"
170+
}
171+
],
172+
"title": "",
173+
"type": "timeseries"
174+
}
175+
],
176+
"preload": false,
177+
"schemaVersion": 41,
178+
"tags": [],
179+
"templating": {
180+
"list": [
181+
{
182+
"current": {
183+
"text": "",
184+
"value": ""
185+
},
186+
"definition": "label_values(pgwatch_pg_index_pilot_estimated_tuples,schemaname)",
187+
"name": "schema_name",
188+
"options": [],
189+
"query": {
190+
"qryType": 1,
191+
"query": "label_values(pgwatch_pg_index_pilot_estimated_tuples,schemaname)",
192+
"refId": "PrometheusVariableQueryEditor-VariableQuery"
193+
},
194+
"refresh": 1,
195+
"regex": "",
196+
"type": "query"
197+
},
198+
{
199+
"current": {
200+
"text": "",
201+
"value": ""
202+
},
203+
"definition": "label_values(pgwatch_pg_index_pilot_estimated_tuples{schemaname=\"$schema_name\"},indexrelname)",
204+
"name": "index_name",
205+
"options": [],
206+
"query": {
207+
"qryType": 1,
208+
"query": "label_values(pgwatch_pg_index_pilot_estimated_tuples{schemaname=\"$schema_name\"},indexrelname)",
209+
"refId": "PrometheusVariableQueryEditor-VariableQuery"
210+
},
211+
"refresh": 1,
212+
"regex": "",
213+
"type": "query"
214+
}
215+
]
216+
},
217+
"time": {
218+
"from": "now-5m",
219+
"to": "now"
220+
},
221+
"timepicker": {},
222+
"timezone": "browser",
223+
"title": "Index Pilot",
224+
"uid": "aa0128c5-c5a0-4418-a99e-c941af10426e",
225+
"version": 5
226+
}

config/pgwatch-prometheus/metrics.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1912,6 +1912,29 @@ metrics:
19121912
join pg_namespace N on (N.oid = C.relnamespace)
19131913
gauges:
19141914
- '*'
1915+
pg_index_pilot:
1916+
sqls:
1917+
11: |
1918+
select
1919+
(extract(epoch from now()) * 1e9)::int8 as epoch_ns,
1920+
current_database() as tag_datname,
1921+
database_name as tag_database_name,
1922+
datname as tag_datname,
1923+
schemaname as tag_schemaname,
1924+
relname as tag_relname,
1925+
indexrelname as tag_indexrelname,
1926+
indexsize as index_size_bytes,
1927+
indisvalid::int as is_valid,
1928+
estimated_tuples,
1929+
best_ratio
1930+
from index_pilot.index_current_state
1931+
order by indexsize desc
1932+
limit 2000;
1933+
gauges:
1934+
- index_size_bytes
1935+
- is_valid
1936+
- estimated_tuples
1937+
- best_ratio
19151938

19161939
presets:
19171940
full:
@@ -1949,4 +1972,7 @@ presets:
19491972
unused_indexes: 7200
19501973
rarely_used_indexes: 10800
19511974
archive_lag: 15
1952-
pg_vacuum_progress: 30
1975+
pg_vacuum_progress: 30
1976+
pg_index_pilot:
1977+
metrics:
1978+
pg_index_pilot: 30

0 commit comments

Comments
 (0)