Browse Source

Tsdb kit dep (#26)

pull/1/head
Coin de Gamma 4 years ago committed by GitHub
parent
commit
e7e004096e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      package.json
  2. 9
      src/target.ts

2
package.json

@ -11,12 +11,12 @@
"license": "ISC",
"dependencies": {},
"devDependencies": {
"@corpglory/tsdb-kit": "^1.1.1",
"@types/express": "^4.11.1",
"@types/lodash": "^4.14.116",
"axios": "^0.18.0",
"express": "^4.16.3",
"fast-csv": "^2.4.1",
"grafana-datasource-kit": "0.1.17",
"moment": "^2.22.1",
"nodemon": "^1.17.3",
"ts-loader": "^3.5.0",

9
src/target.ts

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

Loading…
Cancel
Save