Add support for pg_stat_statements configuration in Targets

This commit introduces a `use_pg_stat_statements` flag for targets, allowing users to enable or disable the use of `pg_stat_statements` for query insights. It includes database schema changes, backend logic, and UI updates to manage this setting in both creation and editing workflows.
This commit is contained in:
2026-02-12 13:39:57 +01:00
parent 839943d9fd
commit 712bec3fea
8 changed files with 215 additions and 15 deletions

View File

@@ -75,8 +75,10 @@ export function QueryInsightsPage() {
(async () => {
try {
const t = await apiFetch("/targets", {}, tokens, refresh);
setTargets(t);
if (t.length > 0) setTargetId(String(t[0].id));
const supported = t.filter((item) => item.use_pg_stat_statements !== false);
setTargets(supported);
if (supported.length > 0) setTargetId(String(supported[0].id));
else setTargetId("");
} catch (e) {
setError(String(e.message || e));
} finally {
@@ -133,11 +135,17 @@ export function QueryInsightsPage() {
<div className="query-insights-page">
<h2>Query Insights</h2>
<p>Note: This section requires the <code>pg_stat_statements</code> extension on the monitored target.</p>
{targets.length === 0 && !loading && (
<div className="card">
No targets with enabled <code>pg_stat_statements</code> are available.
Enable it in <strong>Targets Management</strong> for a target to use Query Insights.
</div>
)}
{error && <div className="card error">{error}</div>}
<div className="card query-toolbar">
<div className="field">
<label>Target</label>
<select value={targetId} onChange={(e) => setTargetId(e.target.value)}>
<select value={targetId} onChange={(e) => setTargetId(e.target.value)} disabled={!targets.length}>
{targets.map((t) => (
<option key={t.id} value={t.id}>
{t.name}