修复语法错误

This commit is contained in:
CN-JS-HuiBai
2026-04-10 22:25:04 +08:00
parent cb27d1a249
commit 2cd6c6ef27

View File

@@ -611,6 +611,7 @@ async function getServerDetails(baseUrl, instance, job, settings = {}) {
// 2. Fallback to Prometheus Targets API
if (!foundIp) {
try {
const targets = await getTargets(baseUrl);
const matchedTarget = targets.find(t => t.labels && t.labels.instance === node && t.labels.job === job);
if (matchedTarget) {
@@ -627,16 +628,17 @@ async function getServerDetails(baseUrl, instance, job, settings = {}) {
}
foundIp = true;
} catch (e) {
results.ipv4 = [];
// Simple fallback if URL parsing fails
const host = scrapeUrl.split('//').pop().split('/')[0].split(':')[0];
if (host) {
results.ipv4 = [host];
results.ipv6 = [];
foundIp = true;
}
} else {
results.ipv4 = [];
results.ipv6 = [];
}
} else {
results.ipv4 = [];
results.ipv6 = [];
}
} catch (e) {
console.error(`[Prometheus] Error fetching target info for ${node}:`, e.message);
}
}
@@ -646,8 +648,8 @@ async function getServerDetails(baseUrl, instance, job, settings = {}) {
}
} catch (err) {
console.error(`[Prometheus] Critical error resolving IPs for ${node}:`, err.message);
results.ipv4 = [];
results.ipv6 = [];
results.ipv4 = results.ipv4 || [];
results.ipv6 = results.ipv6 || [];
}
// Group partitions