|
|
@ -1,6 +1,7 @@ |
|
|
|
import { queryByMetric, Datasource, Metric } from 'grafana-datasource-kit'; |
|
|
|
|
|
|
|
import { apiKeys } from './config'; |
|
|
|
import { apiKeys } from './config'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { queryByMetric, Datasource, Metric } from '@corpglory/tsdb-kit'; |
|
|
|
|
|
|
|
|
|
|
|
import * as csv from 'fast-csv'; |
|
|
|
import * as csv from 'fast-csv'; |
|
|
|
import * as path from 'path'; |
|
|
|
import * as path from 'path'; |
|
|
|
import * as fs from 'fs'; |
|
|
|
import * as fs from 'fs'; |
|
|
@ -15,7 +16,7 @@ export class Target { |
|
|
|
private day: number; |
|
|
|
private day: number; |
|
|
|
private csvStream: any; |
|
|
|
private csvStream: any; |
|
|
|
private metric: Metric; |
|
|
|
private metric: Metric; |
|
|
|
private createdTimestamp: number;
|
|
|
|
private createdTimestamp: number; |
|
|
|
|
|
|
|
|
|
|
|
constructor( |
|
|
|
constructor( |
|
|
|
private panelUrl: string, |
|
|
|
private panelUrl: string, |
|
|
@ -28,7 +29,6 @@ export class Target { |
|
|
|
) { |
|
|
|
) { |
|
|
|
this.metric = new Metric(datasource, targets); |
|
|
|
this.metric = new Metric(datasource, targets); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public updateStatus(status) { |
|
|
|
public updateStatus(status) { |
|
|
|
let time = moment().valueOf(); |
|
|
|
let time = moment().valueOf(); |
|
|
@ -87,7 +87,8 @@ export class Target { |
|
|
|
} |
|
|
|
} |
|
|
|
this.csvStream.end(); |
|
|
|
this.csvStream.end(); |
|
|
|
} |
|
|
|
} |
|
|
|
// TODO: move csv-related stuff to service
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: move csv-related stuff to a service
|
|
|
|
private initCsvStream() { |
|
|
|
private initCsvStream() { |
|
|
|
this.csvStream = csv.createWriteStream({ headers: true }); |
|
|
|
this.csvStream = csv.createWriteStream({ headers: true }); |
|
|
|
let writableStream = fs.createWriteStream(this.getFilePath('csv')); |
|
|
|
let writableStream = fs.createWriteStream(this.getFilePath('csv')); |
|
|
|