Browse Source

Fix POST /anomalies to receive datasource

pull/1/head
rozetko 7 years ago
parent
commit
b9917d34f9
  1. 2
      server/src/routes/anomalies.ts
  2. 9
      server/src/services/anomalyType.ts

2
server/src/routes/anomalies.ts

@ -1,6 +1,7 @@
import * as express from 'express'; import * as express from 'express';
import { import {
Datasource,
Metric, Metric,
Anomaly, Anomaly,
saveAnomaly, saveAnomaly,
@ -81,6 +82,7 @@ async function createAnomaly(req, res) {
name: req.body.name, name: req.body.name,
panelUrl: req.body.panelUrl, panelUrl: req.body.panelUrl,
metric: metric, metric: metric,
datasource: req.body.datasource,
status: 'learning', status: 'learning',
last_prediction_time: 0, last_prediction_time: 0,
next_id: 0 next_id: 0

9
server/src/services/anomalyType.ts

@ -4,6 +4,14 @@ import { ANOMALIES_PATH } from '../config'
import * as fs from 'fs' import * as fs from 'fs'
import * as crypto from 'crypto'; import * as crypto from 'crypto';
export type Datasource = {
method: string,
data: Object,
params: Object,
type: string,
url: string
}
export type Metric = { export type Metric = {
datasource: string, datasource: string,
targets: string[] targets: string[]
@ -15,6 +23,7 @@ export type Anomaly = {
panelUrl: string, panelUrl: string,
metric: Metric, metric: Metric,
datasource: Datasource
status: string, status: string,
last_prediction_time: number, last_prediction_time: number,

Loading…
Cancel
Save