postgresai 0.18.1-rc.4 → 0.18.1-rc.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13538,7 +13538,7 @@ var {
13538
13538
  // package.json
13539
13539
  var package_default = {
13540
13540
  name: "postgresai",
13541
- version: "0.18.1-rc.4",
13541
+ version: "0.18.1-rc.6",
13542
13542
  description: "postgres_ai CLI",
13543
13543
  license: "Apache-2.0",
13544
13544
  private: false,
@@ -16898,7 +16898,7 @@ var Result = import_lib.default.Result;
16898
16898
  var TypeOverrides = import_lib.default.TypeOverrides;
16899
16899
  var defaults = import_lib.default.defaults;
16900
16900
  // package.json
16901
- var version = "0.18.1-rc.4";
16901
+ var version = "0.18.1-rc.6";
16902
16902
  var package_default2 = {
16903
16903
  name: "postgresai",
16904
16904
  version,
@@ -35638,6 +35638,11 @@ var DEFAULT_POLL_INTERVAL_MS = 800;
35638
35638
  var JOE_ASYNC_FALLBACK_WAIT_MS2 = 10 * 60 * 1000;
35639
35639
  var JOE_ASYNC_MAX_WAIT_MS2 = 60 * 60 * 1000;
35640
35640
  var JOE_ASYNC_MAX_POLL_FAILURES = 5;
35641
+ var CONSOLE_URL_SAFE = /^https?:\/\/[^\s\x00-\x1f\x7f-\x9f]+$/;
35642
+ function formatJoeConsoleLine(output) {
35643
+ const url = typeof output?.console_url === "string" ? output.console_url.trim() : "";
35644
+ return CONSOLE_URL_SAFE.test(url) ? `console: ${url}` : null;
35645
+ }
35641
35646
  async function callRpc2(params) {
35642
35647
  return (await callRpcRaw2(params)).data;
35643
35648
  }
@@ -41126,7 +41131,7 @@ order by cmb.total_relation_size_b desc, cmb.schemaname, cmb.relname
41126
41131
  from
41127
41132
  pg_catalog.pg_database d
41128
41133
  where
41129
- d.datallowconn
41134
+ d.datconnlimit <> -2
41130
41135
  `
41131
41136
  },
41132
41137
  gauges: ["age_datfrozenxid", "age_datminmxid"],
@@ -44700,19 +44705,259 @@ async function generateD004(client, nodeName) {
44700
44705
  };
44701
44706
  return report;
44702
44707
  }
44708
+ var D001_SETTING_PATTERN = "^(log_.*|logging_collector|auto_explain\\..*|shared_preload_libraries|session_preload_libraries|deadlock_timeout)$";
44709
+ var D001_OVERRIDE_PATTERN = /^(log_.*|auto_explain\..*|session_preload_libraries|statement_timeout)$/;
44710
+ var D001_BASE_THRESHOLDS_MS = [1000, 1e4];
44711
+ var D001_MAX_ROLES = 60;
44712
+ var D001_SETTINGS_SQL = `
44713
+ select name, reset_val as setting, coalesce(unit, '') as unit, category, context, vartype, source,
44714
+ boot_val, pending_restart
44715
+ from pg_settings
44716
+ where name ~ $1
44717
+ order by name`;
44718
+ var D001_OVERRIDES_SQL = `
44719
+ select r.rolname as role, d.datname as database, s.setconfig as config
44720
+ from pg_db_role_setting as s
44721
+ left join pg_roles as r on r.oid = s.setrole
44722
+ left join pg_database as d on d.oid = s.setdatabase
44723
+ order by r.rolname nulls first, d.datname nulls first`;
44724
+ var D001_LOGIN_ROLES_SQL = `
44725
+ select r.rolname as role, r.rolsuper as superuser,
44726
+ coalesce((select array_agg(g.rolname::text order by g.rolname)
44727
+ from pg_auth_members as m join pg_roles as g on g.oid = m.roleid
44728
+ where m.member = r.oid), '{}') as member_of,
44729
+ count(a.pid) filter (where a.backend_type = 'client backend') as sessions,
44730
+ min(a.backend_start) filter (where a.backend_type = 'client backend') as oldest_session_start,
44731
+ (array_agg(distinct a.application_name) filter (where a.backend_type = 'client backend'
44732
+ and a.application_name <> ''))[1:5] as applications
44733
+ from pg_roles as r
44734
+ left join pg_stat_activity as a on a.usesysid = r.oid
44735
+ where r.rolcanlogin and r.rolname !~ '^pg_'
44736
+ group by r.oid, r.rolname, r.rolsuper
44737
+ order by count(a.pid) filter (where a.backend_type = 'client backend') desc, r.rolname
44738
+ limit 60`;
44739
+ var D001_SEES_SESSIONS_SQL = "select pg_has_role(current_user, 'pg_read_all_stats', 'usage') as visible";
44740
+ function d001StatementsSql(pgss) {
44741
+ return `
44742
+ with s as (
44743
+ select p.userid, p.calls,
44744
+ coalesce((to_jsonb(p) ->> 'max_exec_time'), (to_jsonb(p) ->> 'max_time'))::float8 as max_ms,
44745
+ coalesce(to_jsonb(p) ->> 'minmax_stats_since', to_jsonb(p) ->> 'stats_since') as since
44746
+ from ${pgss} as p
44747
+ )
44748
+ select r.rolname as role, count(*) as groups, sum(s.calls)::bigint as calls, max(s.max_ms) as longest_ms,
44749
+ min(s.since) as stats_since,
44750
+ (select jsonb_object_agg(t::text, (select count(*) from s as x where x.userid = s.userid and x.max_ms >= t) order by t)
44751
+ from unnest($1::float8[]) as t) as groups_at_or_over,
44752
+ (select jsonb_object_agg(t::text, (select coalesce(sum(x.calls), 0) from s as x
44753
+ where x.userid = s.userid and x.max_ms >= t) order by t)
44754
+ from unnest($1::float8[]) as t) as calls_of_groups_at_or_over
44755
+ from s join pg_roles as r on r.oid = s.userid
44756
+ group by r.rolname, s.userid
44757
+ order by 4 desc nulls last
44758
+ limit ${D001_MAX_ROLES}`;
44759
+ }
44760
+ var D001_COUNTERS_SQL = `
44761
+ select d.stats_reset, now() as read_at, d.temp_files, d.temp_bytes,
44762
+ (select coalesce(sum(t.autovacuum_count), 0) from pg_stat_all_tables as t) as autovacuum_runs
44763
+ from pg_stat_database as d
44764
+ where d.datname = current_database()`;
44765
+ function d001Iso(value) {
44766
+ if (value === null || value === undefined)
44767
+ return null;
44768
+ return value instanceof Date ? value.toISOString() : String(value);
44769
+ }
44770
+ var D001_DURATION_SETTINGS = ["log_min_duration_statement", "auto_explain.log_min_duration", "log_min_duration_sample"];
44771
+ var D001_MS_PER = { us: 0.001, ms: 1, s: 1000, min: 60000, h: 3600000, d: 86400000 };
44772
+ var D001_MAX_MS = 2147483647;
44773
+ var D001_MAX_STORED_THRESHOLDS = 20;
44774
+ function d001RoundMs(value) {
44775
+ const clean = Math.round(value * 1e6) / 1e6;
44776
+ const floor = Math.floor(clean);
44777
+ if (clean - floor !== 0.5)
44778
+ return Math.round(clean);
44779
+ return floor % 2 === 0 ? floor : floor + 1;
44780
+ }
44781
+ function d001StoredMs(value) {
44782
+ const match = /^[ \t\n\r\f\v]*([0-9]+(?:\.[0-9]+)?)[ \t\n\r\f\v]*([a-z]*)[ \t\n\r\f\v]*$/.exec(String(value));
44783
+ const factor = match ? D001_MS_PER[match[2] || "ms"] : undefined;
44784
+ if (!match || factor === undefined || match[1].length > 20)
44785
+ return null;
44786
+ const ms = d001RoundMs(parseFloat(match[1]) * factor);
44787
+ return ms <= D001_MAX_MS ? ms : null;
44788
+ }
44789
+ function d001Thresholds(settings, overrides) {
44790
+ const out = new Set(D001_BASE_THRESHOLDS_MS);
44791
+ for (const name of D001_DURATION_SETTINGS) {
44792
+ const info = settings[name];
44793
+ const value = info ? parseInt(info.setting, 10) : NaN;
44794
+ if (value > 0 && (info.unit || "ms") === "ms")
44795
+ out.add(value);
44796
+ }
44797
+ const stored = new Set;
44798
+ for (const item of overrides?.values ?? []) {
44799
+ if (!D001_DURATION_SETTINGS.includes(String(item.setting)))
44800
+ continue;
44801
+ const value = d001StoredMs(item.value);
44802
+ if (value)
44803
+ stored.add(value);
44804
+ }
44805
+ for (const value of [...stored].sort((a, b) => a - b).slice(0, D001_MAX_STORED_THRESHOLDS))
44806
+ out.add(value);
44807
+ return [...out].sort((a, b) => a - b);
44808
+ }
44809
+ function d001Config(config) {
44810
+ const out = {};
44811
+ for (const item of Array.isArray(config) ? config : []) {
44812
+ const text = String(item);
44813
+ const at = text.indexOf("=");
44814
+ const name = at < 0 ? text : text.slice(0, at);
44815
+ if (D001_OVERRIDE_PATTERN.test(name))
44816
+ out[name] = at < 0 ? "" : text.slice(at + 1);
44817
+ }
44818
+ return out;
44819
+ }
44820
+ function d001Window(start, end, total) {
44821
+ const to = end ? new Date(String(end)) : null;
44822
+ if (!to || isNaN(to.getTime()))
44823
+ return null;
44824
+ const from = start ? new Date(String(start)) : null;
44825
+ const bounded = from !== null && !isNaN(from.getTime()) && to > from;
44826
+ return {
44827
+ start: bounded ? from.toISOString().replace(/\.\d{3}Z$/, "Z") : null,
44828
+ end: to.toISOString().replace(/\.\d{3}Z$/, "Z"),
44829
+ days: bounded ? Math.round((to.getTime() - from.getTime()) / 86400000 * 100) / 100 : null,
44830
+ total: Number(total) || 0
44831
+ };
44832
+ }
44833
+ async function d001CatalogFacts(client) {
44834
+ const out = {};
44835
+ const fact = async (key, read) => {
44836
+ try {
44837
+ const value = await read();
44838
+ out[key] = value;
44839
+ return value;
44840
+ } catch (err) {
44841
+ out[`${key}_error`] = a005Error(err);
44842
+ return;
44843
+ }
44844
+ };
44845
+ await fact("read_as", async () => (await client.query("select current_user as role, current_database() as database")).rows[0]);
44846
+ let settings = null;
44847
+ const sources = {};
44848
+ await fact("settings", async () => {
44849
+ const rows = (await client.query(D001_SETTINGS_SQL, [D001_SETTING_PATTERN])).rows;
44850
+ settings = {};
44851
+ for (const row of rows) {
44852
+ const setting = row.setting === null ? "" : String(row.setting);
44853
+ settings[row.name] = {
44854
+ setting,
44855
+ unit: row.unit || "",
44856
+ category: row.category || "",
44857
+ context: row.context || "",
44858
+ vartype: row.vartype || "",
44859
+ pretty_value: row.unit ? `${setting} ${row.unit}` : setting
44860
+ };
44861
+ sources[row.name] = { source: row.source, is_default: setting === row.boot_val, pending_restart: Boolean(row.pending_restart) };
44862
+ }
44863
+ return true;
44864
+ });
44865
+ delete out.settings;
44866
+ if (settings)
44867
+ out.setting_sources = sources;
44868
+ const overrides = await fact("overrides", async () => {
44869
+ const rows = (await client.query(D001_OVERRIDES_SQL)).rows;
44870
+ const values = [];
44871
+ for (const row of rows) {
44872
+ for (const [name, value] of Object.entries(d001Config(row.config))) {
44873
+ const scope = row.role && row.database ? "role in database" : row.role ? "role" : row.database ? "database" : "all";
44874
+ values.push({ scope, role: row.role ?? null, database: row.database ?? null, setting: name, value });
44875
+ }
44876
+ }
44877
+ return { rows_read: rows.length, values };
44878
+ });
44879
+ const roles = await fact("login_roles", async () => (await client.query(D001_LOGIN_ROLES_SQL)).rows.map((row) => ({
44880
+ role: row.role,
44881
+ superuser: Boolean(row.superuser),
44882
+ member_of: Array.isArray(row.member_of) ? row.member_of : [],
44883
+ sessions: parseInt(row.sessions, 10) || 0,
44884
+ oldest_session_start: d001Iso(row.oldest_session_start),
44885
+ applications: Array.isArray(row.applications) ? row.applications : []
44886
+ })));
44887
+ if (roles) {
44888
+ let reason = null;
44889
+ try {
44890
+ const sees = (await client.query(D001_SEES_SESSIONS_SQL)).rows[0];
44891
+ if (sees && sees.visible === false)
44892
+ reason = "the reading role has no pg_read_all_stats: other roles' sessions are not visible";
44893
+ } catch (err) {
44894
+ reason = a005Error(err);
44895
+ }
44896
+ if (reason) {
44897
+ for (const role of roles)
44898
+ Object.assign(role, { sessions: null, oldest_session_start: null, applications: [] });
44899
+ out.sessions_error = reason;
44900
+ }
44901
+ }
44902
+ await fact("statements", async () => {
44903
+ const schema = (await client.query(G003_PGSS_SCHEMA_SQL)).rows[0]?.schema;
44904
+ if (!schema)
44905
+ throw new Error("pg_stat_statements is not installed");
44906
+ const quoted = `"${String(schema).replace(/"/g, '""')}"`;
44907
+ const thresholds = d001Thresholds(settings || {}, overrides);
44908
+ const byRole = (await client.query(d001StatementsSql(`${quoted}.pg_stat_statements`), [thresholds])).rows.map((row) => {
44909
+ const counts = (value) => Object.fromEntries(Object.entries(value || {}).map(([k, v]) => [String(parseFloat(k)), Number(v) || 0]));
44910
+ return {
44911
+ role: row.role,
44912
+ groups: parseInt(row.groups, 10) || 0,
44913
+ calls: parseInt(row.calls, 10) || 0,
44914
+ longest_call_ms: row.longest_ms === null ? null : Math.round(parseFloat(row.longest_ms) * 10) / 10,
44915
+ stats_since: d001Iso(row.stats_since),
44916
+ groups_at_or_over_ms: counts(row.groups_at_or_over),
44917
+ calls_of_groups_at_or_over_ms: counts(row.calls_of_groups_at_or_over)
44918
+ };
44919
+ });
44920
+ const result = { thresholds_ms: thresholds, by_role: byRole };
44921
+ try {
44922
+ const info = (await client.query(`select dealloc, stats_reset from ${quoted}.pg_stat_statements_info`)).rows[0];
44923
+ if (info) {
44924
+ result.dealloc = parseInt(info.dealloc, 10) || 0;
44925
+ result.stats_reset = d001Iso(info.stats_reset);
44926
+ }
44927
+ } catch {}
44928
+ return result;
44929
+ });
44930
+ try {
44931
+ const row = (await client.query(D001_COUNTERS_SQL)).rows[0];
44932
+ for (const [key, total] of [["temp_files", row?.temp_files], ["temp_bytes", row?.temp_bytes], ["autovacuum_runs", row?.autovacuum_runs]]) {
44933
+ const window = row ? d001Window(row.stats_reset, row.read_at, total) : null;
44934
+ if (window)
44935
+ out[key] = window;
44936
+ else
44937
+ out[`${key}_error`] = "the counters could not be read";
44938
+ }
44939
+ } catch (err) {
44940
+ for (const key of ["temp_files", "temp_bytes", "autovacuum_runs"])
44941
+ out[`${key}_error`] = a005Error(err);
44942
+ }
44943
+ return { settings, logging: out };
44944
+ }
44703
44945
  async function generateD001(client, nodeName) {
44704
44946
  const report = createBaseReport("D001", "Logging settings", nodeName);
44705
44947
  const postgresVersion = await getPostgresVersion(client);
44706
- const pgMajorVersion = parseInt(postgresVersion.server_major_ver, 10) || 16;
44707
- const allSettings = await getSettings(client, pgMajorVersion);
44708
- const loggingSettings = {};
44709
- for (const [name, setting] of Object.entries(allSettings)) {
44710
- if (name.startsWith("log_") || name.startsWith("logging_")) {
44711
- loggingSettings[name] = setting;
44948
+ const { settings, logging } = await d001CatalogFacts(client);
44949
+ let data = settings || {};
44950
+ if (!settings || !Object.keys(settings).length) {
44951
+ const pgMajorVersion = parseInt(postgresVersion.server_major_ver, 10) || 16;
44952
+ data = {};
44953
+ for (const [name, setting] of Object.entries(await getSettings(client, pgMajorVersion))) {
44954
+ if (new RegExp(D001_SETTING_PATTERN).test(name))
44955
+ data[name] = setting;
44712
44956
  }
44713
44957
  }
44714
44958
  report.results[nodeName] = {
44715
- data: loggingSettings,
44959
+ data,
44960
+ logging,
44716
44961
  postgres_version: postgresVersion
44717
44962
  };
44718
44963
  return report;
@@ -53083,6 +53328,9 @@ function printJoeOutcome(outcome, json, budgetMs) {
53083
53328
  console.log(JSON.stringify(output, null, 2));
53084
53329
  else {
53085
53330
  console.log(`command ${outcome.commandId} \xB7 ok`);
53331
+ const link = formatJoeConsoleLine(output);
53332
+ if (link)
53333
+ console.log(link);
53086
53334
  const body = formatJoeOutput(output);
53087
53335
  if (body)
53088
53336
  console.log(body);
@@ -53092,6 +53340,9 @@ function printJoeOutcome(outcome, json, budgetMs) {
53092
53340
  if (json && output)
53093
53341
  console.log(JSON.stringify(output, null, 2));
53094
53342
  console.error(`command ${outcome.commandId} error: ${output?.error ?? "command failed"}`);
53343
+ const errLink = json ? null : formatJoeConsoleLine(output);
53344
+ if (errLink)
53345
+ console.error(errLink);
53095
53346
  process.exitCode = 1;
53096
53347
  }
53097
53348
  async function runJoeCli(command, arg, opts) {
@@ -53183,11 +53434,17 @@ withOrgOptions(joe.command("result <commandId>")).description("fetch a Joe comma
53183
53434
  }
53184
53435
  if (output.status === "ok") {
53185
53436
  console.log(`command ${output.command_id} \xB7 ok`);
53437
+ const link = formatJoeConsoleLine(output);
53438
+ if (link)
53439
+ console.log(link);
53186
53440
  const body = formatJoeOutput(output);
53187
53441
  if (body)
53188
53442
  console.log(body);
53189
53443
  } else if (output.status === "error") {
53190
53444
  console.error(`command ${output.command_id} error: ${output.error ?? "command failed"}`);
53445
+ const errLink = formatJoeConsoleLine(output);
53446
+ if (errLink)
53447
+ console.error(errLink);
53191
53448
  process.exitCode = 1;
53192
53449
  } else {
53193
53450
  console.error(`command ${output.command_id} \xB7 ${output.status} \u2014 result is not ready`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postgresai",
3
- "version": "0.18.1-rc.4",
3
+ "version": "0.18.1-rc.6",
4
4
  "description": "postgres_ai CLI",
5
5
  "license": "Apache-2.0",
6
6
  "private": false,
@@ -58,12 +58,283 @@
58
58
  "type": "object",
59
59
  "additionalProperties": { "$ref": "#/$defs/setting" }
60
60
  },
61
+ "counterWindow": {
62
+ "type": "object",
63
+ "additionalProperties": false,
64
+ "required": [
65
+ "start",
66
+ "end",
67
+ "days",
68
+ "total"
69
+ ],
70
+ "properties": {
71
+ "start": {
72
+ "type": [
73
+ "string",
74
+ "null"
75
+ ]
76
+ },
77
+ "end": {
78
+ "type": "string"
79
+ },
80
+ "days": {
81
+ "type": [
82
+ "number",
83
+ "null"
84
+ ]
85
+ },
86
+ "total": {
87
+ "type": "number"
88
+ },
89
+ "floor": {
90
+ "type": "boolean"
91
+ }
92
+ }
93
+ },
94
+ "logging": {
95
+ "type": "object",
96
+ "additionalProperties": false,
97
+ "properties": {
98
+ "read_as": {
99
+ "type": "object",
100
+ "additionalProperties": false,
101
+ "required": [
102
+ "role",
103
+ "database"
104
+ ],
105
+ "properties": {
106
+ "role": {
107
+ "type": "string"
108
+ },
109
+ "database": {
110
+ "type": "string"
111
+ }
112
+ }
113
+ },
114
+ "setting_sources": {
115
+ "type": "object",
116
+ "additionalProperties": {
117
+ "type": "object",
118
+ "additionalProperties": false,
119
+ "required": [
120
+ "source",
121
+ "is_default",
122
+ "pending_restart"
123
+ ],
124
+ "properties": {
125
+ "source": {
126
+ "type": "string"
127
+ },
128
+ "is_default": {
129
+ "type": "boolean"
130
+ },
131
+ "pending_restart": {
132
+ "type": "boolean"
133
+ }
134
+ }
135
+ }
136
+ },
137
+ "overrides": {
138
+ "type": "object",
139
+ "additionalProperties": false,
140
+ "required": [
141
+ "rows_read",
142
+ "values"
143
+ ],
144
+ "properties": {
145
+ "rows_read": {
146
+ "type": "integer"
147
+ },
148
+ "values": {
149
+ "type": "array",
150
+ "items": {
151
+ "type": "object",
152
+ "additionalProperties": false,
153
+ "required": [
154
+ "scope",
155
+ "role",
156
+ "database",
157
+ "setting",
158
+ "value"
159
+ ],
160
+ "properties": {
161
+ "scope": {
162
+ "enum": [
163
+ "role",
164
+ "database",
165
+ "role in database",
166
+ "all"
167
+ ]
168
+ },
169
+ "role": {
170
+ "type": [
171
+ "string",
172
+ "null"
173
+ ]
174
+ },
175
+ "database": {
176
+ "type": [
177
+ "string",
178
+ "null"
179
+ ]
180
+ },
181
+ "setting": {
182
+ "type": "string"
183
+ },
184
+ "value": {
185
+ "type": "string"
186
+ }
187
+ }
188
+ }
189
+ }
190
+ }
191
+ },
192
+ "login_roles": {
193
+ "type": "array",
194
+ "items": {
195
+ "type": "object",
196
+ "additionalProperties": false,
197
+ "required": [
198
+ "role",
199
+ "superuser",
200
+ "member_of",
201
+ "sessions",
202
+ "oldest_session_start",
203
+ "applications"
204
+ ],
205
+ "properties": {
206
+ "role": {
207
+ "type": "string"
208
+ },
209
+ "superuser": {
210
+ "type": "boolean"
211
+ },
212
+ "sessions": {
213
+ "type": [
214
+ "integer",
215
+ "null"
216
+ ]
217
+ },
218
+ "oldest_session_start": {
219
+ "type": [
220
+ "string",
221
+ "null"
222
+ ]
223
+ },
224
+ "applications": {
225
+ "type": "array",
226
+ "items": {
227
+ "type": "string"
228
+ }
229
+ },
230
+ "member_of": {
231
+ "type": "array",
232
+ "items": {
233
+ "type": "string"
234
+ }
235
+ }
236
+ }
237
+ }
238
+ },
239
+ "statements": {
240
+ "type": "object",
241
+ "additionalProperties": false,
242
+ "required": [
243
+ "thresholds_ms",
244
+ "by_role"
245
+ ],
246
+ "properties": {
247
+ "thresholds_ms": {
248
+ "type": "array",
249
+ "items": {
250
+ "type": "number"
251
+ }
252
+ },
253
+ "dealloc": {
254
+ "type": "integer"
255
+ },
256
+ "stats_reset": {
257
+ "type": [
258
+ "string",
259
+ "null"
260
+ ]
261
+ },
262
+ "by_role": {
263
+ "type": "array",
264
+ "items": {
265
+ "type": "object",
266
+ "additionalProperties": false,
267
+ "required": [
268
+ "role",
269
+ "groups",
270
+ "calls",
271
+ "longest_call_ms",
272
+ "stats_since",
273
+ "groups_at_or_over_ms",
274
+ "calls_of_groups_at_or_over_ms"
275
+ ],
276
+ "properties": {
277
+ "role": {
278
+ "type": "string"
279
+ },
280
+ "groups": {
281
+ "type": "integer"
282
+ },
283
+ "calls": {
284
+ "type": "integer"
285
+ },
286
+ "longest_call_ms": {
287
+ "type": [
288
+ "number",
289
+ "null"
290
+ ]
291
+ },
292
+ "stats_since": {
293
+ "type": [
294
+ "string",
295
+ "null"
296
+ ]
297
+ },
298
+ "groups_at_or_over_ms": {
299
+ "type": "object",
300
+ "additionalProperties": {
301
+ "type": "integer"
302
+ }
303
+ },
304
+ "calls_of_groups_at_or_over_ms": {
305
+ "type": "object",
306
+ "additionalProperties": {
307
+ "type": "integer"
308
+ }
309
+ }
310
+ }
311
+ }
312
+ }
313
+ }
314
+ },
315
+ "temp_files": {
316
+ "$ref": "#/$defs/counterWindow"
317
+ },
318
+ "temp_bytes": {
319
+ "$ref": "#/$defs/counterWindow"
320
+ },
321
+ "autovacuum_runs": {
322
+ "$ref": "#/$defs/counterWindow"
323
+ }
324
+ },
325
+ "patternProperties": {
326
+ "_error$": {
327
+ "type": "string"
328
+ }
329
+ }
330
+ },
61
331
  "nodeResult": {
62
332
  "type": "object",
63
333
  "additionalProperties": false,
64
334
  "required": ["data"],
65
335
  "properties": {
66
336
  "data": { "$ref": "#/$defs/data" },
337
+ "logging": { "$ref": "#/$defs/logging" },
67
338
  "postgres_version": { "$ref": "#/$defs/postgresVersion" }
68
339
  }
69
340
  }
@@ -78,7 +78,60 @@
78
78
  "real_size_pretty": { "type": "string" },
79
79
  "table_size_pretty": { "type": "string" },
80
80
  "extra_size_pretty": { "type": "string" },
81
- "bloat_size_pretty": { "type": "string" }
81
+ "bloat_size_pretty": { "type": "string" },
82
+ "bloat_size_min_in_window_bytes": { "type": ["integer", "null"] },
83
+ "bloat_size_max_in_window_bytes": { "type": ["integer", "null"] },
84
+ "real_size_min_in_window_bytes": { "type": ["integer", "null"] },
85
+ "real_size_max_in_window_bytes": { "type": ["integer", "null"] },
86
+ "on_unused_list": { "type": ["boolean", "null"] },
87
+ "on_redundant_list": { "type": ["boolean", "null"] }
88
+ }
89
+ },
90
+ "tableFact": {
91
+ "type": "object",
92
+ "additionalProperties": false,
93
+ "required": ["schema_name", "table_name"],
94
+ "properties": {
95
+ "schema_name": { "type": "string" },
96
+ "table_name": { "type": "string" },
97
+ "n_live_tup": { "type": ["integer", "null"] },
98
+ "n_dead_tup": { "type": ["integer", "null"] },
99
+ "vacuum_threshold": { "type": ["integer", "null"] },
100
+ "autovacuum_runs_in_window": { "type": ["integer", "null"] },
101
+ "vacuum_runs_in_window": { "type": ["integer", "null"] },
102
+ "n_tup_ins_in_window": { "type": ["integer", "null"] },
103
+ "n_tup_upd_in_window": { "type": ["integer", "null"] },
104
+ "n_tup_del_in_window": { "type": ["integer", "null"] },
105
+ "n_tup_hot_upd_in_window": { "type": ["integer", "null"] },
106
+ "table_size_bytes": { "type": ["integer", "null"] },
107
+ "toast_size_bytes": { "type": ["integer", "null"] },
108
+ "table_size_min_in_window_bytes": { "type": ["integer", "null"] },
109
+ "table_size_max_in_window_bytes": { "type": ["integer", "null"] },
110
+ "seconds_since_last_vacuum": { "type": ["integer", "null"] },
111
+ "vacuum_recorded": { "type": ["boolean", "null"] },
112
+ "autovacuum_disabled": { "type": ["boolean", "null"] }
113
+ }
114
+ },
115
+ "history": {
116
+ "type": "object",
117
+ "additionalProperties": false,
118
+ "required": ["daily", "first_reading_at"],
119
+ "properties": {
120
+ "daily": {
121
+ "type": "array",
122
+ "items": {
123
+ "type": "object",
124
+ "additionalProperties": false,
125
+ "required": ["days_ago", "at", "total_bloat_size_bytes"],
126
+ "properties": {
127
+ "days_ago": { "type": "integer" },
128
+ "at": { "type": ["string", "null"] },
129
+ "total_bloat_size_bytes": { "type": "integer" }
130
+ }
131
+ }
132
+ },
133
+ "first_reading_at": { "type": ["string", "null"] },
134
+ "window_seconds": { "type": "integer" }
82
135
  }
83
136
  },
84
137
  "dbEntry": {
@@ -99,7 +152,22 @@
99
152
  "total_bloat_size_bytes": { "type": "number" },
100
153
  "total_bloat_size_pretty": { "type": "string" },
101
154
  "database_size_bytes": { "type": "number" },
102
- "database_size_pretty": { "type": "string" }
155
+ "database_size_pretty": { "type": "string" },
156
+ "history": { "$ref": "#/$defs/history" },
157
+ "table_facts": { "type": "array", "items": { "$ref": "#/$defs/tableFact" } },
158
+ "traffic_by_hour_utc": {
159
+ "type": "array",
160
+ "items": {
161
+ "type": "object",
162
+ "additionalProperties": false,
163
+ "required": ["hour", "xact_commit_per_s", "readings"],
164
+ "properties": {
165
+ "hour": { "type": "integer" },
166
+ "xact_commit_per_s": { "type": "number" },
167
+ "readings": { "type": "integer" }
168
+ }
169
+ }
170
+ }
103
171
  }
104
172
  },
105
173
  "status": {