|
|
@ -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]}`; |
|
|
|