diff --git a/package.json b/package.json index 9fa4d9b..4b4ddf2 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "license": "ISC", "dependencies": {}, "devDependencies": { - "@corpglory/tsdb-kit": "^1.1.1", + "@corpglory/tsdb-kit": "^2.0.1", "axios": "^1.2.1", "express": "^4.18.2", "fast-csv": "^4.3.6", diff --git a/src/services/exporter.ts b/src/services/exporter.ts index 820520f..ab0b766 100644 --- a/src/services/exporter.ts +++ b/src/services/exporter.ts @@ -4,7 +4,9 @@ import { apiKeys } from '../config'; import { promisify } from '../utils'; 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 csv from 'fast-csv'; @@ -60,7 +62,7 @@ export class Exporter { this.validateTargets(data); const targets = data.map(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'; @@ -82,7 +84,7 @@ export class Exporter { const host = new URL(target.panelUrl).origin; 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}` + `-${target.panelTitle.replace(' ', '-')}-${datasourceMetrics.columns[1]}`; diff --git a/yarn.lock b/yarn.lock index b8a5f34..138d2f9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,10 +2,10 @@ # yarn lockfile v1 -"@corpglory/tsdb-kit@^1.1.1": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@corpglory/tsdb-kit/-/tsdb-kit-1.1.1.tgz#ad2c85a4c05748db56c2a65138f2f0d8fd48cdd8" - integrity sha512-OmJdgeFavbbKpXsQ8Aq1Sb8NvaMgPhdXXPArBjnzciizi5WwLs/O91S2TOztZWljnTi+mH+TpWKy9ryH3AuGaw== +"@corpglory/tsdb-kit@^2.0.1": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@corpglory/tsdb-kit/-/tsdb-kit-2.0.1.tgz#13435a69b2bb8c9890b838a06038daf76e96ec39" + integrity sha512-qIoCy0DXjPFkAE/G9URNVJ56vfU9SPyPoNR2wJSRut6vA6eLP8kljFf4GQE/7/yFpvulHI9+RT9UrlhImWbEZA== dependencies: axios "^0.18.0" moment "^2.22.2"