/
githubmirror
/
slo-tests
Обзор
Документация
Войти
/
githubmirror
/
slo-tests
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
reusable-workflow
scripts/parseGrafanaOutput.js
32 строки
767 B
Ilya Shevchenko
feat: add scripts to test grafana output
18 янв 2023, 18:28
18 янв 2023, 18:28
cc9b8a1
Код
Авторство
О чём код?
const fs = require("fs"); console.log("Arguments", process.argv); let [, , inputPath, outputPath] = process.argv; let results; try { const file = JSON.parse(fs.readFileSync(inputPath)); results = file.results; } catch (error) { console.error("Error while reading file", error); process.exit(1); } const queries = Object.keys(results); console.log("queries", queries); const res = new Map(); queries.map((q) => { results[q].frames.map((v) => { const key = Object.values(v.schema.fields[1].labels).join(";"); res.set(key, { ...res.get(key), ...v.schema.fields[1].labels, [q]: v.data.values[1][0], }); }); }); const array = Array.from(res.values()); console.log(array); fs.writeFileSync(outputPath, JSON.stringify(array));