Clarify VPN and Direct traffic metrics in Grafana dashboard
This commit is contained in:
@@ -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) => [
|
||||
|
||||
Reference in New Issue
Block a user