postgresai 0.19.0-rc.1 → 0.19.0-rc.3
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 +197 -6
- package/package.json +1 -1
- package/schemas/D004.schema.json +315 -2
- package/schemas/K003.schema.json +73 -3
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.19.0-rc.
|
|
13541
|
+
version: "0.19.0-rc.3",
|
|
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.19.0-rc.
|
|
16901
|
+
var version = "0.19.0-rc.3";
|
|
16902
16902
|
var package_default2 = {
|
|
16903
16903
|
name: "postgresai",
|
|
16904
16904
|
version,
|
|
@@ -44429,8 +44429,11 @@ select (count(*) filter (where auth_method = 'cert'))::int as cert,
|
|
|
44429
44429
|
from pg_hba_file_rules
|
|
44430
44430
|
`;
|
|
44431
44431
|
function a005Error(err) {
|
|
44432
|
-
const
|
|
44433
|
-
|
|
44432
|
+
const chars = Array.from((err instanceof Error ? err.message : String(err)).replace(/\s+/g, " ").trim());
|
|
44433
|
+
if (chars.length <= A005_ERROR_CHARS)
|
|
44434
|
+
return chars.join("") || "unknown error";
|
|
44435
|
+
const head = Math.floor((A005_ERROR_CHARS - 3) / 3);
|
|
44436
|
+
return chars.slice(0, head).join("") + "..." + chars.slice(chars.length - (A005_ERROR_CHARS - 3 - head)).join("");
|
|
44434
44437
|
}
|
|
44435
44438
|
var a005OpenDatabase = async (client, database) => {
|
|
44436
44439
|
const params = client.connectionParameters;
|
|
@@ -44701,10 +44704,198 @@ async function generateD004(client, nodeName) {
|
|
|
44701
44704
|
...kcacheError && { error: kcacheError }
|
|
44702
44705
|
}
|
|
44703
44706
|
},
|
|
44707
|
+
observability: await d004CatalogFacts(client),
|
|
44704
44708
|
postgres_version: postgresVersion
|
|
44705
44709
|
};
|
|
44706
44710
|
return report;
|
|
44707
44711
|
}
|
|
44712
|
+
var D004_EXTENSIONS = ["pg_stat_statements", "pg_stat_kcache", "pg_wait_sampling", "pg_stat_monitor", "pg_qualstats", "pg_store_plans"];
|
|
44713
|
+
var D004_SETTING_PATTERN = "^(pg_stat_statements|pg_stat_kcache|pg_wait_sampling|pg_stat_monitor|pg_qualstats|pg_store_plans)\\..*$" + "|^(shared_preload_libraries|session_preload_libraries)$";
|
|
44714
|
+
var D004_OVERRIDE_PATTERN = /^(pg_stat_statements|pg_stat_kcache|pg_wait_sampling|pg_stat_monitor|pg_qualstats|pg_store_plans)\..*$/;
|
|
44715
|
+
var D004_AVAILABLE_SQL = `
|
|
44716
|
+
select name, default_version, installed_version
|
|
44717
|
+
from pg_available_extensions
|
|
44718
|
+
where name = any($1)
|
|
44719
|
+
order by name`;
|
|
44720
|
+
var D004_INSTALLED_SQL = `
|
|
44721
|
+
select e.extname as name, e.extversion as version, n.nspname as schema
|
|
44722
|
+
from pg_extension as e join pg_namespace as n on n.oid = e.extnamespace
|
|
44723
|
+
where e.extname = any($1)
|
|
44724
|
+
order by e.extname`;
|
|
44725
|
+
function d004EntriesSql(pgss) {
|
|
44726
|
+
return `
|
|
44727
|
+
select d.datname as database, count(*)::bigint as entries, coalesce(sum(p.calls), 0)::bigint as calls,
|
|
44728
|
+
(count(*) filter (where p.calls = 1))::bigint as called_once,
|
|
44729
|
+
(count(*) filter (where p.query ~* '\\m(pg_temp(_[0-9]+)?|temp|temporary)\\M'))::bigint as temp_table_text,
|
|
44730
|
+
bool_and(p.query <> '<insufficient privilege>') as texts_visible
|
|
44731
|
+
from ${pgss} as p left join pg_database as d on d.oid = p.dbid
|
|
44732
|
+
group by d.datname
|
|
44733
|
+
order by count(*) desc`;
|
|
44734
|
+
}
|
|
44735
|
+
function d004PerRound(entries) {
|
|
44736
|
+
return Math.min(entries, Math.max(10, Math.floor(entries * 5 / 100)));
|
|
44737
|
+
}
|
|
44738
|
+
async function d004Installed(client) {
|
|
44739
|
+
const out = {};
|
|
44740
|
+
for (const row of (await client.query(D004_INSTALLED_SQL, [D004_EXTENSIONS])).rows) {
|
|
44741
|
+
out[row.name] = { version: String(row.version), schema: String(row.schema) };
|
|
44742
|
+
}
|
|
44743
|
+
return out;
|
|
44744
|
+
}
|
|
44745
|
+
var D004_DATABASES_SQL = `
|
|
44746
|
+
select d.datname, d.datname = current_database() as is_current,
|
|
44747
|
+
has_database_privilege(d.oid, 'CONNECT') as can_connect
|
|
44748
|
+
from pg_database as d
|
|
44749
|
+
where d.datallowconn and not d.datistemplate
|
|
44750
|
+
order by d.datname`;
|
|
44751
|
+
async function d004Statements(client, schema, max) {
|
|
44752
|
+
const quoted = `"${schema.replace(/"/g, '""')}"`;
|
|
44753
|
+
const rows = (await client.query(d004EntriesSql(`${quoted}.pg_stat_statements`))).rows;
|
|
44754
|
+
const visible = rows.every((row) => row.texts_visible !== false);
|
|
44755
|
+
const out = {
|
|
44756
|
+
schema,
|
|
44757
|
+
entries: rows.reduce((sum, row) => sum + (parseInt(row.entries, 10) || 0), 0),
|
|
44758
|
+
by_database: rows.map((row) => ({
|
|
44759
|
+
database: row.database ?? null,
|
|
44760
|
+
entries: parseInt(row.entries, 10) || 0,
|
|
44761
|
+
calls: parseInt(row.calls, 10) || 0,
|
|
44762
|
+
called_once: parseInt(row.called_once, 10) || 0,
|
|
44763
|
+
...visible ? { temp_table_text: parseInt(row.temp_table_text, 10) || 0 } : {}
|
|
44764
|
+
}))
|
|
44765
|
+
};
|
|
44766
|
+
if (!visible)
|
|
44767
|
+
out.temp_table_text_error = "the reading role has no pg_read_all_stats: statement texts are hidden";
|
|
44768
|
+
try {
|
|
44769
|
+
const info = (await client.query(`select dealloc, stats_reset, now() as read_at from ${quoted}.pg_stat_statements_info`)).rows[0];
|
|
44770
|
+
if (info) {
|
|
44771
|
+
out.dealloc = parseInt(info.dealloc, 10) || 0;
|
|
44772
|
+
out.stats_reset = d001Iso(info.stats_reset);
|
|
44773
|
+
out.read_at = d001Iso(info.read_at);
|
|
44774
|
+
const reset = info.stats_reset instanceof Date ? info.stats_reset.getTime() : NaN;
|
|
44775
|
+
const read = info.read_at instanceof Date ? info.read_at.getTime() : NaN;
|
|
44776
|
+
if (Number.isFinite(reset) && Number.isFinite(read))
|
|
44777
|
+
out.days_since_reset = Math.round((read - reset) / 864000) / 100;
|
|
44778
|
+
if (out.dealloc && max)
|
|
44779
|
+
out.per_round_at_max = d004PerRound(max);
|
|
44780
|
+
}
|
|
44781
|
+
} catch (err) {
|
|
44782
|
+
out.dealloc_error = a005Error(err);
|
|
44783
|
+
}
|
|
44784
|
+
return out;
|
|
44785
|
+
}
|
|
44786
|
+
async function d004CatalogFacts(client) {
|
|
44787
|
+
const out = {};
|
|
44788
|
+
const fact = async (key, read) => {
|
|
44789
|
+
try {
|
|
44790
|
+
const value = await read();
|
|
44791
|
+
out[key] = value;
|
|
44792
|
+
return value;
|
|
44793
|
+
} catch (err) {
|
|
44794
|
+
out[`${key}_error`] = a005Error(err);
|
|
44795
|
+
return;
|
|
44796
|
+
}
|
|
44797
|
+
};
|
|
44798
|
+
await fact("read_as", async () => (await client.query("select current_user as role, current_database() as database")).rows[0]);
|
|
44799
|
+
const settingsRead = await fact("settings", async () => {
|
|
44800
|
+
const settings = {};
|
|
44801
|
+
for (const row of (await client.query(D001_SETTINGS_SQL, [D004_SETTING_PATTERN])).rows) {
|
|
44802
|
+
const setting = row.setting === null ? "" : String(row.setting);
|
|
44803
|
+
settings[row.name] = {
|
|
44804
|
+
setting,
|
|
44805
|
+
unit: row.unit || "",
|
|
44806
|
+
category: row.category || "",
|
|
44807
|
+
context: row.context || "",
|
|
44808
|
+
vartype: row.vartype || "",
|
|
44809
|
+
source: row.source || "",
|
|
44810
|
+
is_default: setting === row.boot_val,
|
|
44811
|
+
pending_restart: Boolean(row.pending_restart)
|
|
44812
|
+
};
|
|
44813
|
+
}
|
|
44814
|
+
return settings;
|
|
44815
|
+
});
|
|
44816
|
+
await fact("available", async () => {
|
|
44817
|
+
const available = {};
|
|
44818
|
+
for (const row of (await client.query(D004_AVAILABLE_SQL, [D004_EXTENSIONS])).rows) {
|
|
44819
|
+
available[row.name] = { default_version: row.default_version ?? null };
|
|
44820
|
+
}
|
|
44821
|
+
return available;
|
|
44822
|
+
});
|
|
44823
|
+
await fact("overrides", async () => {
|
|
44824
|
+
const rows = (await client.query(D001_OVERRIDES_SQL)).rows;
|
|
44825
|
+
const values = [];
|
|
44826
|
+
for (const row of rows) {
|
|
44827
|
+
for (const [name, value] of Object.entries(d001Config(row.config, D004_OVERRIDE_PATTERN))) {
|
|
44828
|
+
const scope = row.role && row.database ? "role in database" : row.role ? "role" : row.database ? "database" : "all";
|
|
44829
|
+
values.push({ scope, role: row.role ?? null, database: row.database ?? null, setting: name, value });
|
|
44830
|
+
}
|
|
44831
|
+
}
|
|
44832
|
+
return { rows_read: rows.length, values };
|
|
44833
|
+
});
|
|
44834
|
+
const databases = {};
|
|
44835
|
+
let pgssDb = null;
|
|
44836
|
+
let pgssSchema = null;
|
|
44837
|
+
let pgssOther = null;
|
|
44838
|
+
let listed = null;
|
|
44839
|
+
try {
|
|
44840
|
+
listed = (await client.query(D004_DATABASES_SQL)).rows;
|
|
44841
|
+
} catch (err) {
|
|
44842
|
+
out.databases_error = a005Error(err);
|
|
44843
|
+
}
|
|
44844
|
+
const started = Date.now();
|
|
44845
|
+
let opened = 0;
|
|
44846
|
+
try {
|
|
44847
|
+
for (const row of listed || []) {
|
|
44848
|
+
const entry = {};
|
|
44849
|
+
databases[row.datname] = entry;
|
|
44850
|
+
let other = null;
|
|
44851
|
+
try {
|
|
44852
|
+
if (toBool(row.is_current)) {
|
|
44853
|
+
entry.installed = await d004Installed(client);
|
|
44854
|
+
} else {
|
|
44855
|
+
if (!toBool(row.can_connect))
|
|
44856
|
+
throw new Error("the checkup role has no CONNECT privilege on this database");
|
|
44857
|
+
if (opened >= A005_MAX_DATABASES)
|
|
44858
|
+
throw new Error(`not read: more than ${A005_MAX_DATABASES} databases`);
|
|
44859
|
+
if (Date.now() - started > A005_TIME_BUDGET_MS)
|
|
44860
|
+
throw new Error("not read: the time budget ran out");
|
|
44861
|
+
opened += 1;
|
|
44862
|
+
other = await a005OpenDatabase(client, row.datname);
|
|
44863
|
+
entry.installed = await d004Installed(other);
|
|
44864
|
+
}
|
|
44865
|
+
} catch (err) {
|
|
44866
|
+
entry.error = a005Error(err);
|
|
44867
|
+
}
|
|
44868
|
+
const found = entry.installed?.pg_stat_statements;
|
|
44869
|
+
if (found && (pgssDb === null || toBool(row.is_current))) {
|
|
44870
|
+
if (pgssOther)
|
|
44871
|
+
await pgssOther.end().catch(() => {});
|
|
44872
|
+
pgssDb = row.datname;
|
|
44873
|
+
pgssSchema = found.schema;
|
|
44874
|
+
pgssOther = toBool(row.is_current) ? null : other;
|
|
44875
|
+
other = null;
|
|
44876
|
+
}
|
|
44877
|
+
if (other)
|
|
44878
|
+
await other.end().catch(() => {});
|
|
44879
|
+
}
|
|
44880
|
+
if (listed)
|
|
44881
|
+
out.databases = databases;
|
|
44882
|
+
if (listed && (pgssDb === null || pgssSchema === null)) {
|
|
44883
|
+
out.statements_error = "pg_stat_statements is not created in any database read";
|
|
44884
|
+
} else if (listed) {
|
|
44885
|
+
const cap = parseInt(String(settingsRead?.["pg_stat_statements.max"]?.setting ?? ""), 10);
|
|
44886
|
+
const statements = await fact("statements", () => d004Statements(pgssOther ?? client, pgssSchema, Number.isFinite(cap) ? cap : null));
|
|
44887
|
+
if (statements)
|
|
44888
|
+
statements.database = pgssDb;
|
|
44889
|
+
}
|
|
44890
|
+
} catch (err) {
|
|
44891
|
+
out.databases_error = a005Error(err);
|
|
44892
|
+
} finally {
|
|
44893
|
+
if (pgssOther)
|
|
44894
|
+
await pgssOther.end().catch(() => {});
|
|
44895
|
+
}
|
|
44896
|
+
out.monitored_calls_window_error = "the express checkup has no monitoring: one reading, no window";
|
|
44897
|
+
return out;
|
|
44898
|
+
}
|
|
44708
44899
|
var D001_SETTING_PATTERN = "^(log_.*|logging_collector|auto_explain\\..*|shared_preload_libraries|session_preload_libraries|deadlock_timeout)$";
|
|
44709
44900
|
var D001_OVERRIDE_PATTERN = /^(log_.*|auto_explain\..*|session_preload_libraries|statement_timeout)$/;
|
|
44710
44901
|
var D001_BASE_THRESHOLDS_MS = [1000, 1e4];
|
|
@@ -44806,13 +44997,13 @@ function d001Thresholds(settings, overrides) {
|
|
|
44806
44997
|
out.add(value);
|
|
44807
44998
|
return [...out].sort((a, b) => a - b);
|
|
44808
44999
|
}
|
|
44809
|
-
function d001Config(config) {
|
|
45000
|
+
function d001Config(config, pattern = D001_OVERRIDE_PATTERN) {
|
|
44810
45001
|
const out = {};
|
|
44811
45002
|
for (const item of Array.isArray(config) ? config : []) {
|
|
44812
45003
|
const text = String(item);
|
|
44813
45004
|
const at = text.indexOf("=");
|
|
44814
45005
|
const name = at < 0 ? text : text.slice(0, at);
|
|
44815
|
-
if (
|
|
45006
|
+
if (pattern.test(name))
|
|
44816
45007
|
out[name] = at < 0 ? "" : text.slice(at + 1);
|
|
44817
45008
|
}
|
|
44818
45009
|
return out;
|
package/package.json
CHANGED
package/schemas/D004.schema.json
CHANGED
|
@@ -121,16 +121,329 @@
|
|
|
121
121
|
"pg_stat_kcache_status": { "$ref": "#/$defs/kcacheStatus" }
|
|
122
122
|
}
|
|
123
123
|
},
|
|
124
|
+
"catalogSetting": {
|
|
125
|
+
"type": "object",
|
|
126
|
+
"additionalProperties": false,
|
|
127
|
+
"required": [
|
|
128
|
+
"setting",
|
|
129
|
+
"unit",
|
|
130
|
+
"category",
|
|
131
|
+
"context",
|
|
132
|
+
"vartype",
|
|
133
|
+
"source",
|
|
134
|
+
"is_default",
|
|
135
|
+
"pending_restart"
|
|
136
|
+
],
|
|
137
|
+
"properties": {
|
|
138
|
+
"setting": {
|
|
139
|
+
"type": "string"
|
|
140
|
+
},
|
|
141
|
+
"unit": {
|
|
142
|
+
"type": "string"
|
|
143
|
+
},
|
|
144
|
+
"category": {
|
|
145
|
+
"type": "string"
|
|
146
|
+
},
|
|
147
|
+
"context": {
|
|
148
|
+
"type": "string"
|
|
149
|
+
},
|
|
150
|
+
"vartype": {
|
|
151
|
+
"type": "string"
|
|
152
|
+
},
|
|
153
|
+
"source": {
|
|
154
|
+
"type": "string"
|
|
155
|
+
},
|
|
156
|
+
"is_default": {
|
|
157
|
+
"type": "boolean"
|
|
158
|
+
},
|
|
159
|
+
"pending_restart": {
|
|
160
|
+
"type": "boolean"
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
"installed": {
|
|
165
|
+
"type": "object",
|
|
166
|
+
"additionalProperties": {
|
|
167
|
+
"type": "object",
|
|
168
|
+
"additionalProperties": false,
|
|
169
|
+
"required": [
|
|
170
|
+
"version",
|
|
171
|
+
"schema"
|
|
172
|
+
],
|
|
173
|
+
"properties": {
|
|
174
|
+
"version": {
|
|
175
|
+
"type": "string"
|
|
176
|
+
},
|
|
177
|
+
"schema": {
|
|
178
|
+
"type": "string"
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
"observability": {
|
|
184
|
+
"type": "object",
|
|
185
|
+
"additionalProperties": false,
|
|
186
|
+
"properties": {
|
|
187
|
+
"node_error": {
|
|
188
|
+
"type": "string"
|
|
189
|
+
},
|
|
190
|
+
"read_as": {
|
|
191
|
+
"type": "object",
|
|
192
|
+
"additionalProperties": false,
|
|
193
|
+
"required": [
|
|
194
|
+
"role",
|
|
195
|
+
"database"
|
|
196
|
+
],
|
|
197
|
+
"properties": {
|
|
198
|
+
"role": {
|
|
199
|
+
"type": "string"
|
|
200
|
+
},
|
|
201
|
+
"database": {
|
|
202
|
+
"type": "string"
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
"read_as_error": {
|
|
207
|
+
"type": "string"
|
|
208
|
+
},
|
|
209
|
+
"settings": {
|
|
210
|
+
"type": "object",
|
|
211
|
+
"additionalProperties": {
|
|
212
|
+
"$ref": "#/$defs/catalogSetting"
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
"settings_error": {
|
|
216
|
+
"type": "string"
|
|
217
|
+
},
|
|
218
|
+
"available": {
|
|
219
|
+
"type": "object",
|
|
220
|
+
"additionalProperties": {
|
|
221
|
+
"type": "object",
|
|
222
|
+
"additionalProperties": false,
|
|
223
|
+
"required": [
|
|
224
|
+
"default_version"
|
|
225
|
+
],
|
|
226
|
+
"properties": {
|
|
227
|
+
"default_version": {
|
|
228
|
+
"type": [
|
|
229
|
+
"string",
|
|
230
|
+
"null"
|
|
231
|
+
]
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
"available_error": {
|
|
237
|
+
"type": "string"
|
|
238
|
+
},
|
|
239
|
+
"overrides": {
|
|
240
|
+
"type": "object",
|
|
241
|
+
"additionalProperties": false,
|
|
242
|
+
"required": [
|
|
243
|
+
"rows_read",
|
|
244
|
+
"values"
|
|
245
|
+
],
|
|
246
|
+
"properties": {
|
|
247
|
+
"rows_read": {
|
|
248
|
+
"type": "integer"
|
|
249
|
+
},
|
|
250
|
+
"values": {
|
|
251
|
+
"type": "array",
|
|
252
|
+
"items": {
|
|
253
|
+
"type": "object",
|
|
254
|
+
"additionalProperties": false,
|
|
255
|
+
"required": [
|
|
256
|
+
"scope",
|
|
257
|
+
"role",
|
|
258
|
+
"database",
|
|
259
|
+
"setting",
|
|
260
|
+
"value"
|
|
261
|
+
],
|
|
262
|
+
"properties": {
|
|
263
|
+
"scope": {
|
|
264
|
+
"enum": [
|
|
265
|
+
"all",
|
|
266
|
+
"role",
|
|
267
|
+
"database",
|
|
268
|
+
"role in database"
|
|
269
|
+
]
|
|
270
|
+
},
|
|
271
|
+
"role": {
|
|
272
|
+
"type": [
|
|
273
|
+
"string",
|
|
274
|
+
"null"
|
|
275
|
+
]
|
|
276
|
+
},
|
|
277
|
+
"database": {
|
|
278
|
+
"type": [
|
|
279
|
+
"string",
|
|
280
|
+
"null"
|
|
281
|
+
]
|
|
282
|
+
},
|
|
283
|
+
"setting": {
|
|
284
|
+
"type": "string"
|
|
285
|
+
},
|
|
286
|
+
"value": {
|
|
287
|
+
"type": "string"
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
"overrides_error": {
|
|
295
|
+
"type": "string"
|
|
296
|
+
},
|
|
297
|
+
"databases": {
|
|
298
|
+
"type": "object",
|
|
299
|
+
"additionalProperties": {
|
|
300
|
+
"type": "object",
|
|
301
|
+
"additionalProperties": false,
|
|
302
|
+
"properties": {
|
|
303
|
+
"installed": {
|
|
304
|
+
"$ref": "#/$defs/installed"
|
|
305
|
+
},
|
|
306
|
+
"error": {
|
|
307
|
+
"type": "string"
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
"statements": {
|
|
313
|
+
"type": "object",
|
|
314
|
+
"additionalProperties": false,
|
|
315
|
+
"required": [
|
|
316
|
+
"schema",
|
|
317
|
+
"entries",
|
|
318
|
+
"by_database"
|
|
319
|
+
],
|
|
320
|
+
"properties": {
|
|
321
|
+
"schema": {
|
|
322
|
+
"type": "string"
|
|
323
|
+
},
|
|
324
|
+
"database": {
|
|
325
|
+
"type": "string"
|
|
326
|
+
},
|
|
327
|
+
"entries": {
|
|
328
|
+
"type": "integer"
|
|
329
|
+
},
|
|
330
|
+
"by_database": {
|
|
331
|
+
"type": "array",
|
|
332
|
+
"items": {
|
|
333
|
+
"type": "object",
|
|
334
|
+
"additionalProperties": false,
|
|
335
|
+
"required": [
|
|
336
|
+
"database",
|
|
337
|
+
"entries",
|
|
338
|
+
"calls",
|
|
339
|
+
"called_once"
|
|
340
|
+
],
|
|
341
|
+
"properties": {
|
|
342
|
+
"database": {
|
|
343
|
+
"type": [
|
|
344
|
+
"string",
|
|
345
|
+
"null"
|
|
346
|
+
]
|
|
347
|
+
},
|
|
348
|
+
"entries": {
|
|
349
|
+
"type": "integer"
|
|
350
|
+
},
|
|
351
|
+
"calls": {
|
|
352
|
+
"type": "integer"
|
|
353
|
+
},
|
|
354
|
+
"called_once": {
|
|
355
|
+
"type": "integer"
|
|
356
|
+
},
|
|
357
|
+
"temp_table_text": {
|
|
358
|
+
"type": "integer"
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
"temp_table_text_error": {
|
|
364
|
+
"type": "string"
|
|
365
|
+
},
|
|
366
|
+
"dealloc": {
|
|
367
|
+
"type": "integer"
|
|
368
|
+
},
|
|
369
|
+
"stats_reset": {
|
|
370
|
+
"type": [
|
|
371
|
+
"string",
|
|
372
|
+
"null"
|
|
373
|
+
]
|
|
374
|
+
},
|
|
375
|
+
"read_at": {
|
|
376
|
+
"type": [
|
|
377
|
+
"string",
|
|
378
|
+
"null"
|
|
379
|
+
]
|
|
380
|
+
},
|
|
381
|
+
"dealloc_error": {
|
|
382
|
+
"type": "string"
|
|
383
|
+
},
|
|
384
|
+
"per_round_at_max": {
|
|
385
|
+
"type": "integer"
|
|
386
|
+
},
|
|
387
|
+
"days_since_reset": {
|
|
388
|
+
"type": "number"
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
"statements_error": {
|
|
393
|
+
"type": "string"
|
|
394
|
+
},
|
|
395
|
+
"databases_error": {
|
|
396
|
+
"type": "string"
|
|
397
|
+
},
|
|
398
|
+
"monitored_calls_window": {
|
|
399
|
+
"type": "array",
|
|
400
|
+
"items": {
|
|
401
|
+
"type": "object",
|
|
402
|
+
"additionalProperties": false,
|
|
403
|
+
"required": [
|
|
404
|
+
"start",
|
|
405
|
+
"end",
|
|
406
|
+
"days",
|
|
407
|
+
"total",
|
|
408
|
+
"database",
|
|
409
|
+
"statements"
|
|
410
|
+
],
|
|
411
|
+
"properties": {
|
|
412
|
+
"start": {
|
|
413
|
+
"type": "string"
|
|
414
|
+
},
|
|
415
|
+
"end": {
|
|
416
|
+
"type": "string"
|
|
417
|
+
},
|
|
418
|
+
"days": {
|
|
419
|
+
"type": "number"
|
|
420
|
+
},
|
|
421
|
+
"total": {
|
|
422
|
+
"type": "integer"
|
|
423
|
+
},
|
|
424
|
+
"database": {
|
|
425
|
+
"type": "string"
|
|
426
|
+
},
|
|
427
|
+
"statements": {
|
|
428
|
+
"type": "integer"
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
"monitored_calls_window_error": {
|
|
434
|
+
"type": "string"
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
},
|
|
124
438
|
"nodeResult": {
|
|
125
439
|
"type": "object",
|
|
126
440
|
"additionalProperties": false,
|
|
127
441
|
"required": ["data"],
|
|
128
442
|
"properties": {
|
|
129
443
|
"data": { "$ref": "#/$defs/data" },
|
|
444
|
+
"observability": { "$ref": "#/$defs/observability" },
|
|
130
445
|
"postgres_version": { "$ref": "#/$defs/postgresVersion" }
|
|
131
446
|
}
|
|
132
447
|
}
|
|
133
448
|
}
|
|
134
449
|
}
|
|
135
|
-
|
|
136
|
-
|
package/schemas/K003.schema.json
CHANGED
|
@@ -144,9 +144,81 @@
|
|
|
144
144
|
"summary": { "$ref": "#/$defs/summary" }
|
|
145
145
|
}
|
|
146
146
|
},
|
|
147
|
+
"hourlyNumbers": { "type": "array", "items": { "type": "number" } },
|
|
148
|
+
"hourlyQueryEntry": {
|
|
149
|
+
"type": "object",
|
|
150
|
+
"additionalProperties": false,
|
|
151
|
+
"required": ["queryid", "total_time_ms", "total_exec_time_ms", "total_plan_time_ms", "hourly_time_ms", "hourly_exec_time_ms", "hourly_plan_time_ms"],
|
|
152
|
+
"properties": {
|
|
153
|
+
"queryid": { "type": "string" },
|
|
154
|
+
"total_time_ms": { "type": "number" },
|
|
155
|
+
"total_exec_time_ms": { "type": "number" },
|
|
156
|
+
"total_plan_time_ms": { "type": "number" },
|
|
157
|
+
"hourly_time_ms": { "$ref": "#/$defs/hourlyNumbers" },
|
|
158
|
+
"hourly_exec_time_ms": { "$ref": "#/$defs/hourlyNumbers" },
|
|
159
|
+
"hourly_plan_time_ms": { "type": ["array", "null"], "items": { "type": "number" } },
|
|
160
|
+
"calls": { "type": "number" },
|
|
161
|
+
"rows": { "type": "number" },
|
|
162
|
+
"shared_blks_hit_bytes": { "type": "number" },
|
|
163
|
+
"shared_blks_read_bytes": { "type": "number" },
|
|
164
|
+
"wal_bytes": { "type": "number" },
|
|
165
|
+
"temp_bytes_written": { "type": "number" },
|
|
166
|
+
"query_text": { "type": "string" },
|
|
167
|
+
"is_monitoring": { "type": "boolean" },
|
|
168
|
+
"relations": { "type": "array", "items": { "type": "string" }, "maxItems": 3 }
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
"exportRule": {
|
|
172
|
+
"type": "object",
|
|
173
|
+
"additionalProperties": false,
|
|
174
|
+
"required": ["top_n_per_database", "ranked_by", "min_calls", "min_exec_time_ms", "interval_seconds"],
|
|
175
|
+
"properties": {
|
|
176
|
+
"top_n_per_database": { "type": "integer" },
|
|
177
|
+
"ranked_by": { "type": "string" },
|
|
178
|
+
"min_calls": { "type": "integer" },
|
|
179
|
+
"min_exec_time_ms": { "type": "number" },
|
|
180
|
+
"interval_seconds": { "type": "integer" }
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
"hourlySummary": {
|
|
184
|
+
"type": "object",
|
|
185
|
+
"additionalProperties": false,
|
|
186
|
+
"required": ["queries_returned", "total_time_ms", "total_time_tracked_queries_ms", "total_time_other_ms", "time_range_hours", "hourly_timestamps", "limit", "plan_time_available", "note"],
|
|
187
|
+
"properties": {
|
|
188
|
+
"queries_returned": { "type": "integer" },
|
|
189
|
+
"total_time_ms": { "type": "number" },
|
|
190
|
+
"total_time_tracked_queries_ms": { "type": "number" },
|
|
191
|
+
"total_time_other_ms": { "type": "number" },
|
|
192
|
+
"time_range_hours": { "type": "integer" },
|
|
193
|
+
"hourly_timestamps": { "type": "array", "items": { "type": "integer" } },
|
|
194
|
+
"limit": { "type": "integer" },
|
|
195
|
+
"plan_time_available": { "type": "boolean" },
|
|
196
|
+
"note": { "type": "string" },
|
|
197
|
+
"window_start": { "type": "string" },
|
|
198
|
+
"window_end": { "type": "string" },
|
|
199
|
+
"window_seconds": { "type": "integer" },
|
|
200
|
+
"export_rule": { "$ref": "#/$defs/exportRule" },
|
|
201
|
+
"total_calls": { "type": "number" },
|
|
202
|
+
"statements_exported_max": { "type": "integer" },
|
|
203
|
+
"statements_reset_max": { "type": "integer" },
|
|
204
|
+
"statements_reset_at": { "type": "string" }
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
"hourlyDbEntry": {
|
|
208
|
+
"type": "object",
|
|
209
|
+
"additionalProperties": false,
|
|
210
|
+
"required": ["top_queries", "other_time_hourly", "other_exec_time_hourly", "other_plan_time_hourly", "summary"],
|
|
211
|
+
"properties": {
|
|
212
|
+
"top_queries": { "type": "array", "items": { "$ref": "#/$defs/hourlyQueryEntry" } },
|
|
213
|
+
"other_time_hourly": { "$ref": "#/$defs/hourlyNumbers" },
|
|
214
|
+
"other_exec_time_hourly": { "$ref": "#/$defs/hourlyNumbers" },
|
|
215
|
+
"other_plan_time_hourly": { "type": ["array", "null"], "items": { "type": "number" } },
|
|
216
|
+
"summary": { "$ref": "#/$defs/hourlySummary" }
|
|
217
|
+
}
|
|
218
|
+
},
|
|
147
219
|
"data": {
|
|
148
220
|
"type": "object",
|
|
149
|
-
"additionalProperties": { "$ref": "#/$defs/dbEntry" }
|
|
221
|
+
"additionalProperties": { "anyOf": [{ "$ref": "#/$defs/hourlyDbEntry" }, { "$ref": "#/$defs/dbEntry" }] }
|
|
150
222
|
},
|
|
151
223
|
"nodeResult": {
|
|
152
224
|
"type": "object",
|
|
@@ -159,5 +231,3 @@
|
|
|
159
231
|
}
|
|
160
232
|
}
|
|
161
233
|
}
|
|
162
|
-
|
|
163
|
-
|