Add domain traffic metrics and Grafana dashboard
Build and Deploy Gateway / build-and-push (push) Successful in 14s
Build and Deploy Gateway / deploy (push) Successful in 13s

This commit is contained in:
2026-08-08 01:57:00 +03:00
parent 10888ac012
commit ca53b671ee
20 changed files with 612 additions and 17 deletions
+5 -1
View File
@@ -32,7 +32,7 @@ test('metrics route reads the current snapshot before static fallback', () => {
const staticFallback = server.indexOf(': serveStatic(req, res)');
assert.ok(metricsRoute >= 0 && metricsRoute < staticFallback);
assert.match(server, /requestUrl\.pathname === '\/metrics'[\s\S]*deviceInventory\.snapshot\(\)/);
assert.match(server, /requestUrl\.pathname === '\/metrics'[\s\S]*deviceInventory\.metricsSnapshot\(\)/);
assert.doesNotMatch(server.slice(metricsRoute, staticFallback), /deviceInventory\.refresh\(/);
});
@@ -45,8 +45,12 @@ test('Grafana dashboard covers global and named per-device traffic', () => {
assert.ok(titles.includes('Общая скорость за 5 минут'));
assert.ok(titles.includes('Устройства по объёму'));
assert.ok(titles.includes('Скорость выбранных устройств'));
assert.ok(titles.includes('Сервисы за выбранный период'));
assert.ok(titles.includes('Домены выбранных устройств'));
assert.ok(expressions.some((expression) => expression.includes('harbor_traffic_bytes_total')));
assert.ok(expressions.some((expression) => expression.includes('harbor_device_traffic_bytes_total')));
assert.ok(expressions.some((expression) => expression.includes('harbor_device_domain_traffic_bytes_total[$__range]')));
assert.ok(expressions.some((expression) => expression.includes('harbor_domain_traffic_last_observed_timestamp_seconds')));
assert.ok(expressions.some((expression) => expression.includes('group_left (name, ip)')));
assert.equal(dashboard.templating.list[0].query.query, 'label_values(harbor_device_info, name)');
});