加入自定义指标支持
This commit is contained in:
@@ -146,7 +146,9 @@ function getPublicSiteSettings(settings = {}) {
|
||||
icp_filing: settings.icp_filing || null,
|
||||
ps_filing: settings.ps_filing || null,
|
||||
network_data_sources: settings.network_data_sources || null,
|
||||
show_server_ip: settings.show_server_ip ? 1 : 0
|
||||
show_server_ip: settings.show_server_ip ? 1 : 0,
|
||||
ip_metric_name: settings.ip_metric_name || null,
|
||||
ip_label_name: settings.ip_label_name || 'address'
|
||||
};
|
||||
}
|
||||
|
||||
@@ -551,6 +553,8 @@ app.post('/api/setup/init', ensureSetupAccess, async (req, res) => {
|
||||
ps_filing VARCHAR(255),
|
||||
network_data_sources TEXT,
|
||||
show_server_ip TINYINT(1) DEFAULT 0,
|
||||
ip_metric_name VARCHAR(100) DEFAULT NULL,
|
||||
ip_label_name VARCHAR(100) DEFAULT 'address',
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||
`);
|
||||
@@ -566,6 +570,8 @@ app.post('/api/setup/init', ensureSetupAccess, async (req, res) => {
|
||||
await connection.query("ALTER TABLE site_settings ADD COLUMN IF NOT EXISTS require_login_for_server_details TINYINT(1) DEFAULT 1 AFTER p95_type");
|
||||
await connection.query("ALTER TABLE site_settings ADD COLUMN IF NOT EXISTS network_data_sources TEXT AFTER ps_filing");
|
||||
await connection.query("ALTER TABLE site_settings ADD COLUMN IF NOT EXISTS show_server_ip TINYINT(1) DEFAULT 0 AFTER network_data_sources");
|
||||
await connection.query("ALTER TABLE site_settings ADD COLUMN IF NOT EXISTS ip_metric_name VARCHAR(100) DEFAULT NULL AFTER show_server_ip");
|
||||
await connection.query("ALTER TABLE site_settings ADD COLUMN IF NOT EXISTS ip_label_name VARCHAR(100) DEFAULT 'address' AFTER ip_metric_name");
|
||||
await connection.query(`
|
||||
CREATE TABLE IF NOT EXISTS latency_routes (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
@@ -923,7 +929,9 @@ app.post('/api/settings', requireAuth, async (req, res) => {
|
||||
icp_filing: icp_filing !== undefined ? icp_filing : (current.icp_filing || null),
|
||||
ps_filing: ps_filing !== undefined ? ps_filing : (current.ps_filing || null),
|
||||
network_data_sources: network_data_sources !== undefined ? network_data_sources : (current.network_data_sources || null),
|
||||
show_server_ip: show_server_ip !== undefined ? (show_server_ip ? 1 : 0) : (current.show_server_ip || 0)
|
||||
show_server_ip: show_server_ip !== undefined ? (show_server_ip ? 1 : 0) : (current.show_server_ip || 0),
|
||||
ip_metric_name: ip_metric_name !== undefined ? ip_metric_name : (current.ip_metric_name || null),
|
||||
ip_label_name: ip_label_name !== undefined ? ip_label_name : (current.ip_label_name || 'address')
|
||||
};
|
||||
|
||||
await db.query(`
|
||||
@@ -1216,8 +1224,8 @@ app.get('/api/metrics/server-details', requireServerDetailsAccess, async (req, r
|
||||
}
|
||||
const sourceUrl = rows[0].url;
|
||||
|
||||
// Fetch detailed metrics
|
||||
const details = await prometheusService.getServerDetails(sourceUrl, instance, job);
|
||||
// Fetch detailed metrics with custom metric configuration if present
|
||||
const details = await prometheusService.getServerDetails(sourceUrl, instance, job, req.siteSettings);
|
||||
|
||||
// Dynamic field removal based on security settings: PHYSICAL DATA STRIPPING
|
||||
if (!req.siteSettings || !req.siteSettings.show_server_ip) {
|
||||
|
||||
Reference in New Issue
Block a user