You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ji...@apache.org on 2019/03/13 22:13:35 UTC

[incubator-pinot] branch master updated: [TE] frontend - harleyjj/rca - update predicted baseline endpoint and response handling (#3959)

This is an automated email from the ASF dual-hosted git repository.

jihao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 92a5b40  [TE] frontend - harleyjj/rca - update predicted baseline endpoint and response handling (#3959)
92a5b40 is described below

commit 92a5b4097588ffb46ea28d263eba96c3c0725650
Author: Harley Jackson <ha...@gmail.com>
AuthorDate: Wed Mar 13 15:13:26 2019 -0700

    [TE] frontend - harleyjj/rca - update predicted baseline endpoint and response handling (#3959)
    
    Handles new predicted baseline endpoint path and response formats
    Updates RCA utils to deal with thirdeye:event:anomaly
    Cleans some eslint warnings
---
 .../app/pods/rootcause/controller.js               |  6 ++----
 .../thirdeye-frontend/app/pods/rootcause/route.js  |  6 ++----
 .../rootcause-anomalyfunction-cache/service.js     | 22 +++++++++-------------
 thirdeye/thirdeye-frontend/app/utils/rca-utils.js  | 13 ++++++++++++-
 thirdeye/thirdeye-frontend/app/utils/utils.js      | 10 +++++-----
 5 files changed, 30 insertions(+), 27 deletions(-)

diff --git a/thirdeye/thirdeye-frontend/app/pods/rootcause/controller.js b/thirdeye/thirdeye-frontend/app/pods/rootcause/controller.js
index 531a3af..10759e4 100644
--- a/thirdeye/thirdeye-frontend/app/pods/rootcause/controller.js
+++ b/thirdeye/thirdeye-frontend/app/pods/rootcause/controller.js
@@ -23,9 +23,7 @@ import _ from 'lodash';
 
 const ROOTCAUSE_TAB_DIMENSIONS = 'dimensions';
 const ROOTCAUSE_TAB_METRICS = 'metrics';
-const ROOTCAUSE_TAB_EVENTS = 'events';
 const ROOTCAUSE_TAB_TREND = 'trend';
-const ROOTCAUSE_TAB_CALLGRAPH = 'callgraph';
 
 const ROOTCAUSE_SETUP_MODE_CONTEXT = "context";
 const ROOTCAUSE_SETUP_MODE_SELECTED = "selected";
@@ -361,7 +359,7 @@ export default Controller.extend({
       //
       // anomaly function baselines
       //
-      const anomalyFunctionUrns = filterPrefix(context.anomalyUrns, 'frontend:anomalyfunction:');
+      const anomalyFunctionUrns = filterPrefix(context.anomalyUrns, 'thirdeye:event:anomaly');
       anomalyFunctionService.request(context, new Set(anomalyFunctionUrns));
 
       //
@@ -469,7 +467,7 @@ export default Controller.extend({
       }
 
       // NOTE: only supports a single anomaly function baseline
-      const anomalyFunctionUrns = filterPrefix(context.anomalyUrns, 'frontend:anomalyfunction:');
+      const anomalyFunctionUrns = filterPrefix(context.anomalyUrns, 'thirdeye:event:anomaly:');
       const anomalyFunctionUrn = anomalyFunctionUrns[0];
 
       filterPrefix(context.anomalyUrns, 'thirdeye:metric:').forEach(urn => {
diff --git a/thirdeye/thirdeye-frontend/app/pods/rootcause/route.js b/thirdeye/thirdeye-frontend/app/pods/rootcause/route.js
index 1cd28ed..ce08201 100644
--- a/thirdeye/thirdeye-frontend/app/pods/rootcause/route.js
+++ b/thirdeye/thirdeye-frontend/app/pods/rootcause/route.js
@@ -373,10 +373,8 @@ export default Route.extend(AuthenticatedRouteMixin, {
         const anomalyMetricUrn = appendFilters(anomalyMetricUrnRaw, anomalyFilters);
 
         const anomalyFunctionUrns = [];
-        if (!_.isEmpty(anomalyEntity.attributes['functionId'])) {
-          const anomalyFunctionUrnRaw = `frontend:anomalyfunction:${anomalyEntity.attributes['functionId'][0]}`;
-          anomalyFunctionUrns.pushObject(appendFilters(anomalyFunctionUrnRaw, anomalyFilters));
-        }
+        const anomalyFunctionUrnRaw = `thirdeye:event:anomaly:${anomalyId}`;
+        anomalyFunctionUrns.pushObject(appendFilters(anomalyFunctionUrnRaw, anomalyFilters));
 
         context = {
           urns: new Set([anomalyMetricUrn]),
diff --git a/thirdeye/thirdeye-frontend/app/pods/services/rootcause-anomalyfunction-cache/service.js b/thirdeye/thirdeye-frontend/app/pods/services/rootcause-anomalyfunction-cache/service.js
index c48b8d4..adc70d5 100644
--- a/thirdeye/thirdeye-frontend/app/pods/services/rootcause-anomalyfunction-cache/service.js
+++ b/thirdeye/thirdeye-frontend/app/pods/services/rootcause-anomalyfunction-cache/service.js
@@ -1,8 +1,4 @@
 import Service from '@ember/service';
-import {
-  toFilters,
-  makeTime
-} from 'thirdeye-frontend/utils/rca-utils';
 import { checkStatus } from 'thirdeye-frontend/utils/utils';
 import fetch from 'fetch';
 import _ from 'lodash';
@@ -28,7 +24,7 @@ export default Service.extend({
   request(requestContext, urns) {
     const { context, timeseries, pending } = this.getProperties('context', 'timeseries', 'pending');
 
-    const metrics = [...urns].filter(urn => urn.startsWith('frontend:anomalyfunction:'));
+    const metrics = [...urns].filter(urn => urn.startsWith('thirdeye:event:anomaly'));
 
     // TODO eviction on cache size limit
 
@@ -77,8 +73,8 @@ export default Service.extend({
   },
 
   _extractTimeseries(json, urn) {
-    const timestamp = json['timeBuckets'].map(bucket => parseInt(bucket['baselineStart'], 10));
-    const value = json['baselineValues'].map(parseFloat);
+    const timestamp = json['timestamp'].map(bucket => parseInt(bucket, 10));
+    const value = json['value'].map(parseFloat);
 
     const timeseries = {};
     timeseries[urn] = {
@@ -90,12 +86,12 @@ export default Service.extend({
   },
 
   _fetchSlice(urn, context) {
-    const functionId = urn.split(':')[2];
-    const startDateTime = makeTime(context.analysisRange[0]).utc().format();
-    const endDateTime = makeTime(context.analysisRange[1]).utc().format();
-    const dimensionJsonString = encodeURIComponent(JSON.stringify(this._toFilterMapCustom(toFilters(urn))));
+    const functionId = urn.split(':')[3];
+    const startDateTime = context.analysisRange[0];
+    const endDateTime = context.analysisRange[1];
+
+    const url = `/detection/predicted-baseline/${functionId}?start=${startDateTime}&end=${endDateTime}`;
 
-    const url = `/dashboard/anomaly-function/${functionId}/baseline?start=${startDateTime}&end=${endDateTime}&dimension=${dimensionJsonString}&mode=offline`;
     return fetch(url)
       .then(checkStatus)
       .then(res => this._extractTimeseries(res, urn))
@@ -103,7 +99,7 @@ export default Service.extend({
       .catch(error => this._handleError(urn, error));
   },
 
-  _handleError(urn, error) {
+  _handleError(urn) {
     const { errors, pending } = this.getProperties('errors', 'pending');
 
     const newError = urn;
diff --git a/thirdeye/thirdeye-frontend/app/utils/rca-utils.js b/thirdeye/thirdeye-frontend/app/utils/rca-utils.js
index e96493b..eff8834 100644
--- a/thirdeye/thirdeye-frontend/app/utils/rca-utils.js
+++ b/thirdeye/thirdeye-frontend/app/utils/rca-utils.js
@@ -111,6 +111,9 @@ export function stripTail(urn) {
   if (urn.startsWith('frontend:anomalyfunction:')) {
     return _.slice(parts, 0, 3).join(':');
   }
+  if (urn.startsWith('thirdeye:event:anomaly:')) {
+    return _.slice(parts, 0, 4).join(':');
+  }
   if (urn.startsWith('thirdeye:dimensions:')) {
     return _.slice(parts, 0, 2).join(':');
   }
@@ -138,6 +141,9 @@ export function extractTail(urn) {
   if (urn.startsWith('frontend:anomalyfunction:')) {
     return _.slice(parts, 3).filter(p => !_.isEmpty(p));
   }
+  if (urn.startsWith('thirdeye:event:anomaly:')) {
+    return _.slice(parts, 4).filter(p => !_.isEmpty(p));
+  }
   if (urn.startsWith('thirdeye:dimensions:')) {
     return _.slice(parts, 2).filter(p => !_.isEmpty(p));
   }
@@ -359,6 +365,10 @@ function metricUrnHelper(prefix, urn) {
     const tail = makeUrnTail(parts, 3);
     return `${prefix}${parts[2]}${tail}`;
   }
+  if (hasPrefix(urn, 'thirdeye:event:anomaly:')) {
+    const tail = makeUrnTail(parts, 4);
+    return `${prefix}${parts[2]}${tail}`;
+  }
   throw new Error(`Requires supported urn, but found ${urn}`);
 }
 
@@ -494,9 +504,10 @@ export function toFilters(urns) {
   const metricFilters = filterPrefix(urns, 'thirdeye:metric:').map(extractTail).map(enc => enc.map(tup => splitFilterFragment(decodeURIComponent(tup)))).reduce(flatten, []);
   const frontendMetricFilters = filterPrefix(urns, 'frontend:metric:').map(extractTail).map(enc => enc.map(tup => splitFilterFragment(decodeURIComponent(tup)))).reduce(flatten, []);
   const anomalyFunctionFilters = filterPrefix(urns, 'frontend:anomalyfunction:').map(extractTail).map(enc => enc.map(tup => splitFilterFragment(decodeURIComponent(tup)))).reduce(flatten, []);
+  const anomalyFilters = filterPrefix(urns, 'thirdeye:event:anomaly:').map(extractTail).map(enc => enc.map(tup => splitFilterFragment(decodeURIComponent(tup)))).reduce(flatten, []);
   const callgraphFilters = filterPrefix(urns, 'thirdeye:callgraph:').map(extractTail).map(enc => enc.map(tup => splitFilterFragment(decodeURIComponent(tup)))).reduce(flatten, []);
 
-  return [...new Set([...dimensionFilters, ...dimensionsFilters, ...metricFilters, ...frontendMetricFilters, ...anomalyFunctionFilters, ...callgraphFilters])].sort();
+  return [...new Set([...dimensionFilters, ...dimensionsFilters, ...metricFilters, ...frontendMetricFilters, ...anomalyFunctionFilters, ...anomalyFilters, ...callgraphFilters])].sort();
 }
 
 /**
diff --git a/thirdeye/thirdeye-frontend/app/utils/utils.js b/thirdeye/thirdeye-frontend/app/utils/utils.js
index 40846be9..d655d98 100644
--- a/thirdeye/thirdeye-frontend/app/utils/utils.js
+++ b/thirdeye/thirdeye-frontend/app/utils/utils.js
@@ -26,11 +26,11 @@ export function checkStatus(response, mode = 'get', recoverBlank = false, isYaml
   } else {
     if (isYamlPreview) {
       return response.json()
-              .then(data => {
-                const error = new Error(data);
-                error.body= data;
-                throw error;
-              })
+        .then(data => {
+          const error = new Error(data);
+          error.body= data;
+          throw error;
+        });
     }
     const error = new Error(response.statusText);
     error.response = response;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org