Browse Source

HSR for anomaly analytic unit #653 (#654)

pull/1/head
rozetko 6 years ago committed by GitHub
parent
commit
3955aff329
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      server/src/controllers/analytics_controller.ts

4
server/src/controllers/analytics_controller.ts

@ -591,7 +591,7 @@ export async function getHSR(analyticUnit: AnalyticUnit.AnalyticUnit, from: numb
const data = await queryByMetric(analyticUnit.metric, grafanaUrl, from, to, HASTIC_API_KEY);
if(analyticUnit.detectorType !== AnalyticUnit.DetectorType.ANOMALY) {
return data;
return { hsr: data };
}
let cache = await AnalyticUnitCache.findById(analyticUnit.id);
if(
@ -619,7 +619,7 @@ export async function getHSR(analyticUnit: AnalyticUnit.AnalyticUnit, from: numb
if(result.status !== AnalyticUnit.AnalyticUnitStatus.SUCCESS) {
throw new Error(`Data processing error: ${result.error}`);
}
return { values: result.payload.data, columns: data.columns };
return { hsr: data, smoothed: { values: result.payload.data, columns: data.columns } };
} catch (err) {
const message = err.message || JSON.stringify(err);
await AnalyticUnit.setStatus(analyticUnit.id, AnalyticUnit.AnalyticUnitStatus.FAILED, message);

Loading…
Cancel
Save