Refine Grafana traffic dashboard and documentation
This commit is contained in:
@@ -36,21 +36,42 @@ test('metrics route reads the current snapshot before static fallback', () => {
|
||||
assert.doesNotMatch(server.slice(metricsRoute, staticFallback), /deviceInventory\.refresh\(/);
|
||||
});
|
||||
|
||||
test('Grafana dashboard covers global and named per-device traffic', () => {
|
||||
test('Grafana dashboard is organized around period ranking and one stable device selection', () => {
|
||||
const expressions = dashboard.panels.flatMap((panel) => panel.targets || []).map(({ expr }) => expr).filter(Boolean);
|
||||
const titles = dashboard.panels.map(({ title }) => title);
|
||||
const deviceVariable = dashboard.templating.list[0];
|
||||
const freshness = dashboard.panels.find(({ id }) => id === 2);
|
||||
const topDevices = dashboard.panels.find(({ id }) => id === 5);
|
||||
const domains = dashboard.panels.find(({ id }) => id === 9);
|
||||
|
||||
assert.equal(dashboard.title, 'Harbor Gateway Traffic');
|
||||
assert.ok(titles.includes('Всего учтено Harbor'));
|
||||
assert.ok(titles.includes('Общая скорость за 5 минут'));
|
||||
assert.ok(titles.includes('Устройства по объёму'));
|
||||
assert.ok(titles.includes('Скорость выбранных устройств'));
|
||||
assert.ok(titles.includes('Сервисы за выбранный период'));
|
||||
assert.ok(titles.includes('Домены выбранных устройств'));
|
||||
assert.equal(dashboard.title, 'Harbor Gateway: трафик');
|
||||
assert.equal(dashboard.refresh, '30s');
|
||||
assert.deepEqual(titles.filter((title) => ['Обзор', 'Устройство', 'Сервисы и домены', 'Техническая детализация'].includes(title)), [
|
||||
'Обзор',
|
||||
'Устройство',
|
||||
'Сервисы и домены',
|
||||
'Техническая детализация',
|
||||
]);
|
||||
assert.ok(titles.includes('Скорость сейчас, средняя за 5 минут'));
|
||||
assert.ok(titles.includes('Топ-10 устройств за выбранный период'));
|
||||
assert.ok(titles.includes('${device_id:text}: накоплено'));
|
||||
assert.ok(titles.includes('${device_id:text}: сервисы за период'));
|
||||
assert.ok(titles.includes('${device_id:text}: домены за период'));
|
||||
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_device_domain_traffic_bytes_total{device_id="$device_id"}[$__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)');
|
||||
assert.match(topDevices.targets[0].expr, /^topk\(10,[\s\S]*increase\(harbor_device_traffic_bytes_total\[\$__range\]\)[\s\S]*> 0[\s\S]*group_left \(name, ip\)/);
|
||||
assert.equal(topDevices.options.sortBy[0].desc, true);
|
||||
assert.match(topDevices.fieldConfig.overrides[1].properties[0].value[0].url, /var-device_id=\$\{__data\.fields/);
|
||||
assert.deepEqual(freshness.fieldConfig.defaults.thresholds.steps.map(({ value }) => value), [null, 60, 120]);
|
||||
assert.equal(freshness.fieldConfig.defaults.noValue, 'Нет данных');
|
||||
assert.equal(deviceVariable.name, 'device_id');
|
||||
assert.equal(deviceVariable.multi, false);
|
||||
assert.equal(deviceVariable.includeAll, false);
|
||||
assert.match(deviceVariable.query.query, /query_result\(label_join\(/);
|
||||
assert.match(deviceVariable.regex, /<text>/);
|
||||
assert.match(deviceVariable.regex, /<value>/);
|
||||
assert.deepEqual(domains.transformations[0].options.indexByName, { service: 0, domain: 1, Value: 2 });
|
||||
assert.match(domains.targets[0].expr, /^topk\(15,[\s\S]*> 0\)$/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user