Browse Source

upd tsdb-kit to the latest version

pull/3/head
rozetko 2 years ago
parent
commit
bb22cf887f
  1. 2
      package.json
  2. 8
      src/services/exporter.ts
  3. 8
      yarn.lock

2
package.json

@ -11,7 +11,7 @@
"license": "ISC", "license": "ISC",
"dependencies": {}, "dependencies": {},
"devDependencies": { "devDependencies": {
"@corpglory/tsdb-kit": "^1.1.1", "@corpglory/tsdb-kit": "^2.0.1",
"axios": "^1.2.1", "axios": "^1.2.1",
"express": "^4.18.2", "express": "^4.18.2",
"fast-csv": "^4.3.6", "fast-csv": "^4.3.6",

8
src/services/exporter.ts

@ -4,7 +4,9 @@ import { apiKeys } from '../config';
import { promisify } from '../utils'; import { promisify } from '../utils';
import { ExportStatus } from '../types/export-status'; import { ExportStatus } from '../types/export-status';
import { Metric, queryByMetric } from '@corpglory/tsdb-kit'; import { QueryConfig, queryByConfig } from '@corpglory/tsdb-kit';
// TODO: export QueryType directly from @corpglory/tsdb-kit
import { QueryType } from '@corpglory/tsdb-kit/lib/connectors';
import * as moment from 'moment'; import * as moment from 'moment';
import * as csv from 'fast-csv'; import * as csv from 'fast-csv';
@ -60,7 +62,7 @@ export class Exporter {
this.validateTargets(data); this.validateTargets(data);
const targets = data.map(target => ({ const targets = data.map(target => ({
...target, ...target,
metric: new Metric(target.datasource, target.targets) metric: new QueryConfig(QueryType.GRAFANA, target.datasource, target.targets)
})); }));
this.datasource = data.length === 1 ? data[0].datasourceName : 'all'; this.datasource = data.length === 1 ? data[0].datasourceName : 'all';
@ -82,7 +84,7 @@ export class Exporter {
const host = new URL(target.panelUrl).origin; const host = new URL(target.panelUrl).origin;
const apiKey = apiKeys[host]; const apiKey = apiKeys[host];
const datasourceMetrics = await queryByMetric(target.metric, target.panelUrl, from, to, apiKey); const datasourceMetrics = await queryByConfig(target.metric, target.panelUrl, from, to, apiKey);
const column = `${target.panelId}` + const column = `${target.panelId}` +
`-${target.panelTitle.replace(' ', '-')}-${datasourceMetrics.columns[1]}`; `-${target.panelTitle.replace(' ', '-')}-${datasourceMetrics.columns[1]}`;

8
yarn.lock

@ -2,10 +2,10 @@
# yarn lockfile v1 # yarn lockfile v1
"@corpglory/tsdb-kit@^1.1.1": "@corpglory/tsdb-kit@^2.0.1":
version "1.1.1" version "2.0.1"
resolved "https://registry.yarnpkg.com/@corpglory/tsdb-kit/-/tsdb-kit-1.1.1.tgz#ad2c85a4c05748db56c2a65138f2f0d8fd48cdd8" resolved "https://registry.yarnpkg.com/@corpglory/tsdb-kit/-/tsdb-kit-2.0.1.tgz#13435a69b2bb8c9890b838a06038daf76e96ec39"
integrity sha512-OmJdgeFavbbKpXsQ8Aq1Sb8NvaMgPhdXXPArBjnzciizi5WwLs/O91S2TOztZWljnTi+mH+TpWKy9ryH3AuGaw== integrity sha512-qIoCy0DXjPFkAE/G9URNVJ56vfU9SPyPoNR2wJSRut6vA6eLP8kljFf4GQE/7/yFpvulHI9+RT9UrlhImWbEZA==
dependencies: dependencies:
axios "^0.18.0" axios "^0.18.0"
moment "^2.22.2" moment "^2.22.2"

Loading…
Cancel
Save