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. 7
      src/target.ts

2
package.json

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

7
src/target.ts

@ -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';
@ -29,7 +30,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();
let data = { let data = {
@ -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'));

Loading…
Cancel
Save