diff --git a/public/js/app.js b/public/js/app.js index e3535e7..6dca5af 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -328,7 +328,6 @@
${escapeHtml(server.job)}
-
${escapeHtml(server.instance)}
${escapeHtml(server.source)} diff --git a/server/prometheus-service.js b/server/prometheus-service.js index 8557e44..90547dc 100644 --- a/server/prometheus-service.js +++ b/server/prometheus-service.js @@ -42,18 +42,18 @@ async function testConnection(url) { // Using native fetch to avoid follow-redirects/axios "protocol mismatch" issues in some Node environments const controller = new AbortController(); const timer = setTimeout(() => controller.abort(), QUERY_TIMEOUT); - + // Node native fetch - handles http/https automatically const res = await fetch(`${normalized}/api/v1/status/buildinfo`, { signal: controller.signal }); - + clearTimeout(timer); if (!res.ok) { throw new Error(`Prometheus returned HTTP ${res.status}`); } - + const data = await res.json(); return data?.data?.version || 'unknown'; } catch (err) { @@ -74,17 +74,17 @@ async function query(baseUrl, expr) { const params = new URLSearchParams({ query: expr }); const controller = new AbortController(); const timer = setTimeout(() => controller.abort(), QUERY_TIMEOUT); - + const res = await fetch(`${url}/api/v1/query?${params.toString()}`, { signal: controller.signal }); - + clearTimeout(timer); if (!res.ok) { throw new Error(`Prometheus returned HTTP ${res.status}`); } - + const data = await res.json(); if (data.status !== 'success') { throw new Error(`Prometheus query failed: ${data.error || 'unknown error'}`); @@ -107,17 +107,17 @@ async function queryRange(baseUrl, expr, start, end, step) { const params = new URLSearchParams({ query: expr, start, end, step }); const controller = new AbortController(); const timer = setTimeout(() => controller.abort(), QUERY_TIMEOUT); - + const res = await fetch(`${url}/api/v1/query_range?${params.toString()}`, { signal: controller.signal }); - + clearTimeout(timer); if (!res.ok) { throw new Error(`Prometheus returned HTTP ${res.status}`); } - + const data = await res.json(); if (data.status !== 'success') { throw new Error(`Prometheus range query failed: ${data.error || 'unknown error'}`); @@ -180,6 +180,7 @@ async function getOverviewMetrics(url, sourceName) { const getOrCreate = (metric) => { const key = metric.instance; + if (!instances.has(key)) { instances.set(key, { instance: key,