collabSupport/services/voiceDiag/checks/wan/wanLoss.js
jmcqueen b802383441 Add Prisma SD-WAN voice-quality enrichment for /phonestatus + /voicediag
Introduces a full Palo Alto Prisma SD-WAN integration (dual-mode SASE
OAuth 2.0 / legacy CloudGenix auth, pagination, 429 backoff, session
priming) that surfaces per-path latency/jitter/loss/MOS, site
healthscore, link state, and alarm data for a store. Wired into the
/phonestatus WAN follow-up and eight new /voicediag WAN checks graded
against ITU-T G.114 / RFC 3550 defaults (env-overridable via
WAN_STANDARD_*).

Also adds a shape-aware detail renderer for /voicediag (per-link
tables with verdict icons instead of a stringified JSON dump) and a
--window flag (15m / 1h / 6h / 24h / 1d, env default via
WAN_STANDARD_WINDOW_MINUTES) so operators can widen the look-back
without redeploying. scripts/prismaProbe.js is bundled as a CLI for
schema iteration against a live tenant.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-09 09:45:29 -04:00

50 lines
1.2 KiB
JavaScript

// src/services/voiceDiag/checks/wan/wanLoss.js
//
// Per-path WAN packet loss (LQM %, 0-100). Voice codec loss
// tolerance:
// - <= 1% : good (PLC hides it)
// - 1-3% : warn (audible artifacts on longer calls)
// - > 3% : error (words dropping, users repeating themselves)
//
// Both thresholds are env-configurable via WAN_STANDARD_LOSS_*.
import {
maybeSkippedByKillSwitch,
getLinks,
getLossWarnPct,
getLossErrorPct,
evaluatePerLinkMetric,
} from './_helpers.js';
export const WAN_LOSS_STANDARDS = Object.freeze({
maxWarnPct: 1,
maxErrorPct: 3,
unit: '%',
reference: 'G.711 PLC tolerance envelope',
});
export const wanLossCheck = {
id: 'wanLoss',
label: 'SD-WAN Packet Loss (per path)',
requires: ['sdwanSite'],
scope: null,
standards: WAN_LOSS_STANDARDS,
async run(ctx) {
const skip = maybeSkippedByKillSwitch(wanLossCheck);
if (skip) return skip;
const warnThresh = getLossWarnPct();
const errorThresh = getLossErrorPct();
return evaluatePerLinkMetric({
links: getLinks(ctx),
metricKey: 'lossPct',
label: 'packet loss',
unit: '%',
warnThresh,
errorThresh,
lowIsBad: false,
standardLabel: `warn > ${warnThresh}%, error > ${errorThresh}%`,
});
},
};