Clarify VPN and Direct traffic metrics in Grafana dashboard
Build and Deploy Gateway / build-and-push (push) Successful in 31s
Build and Deploy Gateway / deploy (push) Successful in 7s

This commit is contained in:
2026-09-01 07:01:26 +03:00
parent 76a99f098a
commit ab14fc979e
8 changed files with 316 additions and 91 deletions
+15
View File
@@ -4,6 +4,7 @@ const COUNTER_PATTERN = /^\d+$/;
const SIGNED_DECIMAL_PATTERN = /^-?\d+$/;
const COLLECTOR_MODES = new Set(['snapshot', 'shadow', 'native']);
const COLLECTOR_WRITERS = new Set(['snapshot', 'native']);
const APPLIED_POLICY_VALUES: Readonly<Record<string, string>> = Object.freeze({ direct: '0', vpn: '1' });
const COLLECTOR_STATES = new Set([
'connecting', 'live', 'degraded', 'stale', 'stopped', 'incompatible', 'disabled',
]);
@@ -93,6 +94,20 @@ export function renderPrometheusMetrics(value: unknown) {
ip: device.ip || '',
}, '1');
}
lines.push(
'# HELP harbor_device_applied_policy Current applied device policy: 0 Direct, 1 VPN.',
'# TYPE harbor_device_applied_policy gauge',
);
for (const device of devices) {
const appliedPolicy = String(device.appliedPolicy || '');
if (!Object.hasOwn(APPLIED_POLICY_VALUES, appliedPolicy)) {
throw new Error('Invalid applied device policy');
}
metric(lines, 'harbor_device_applied_policy', {
device_id: device.id,
}, APPLIED_POLICY_VALUES[appliedPolicy]);
}
}
const deviceTraffic = devices.flatMap((device) => [