postgresai 0.18.1-rc.4 → 0.18.1-rc.5
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.
- package/dist/bin/postgres-ai.js +250 -10
- package/package.json +1 -1
- package/schemas/D001.schema.json +271 -0
- package/schemas/F005.schema.json +70 -2
package/dist/bin/postgres-ai.js
CHANGED
|
@@ -13538,7 +13538,7 @@ var {
|
|
|
13538
13538
|
// package.json
|
|
13539
13539
|
var package_default = {
|
|
13540
13540
|
name: "postgresai",
|
|
13541
|
-
version: "0.18.1-rc.
|
|
13541
|
+
version: "0.18.1-rc.5",
|
|
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.
|
|
16901
|
+
var version = "0.18.1-rc.5";
|
|
16902
16902
|
var package_default2 = {
|
|
16903
16903
|
name: "postgresai",
|
|
16904
16904
|
version,
|
|
@@ -41126,7 +41126,7 @@ order by cmb.total_relation_size_b desc, cmb.schemaname, cmb.relname
|
|
|
41126
41126
|
from
|
|
41127
41127
|
pg_catalog.pg_database d
|
|
41128
41128
|
where
|
|
41129
|
-
d.
|
|
41129
|
+
d.datconnlimit <> -2
|
|
41130
41130
|
`
|
|
41131
41131
|
},
|
|
41132
41132
|
gauges: ["age_datfrozenxid", "age_datminmxid"],
|
|
@@ -44700,19 +44700,259 @@ async function generateD004(client, nodeName) {
|
|
|
44700
44700
|
};
|
|
44701
44701
|
return report;
|
|
44702
44702
|
}
|
|
44703
|
+
var D001_SETTING_PATTERN = "^(log_.*|logging_collector|auto_explain\\..*|shared_preload_libraries|session_preload_libraries|deadlock_timeout)$";
|
|
44704
|
+
var D001_OVERRIDE_PATTERN = /^(log_.*|auto_explain\..*|session_preload_libraries|statement_timeout)$/;
|
|
44705
|
+
var D001_BASE_THRESHOLDS_MS = [1000, 1e4];
|
|
44706
|
+
var D001_MAX_ROLES = 60;
|
|
44707
|
+
var D001_SETTINGS_SQL = `
|
|
44708
|
+
select name, reset_val as setting, coalesce(unit, '') as unit, category, context, vartype, source,
|
|
44709
|
+
boot_val, pending_restart
|
|
44710
|
+
from pg_settings
|
|
44711
|
+
where name ~ $1
|
|
44712
|
+
order by name`;
|
|
44713
|
+
var D001_OVERRIDES_SQL = `
|
|
44714
|
+
select r.rolname as role, d.datname as database, s.setconfig as config
|
|
44715
|
+
from pg_db_role_setting as s
|
|
44716
|
+
left join pg_roles as r on r.oid = s.setrole
|
|
44717
|
+
left join pg_database as d on d.oid = s.setdatabase
|
|
44718
|
+
order by r.rolname nulls first, d.datname nulls first`;
|
|
44719
|
+
var D001_LOGIN_ROLES_SQL = `
|
|
44720
|
+
select r.rolname as role, r.rolsuper as superuser,
|
|
44721
|
+
coalesce((select array_agg(g.rolname::text order by g.rolname)
|
|
44722
|
+
from pg_auth_members as m join pg_roles as g on g.oid = m.roleid
|
|
44723
|
+
where m.member = r.oid), '{}') as member_of,
|
|
44724
|
+
count(a.pid) filter (where a.backend_type = 'client backend') as sessions,
|
|
44725
|
+
min(a.backend_start) filter (where a.backend_type = 'client backend') as oldest_session_start,
|
|
44726
|
+
(array_agg(distinct a.application_name) filter (where a.backend_type = 'client backend'
|
|
44727
|
+
and a.application_name <> ''))[1:5] as applications
|
|
44728
|
+
from pg_roles as r
|
|
44729
|
+
left join pg_stat_activity as a on a.usesysid = r.oid
|
|
44730
|
+
where r.rolcanlogin and r.rolname !~ '^pg_'
|
|
44731
|
+
group by r.oid, r.rolname, r.rolsuper
|
|
44732
|
+
order by count(a.pid) filter (where a.backend_type = 'client backend') desc, r.rolname
|
|
44733
|
+
limit 60`;
|
|
44734
|
+
var D001_SEES_SESSIONS_SQL = "select pg_has_role(current_user, 'pg_read_all_stats', 'usage') as visible";
|
|
44735
|
+
function d001StatementsSql(pgss) {
|
|
44736
|
+
return `
|
|
44737
|
+
with s as (
|
|
44738
|
+
select p.userid, p.calls,
|
|
44739
|
+
coalesce((to_jsonb(p) ->> 'max_exec_time'), (to_jsonb(p) ->> 'max_time'))::float8 as max_ms,
|
|
44740
|
+
coalesce(to_jsonb(p) ->> 'minmax_stats_since', to_jsonb(p) ->> 'stats_since') as since
|
|
44741
|
+
from ${pgss} as p
|
|
44742
|
+
)
|
|
44743
|
+
select r.rolname as role, count(*) as groups, sum(s.calls)::bigint as calls, max(s.max_ms) as longest_ms,
|
|
44744
|
+
min(s.since) as stats_since,
|
|
44745
|
+
(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)
|
|
44746
|
+
from unnest($1::float8[]) as t) as groups_at_or_over,
|
|
44747
|
+
(select jsonb_object_agg(t::text, (select coalesce(sum(x.calls), 0) from s as x
|
|
44748
|
+
where x.userid = s.userid and x.max_ms >= t) order by t)
|
|
44749
|
+
from unnest($1::float8[]) as t) as calls_of_groups_at_or_over
|
|
44750
|
+
from s join pg_roles as r on r.oid = s.userid
|
|
44751
|
+
group by r.rolname, s.userid
|
|
44752
|
+
order by 4 desc nulls last
|
|
44753
|
+
limit ${D001_MAX_ROLES}`;
|
|
44754
|
+
}
|
|
44755
|
+
var D001_COUNTERS_SQL = `
|
|
44756
|
+
select d.stats_reset, now() as read_at, d.temp_files, d.temp_bytes,
|
|
44757
|
+
(select coalesce(sum(t.autovacuum_count), 0) from pg_stat_all_tables as t) as autovacuum_runs
|
|
44758
|
+
from pg_stat_database as d
|
|
44759
|
+
where d.datname = current_database()`;
|
|
44760
|
+
function d001Iso(value) {
|
|
44761
|
+
if (value === null || value === undefined)
|
|
44762
|
+
return null;
|
|
44763
|
+
return value instanceof Date ? value.toISOString() : String(value);
|
|
44764
|
+
}
|
|
44765
|
+
var D001_DURATION_SETTINGS = ["log_min_duration_statement", "auto_explain.log_min_duration", "log_min_duration_sample"];
|
|
44766
|
+
var D001_MS_PER = { us: 0.001, ms: 1, s: 1000, min: 60000, h: 3600000, d: 86400000 };
|
|
44767
|
+
var D001_MAX_MS = 2147483647;
|
|
44768
|
+
var D001_MAX_STORED_THRESHOLDS = 20;
|
|
44769
|
+
function d001RoundMs(value) {
|
|
44770
|
+
const clean = Math.round(value * 1e6) / 1e6;
|
|
44771
|
+
const floor = Math.floor(clean);
|
|
44772
|
+
if (clean - floor !== 0.5)
|
|
44773
|
+
return Math.round(clean);
|
|
44774
|
+
return floor % 2 === 0 ? floor : floor + 1;
|
|
44775
|
+
}
|
|
44776
|
+
function d001StoredMs(value) {
|
|
44777
|
+
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));
|
|
44778
|
+
const factor = match ? D001_MS_PER[match[2] || "ms"] : undefined;
|
|
44779
|
+
if (!match || factor === undefined || match[1].length > 20)
|
|
44780
|
+
return null;
|
|
44781
|
+
const ms = d001RoundMs(parseFloat(match[1]) * factor);
|
|
44782
|
+
return ms <= D001_MAX_MS ? ms : null;
|
|
44783
|
+
}
|
|
44784
|
+
function d001Thresholds(settings, overrides) {
|
|
44785
|
+
const out = new Set(D001_BASE_THRESHOLDS_MS);
|
|
44786
|
+
for (const name of D001_DURATION_SETTINGS) {
|
|
44787
|
+
const info = settings[name];
|
|
44788
|
+
const value = info ? parseInt(info.setting, 10) : NaN;
|
|
44789
|
+
if (value > 0 && (info.unit || "ms") === "ms")
|
|
44790
|
+
out.add(value);
|
|
44791
|
+
}
|
|
44792
|
+
const stored = new Set;
|
|
44793
|
+
for (const item of overrides?.values ?? []) {
|
|
44794
|
+
if (!D001_DURATION_SETTINGS.includes(String(item.setting)))
|
|
44795
|
+
continue;
|
|
44796
|
+
const value = d001StoredMs(item.value);
|
|
44797
|
+
if (value)
|
|
44798
|
+
stored.add(value);
|
|
44799
|
+
}
|
|
44800
|
+
for (const value of [...stored].sort((a, b) => a - b).slice(0, D001_MAX_STORED_THRESHOLDS))
|
|
44801
|
+
out.add(value);
|
|
44802
|
+
return [...out].sort((a, b) => a - b);
|
|
44803
|
+
}
|
|
44804
|
+
function d001Config(config) {
|
|
44805
|
+
const out = {};
|
|
44806
|
+
for (const item of Array.isArray(config) ? config : []) {
|
|
44807
|
+
const text = String(item);
|
|
44808
|
+
const at = text.indexOf("=");
|
|
44809
|
+
const name = at < 0 ? text : text.slice(0, at);
|
|
44810
|
+
if (D001_OVERRIDE_PATTERN.test(name))
|
|
44811
|
+
out[name] = at < 0 ? "" : text.slice(at + 1);
|
|
44812
|
+
}
|
|
44813
|
+
return out;
|
|
44814
|
+
}
|
|
44815
|
+
function d001Window(start, end, total) {
|
|
44816
|
+
const to = end ? new Date(String(end)) : null;
|
|
44817
|
+
if (!to || isNaN(to.getTime()))
|
|
44818
|
+
return null;
|
|
44819
|
+
const from = start ? new Date(String(start)) : null;
|
|
44820
|
+
const bounded = from !== null && !isNaN(from.getTime()) && to > from;
|
|
44821
|
+
return {
|
|
44822
|
+
start: bounded ? from.toISOString().replace(/\.\d{3}Z$/, "Z") : null,
|
|
44823
|
+
end: to.toISOString().replace(/\.\d{3}Z$/, "Z"),
|
|
44824
|
+
days: bounded ? Math.round((to.getTime() - from.getTime()) / 86400000 * 100) / 100 : null,
|
|
44825
|
+
total: Number(total) || 0
|
|
44826
|
+
};
|
|
44827
|
+
}
|
|
44828
|
+
async function d001CatalogFacts(client) {
|
|
44829
|
+
const out = {};
|
|
44830
|
+
const fact = async (key, read) => {
|
|
44831
|
+
try {
|
|
44832
|
+
const value = await read();
|
|
44833
|
+
out[key] = value;
|
|
44834
|
+
return value;
|
|
44835
|
+
} catch (err) {
|
|
44836
|
+
out[`${key}_error`] = a005Error(err);
|
|
44837
|
+
return;
|
|
44838
|
+
}
|
|
44839
|
+
};
|
|
44840
|
+
await fact("read_as", async () => (await client.query("select current_user as role, current_database() as database")).rows[0]);
|
|
44841
|
+
let settings = null;
|
|
44842
|
+
const sources = {};
|
|
44843
|
+
await fact("settings", async () => {
|
|
44844
|
+
const rows = (await client.query(D001_SETTINGS_SQL, [D001_SETTING_PATTERN])).rows;
|
|
44845
|
+
settings = {};
|
|
44846
|
+
for (const row of rows) {
|
|
44847
|
+
const setting = row.setting === null ? "" : String(row.setting);
|
|
44848
|
+
settings[row.name] = {
|
|
44849
|
+
setting,
|
|
44850
|
+
unit: row.unit || "",
|
|
44851
|
+
category: row.category || "",
|
|
44852
|
+
context: row.context || "",
|
|
44853
|
+
vartype: row.vartype || "",
|
|
44854
|
+
pretty_value: row.unit ? `${setting} ${row.unit}` : setting
|
|
44855
|
+
};
|
|
44856
|
+
sources[row.name] = { source: row.source, is_default: setting === row.boot_val, pending_restart: Boolean(row.pending_restart) };
|
|
44857
|
+
}
|
|
44858
|
+
return true;
|
|
44859
|
+
});
|
|
44860
|
+
delete out.settings;
|
|
44861
|
+
if (settings)
|
|
44862
|
+
out.setting_sources = sources;
|
|
44863
|
+
const overrides = await fact("overrides", async () => {
|
|
44864
|
+
const rows = (await client.query(D001_OVERRIDES_SQL)).rows;
|
|
44865
|
+
const values = [];
|
|
44866
|
+
for (const row of rows) {
|
|
44867
|
+
for (const [name, value] of Object.entries(d001Config(row.config))) {
|
|
44868
|
+
const scope = row.role && row.database ? "role in database" : row.role ? "role" : row.database ? "database" : "all";
|
|
44869
|
+
values.push({ scope, role: row.role ?? null, database: row.database ?? null, setting: name, value });
|
|
44870
|
+
}
|
|
44871
|
+
}
|
|
44872
|
+
return { rows_read: rows.length, values };
|
|
44873
|
+
});
|
|
44874
|
+
const roles = await fact("login_roles", async () => (await client.query(D001_LOGIN_ROLES_SQL)).rows.map((row) => ({
|
|
44875
|
+
role: row.role,
|
|
44876
|
+
superuser: Boolean(row.superuser),
|
|
44877
|
+
member_of: Array.isArray(row.member_of) ? row.member_of : [],
|
|
44878
|
+
sessions: parseInt(row.sessions, 10) || 0,
|
|
44879
|
+
oldest_session_start: d001Iso(row.oldest_session_start),
|
|
44880
|
+
applications: Array.isArray(row.applications) ? row.applications : []
|
|
44881
|
+
})));
|
|
44882
|
+
if (roles) {
|
|
44883
|
+
let reason = null;
|
|
44884
|
+
try {
|
|
44885
|
+
const sees = (await client.query(D001_SEES_SESSIONS_SQL)).rows[0];
|
|
44886
|
+
if (sees && sees.visible === false)
|
|
44887
|
+
reason = "the reading role has no pg_read_all_stats: other roles' sessions are not visible";
|
|
44888
|
+
} catch (err) {
|
|
44889
|
+
reason = a005Error(err);
|
|
44890
|
+
}
|
|
44891
|
+
if (reason) {
|
|
44892
|
+
for (const role of roles)
|
|
44893
|
+
Object.assign(role, { sessions: null, oldest_session_start: null, applications: [] });
|
|
44894
|
+
out.sessions_error = reason;
|
|
44895
|
+
}
|
|
44896
|
+
}
|
|
44897
|
+
await fact("statements", async () => {
|
|
44898
|
+
const schema = (await client.query(G003_PGSS_SCHEMA_SQL)).rows[0]?.schema;
|
|
44899
|
+
if (!schema)
|
|
44900
|
+
throw new Error("pg_stat_statements is not installed");
|
|
44901
|
+
const quoted = `"${String(schema).replace(/"/g, '""')}"`;
|
|
44902
|
+
const thresholds = d001Thresholds(settings || {}, overrides);
|
|
44903
|
+
const byRole = (await client.query(d001StatementsSql(`${quoted}.pg_stat_statements`), [thresholds])).rows.map((row) => {
|
|
44904
|
+
const counts = (value) => Object.fromEntries(Object.entries(value || {}).map(([k, v]) => [String(parseFloat(k)), Number(v) || 0]));
|
|
44905
|
+
return {
|
|
44906
|
+
role: row.role,
|
|
44907
|
+
groups: parseInt(row.groups, 10) || 0,
|
|
44908
|
+
calls: parseInt(row.calls, 10) || 0,
|
|
44909
|
+
longest_call_ms: row.longest_ms === null ? null : Math.round(parseFloat(row.longest_ms) * 10) / 10,
|
|
44910
|
+
stats_since: d001Iso(row.stats_since),
|
|
44911
|
+
groups_at_or_over_ms: counts(row.groups_at_or_over),
|
|
44912
|
+
calls_of_groups_at_or_over_ms: counts(row.calls_of_groups_at_or_over)
|
|
44913
|
+
};
|
|
44914
|
+
});
|
|
44915
|
+
const result = { thresholds_ms: thresholds, by_role: byRole };
|
|
44916
|
+
try {
|
|
44917
|
+
const info = (await client.query(`select dealloc, stats_reset from ${quoted}.pg_stat_statements_info`)).rows[0];
|
|
44918
|
+
if (info) {
|
|
44919
|
+
result.dealloc = parseInt(info.dealloc, 10) || 0;
|
|
44920
|
+
result.stats_reset = d001Iso(info.stats_reset);
|
|
44921
|
+
}
|
|
44922
|
+
} catch {}
|
|
44923
|
+
return result;
|
|
44924
|
+
});
|
|
44925
|
+
try {
|
|
44926
|
+
const row = (await client.query(D001_COUNTERS_SQL)).rows[0];
|
|
44927
|
+
for (const [key, total] of [["temp_files", row?.temp_files], ["temp_bytes", row?.temp_bytes], ["autovacuum_runs", row?.autovacuum_runs]]) {
|
|
44928
|
+
const window = row ? d001Window(row.stats_reset, row.read_at, total) : null;
|
|
44929
|
+
if (window)
|
|
44930
|
+
out[key] = window;
|
|
44931
|
+
else
|
|
44932
|
+
out[`${key}_error`] = "the counters could not be read";
|
|
44933
|
+
}
|
|
44934
|
+
} catch (err) {
|
|
44935
|
+
for (const key of ["temp_files", "temp_bytes", "autovacuum_runs"])
|
|
44936
|
+
out[`${key}_error`] = a005Error(err);
|
|
44937
|
+
}
|
|
44938
|
+
return { settings, logging: out };
|
|
44939
|
+
}
|
|
44703
44940
|
async function generateD001(client, nodeName) {
|
|
44704
44941
|
const report = createBaseReport("D001", "Logging settings", nodeName);
|
|
44705
44942
|
const postgresVersion = await getPostgresVersion(client);
|
|
44706
|
-
const
|
|
44707
|
-
|
|
44708
|
-
|
|
44709
|
-
|
|
44710
|
-
|
|
44711
|
-
|
|
44943
|
+
const { settings, logging } = await d001CatalogFacts(client);
|
|
44944
|
+
let data = settings || {};
|
|
44945
|
+
if (!settings || !Object.keys(settings).length) {
|
|
44946
|
+
const pgMajorVersion = parseInt(postgresVersion.server_major_ver, 10) || 16;
|
|
44947
|
+
data = {};
|
|
44948
|
+
for (const [name, setting] of Object.entries(await getSettings(client, pgMajorVersion))) {
|
|
44949
|
+
if (new RegExp(D001_SETTING_PATTERN).test(name))
|
|
44950
|
+
data[name] = setting;
|
|
44712
44951
|
}
|
|
44713
44952
|
}
|
|
44714
44953
|
report.results[nodeName] = {
|
|
44715
|
-
data
|
|
44954
|
+
data,
|
|
44955
|
+
logging,
|
|
44716
44956
|
postgres_version: postgresVersion
|
|
44717
44957
|
};
|
|
44718
44958
|
return report;
|
package/package.json
CHANGED
package/schemas/D001.schema.json
CHANGED
|
@@ -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
|
}
|
package/schemas/F005.schema.json
CHANGED
|
@@ -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": {
|