You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2020/11/30 23:40:03 UTC

[GitHub] [incubator-pinot] tejasajmera commented on a change in pull request #6290: [TE]frontend - Build the tree parser for composite anomalies

tejasajmera commented on a change in pull request #6290:
URL: https://github.com/apache/incubator-pinot/pull/6290#discussion_r532974984



##########
File path: thirdeye/thirdeye-frontend/app/utils/anomalies-tree-parser.js
##########
@@ -0,0 +1,563 @@
+import { isEmpty } from "@ember/utils";
+import { set } from "@ember/object";
+import moment from "moment";
+
+const CLASSIFICATIONS = {
+  METRICS: {
+    KEY: "metrics",

Review comment:
       Can you tell me what is the exact command for it? Is it tied to your code changes in https://github.com/apache/incubator-pinot/pull/6245? If so, I may not be able to do as your changes are not merged yet.

##########
File path: thirdeye/thirdeye-frontend/app/utils/anomalies-tree-parser.js
##########
@@ -0,0 +1,563 @@
+import { isEmpty } from "@ember/utils";
+import { set } from "@ember/object";
+import moment from "moment";
+
+const CLASSIFICATIONS = {
+  METRICS: {
+    KEY: "metrics",
+    COMPONENT_PATH: "entity-metrics",
+    DEFAULT_TITLE: "Metric Anomalies"
+  },
+  GROUPS: {
+    KEY: "groups",
+    COMPONENT_PATH: "entity-groups",
+    DEFAULT_TITLE: "ENTITY:"
+  },
+  ENTITIES: {
+    KEY: "entities",
+    COMPONENT_PATH: "parent-anomalies",
+    DEFAULT_TITLE: "Entity"
+  }
+};
+const BREADCRUMB_TIME_DISPLAY_FORMAT = "MMM D HH:mm";

Review comment:
       Sure.

##########
File path: thirdeye/thirdeye-frontend/app/utils/anomalies-tree-parser.js
##########
@@ -0,0 +1,563 @@
+import { isEmpty } from "@ember/utils";
+import { set } from "@ember/object";
+import moment from "moment";
+
+const CLASSIFICATIONS = {
+  METRICS: {
+    KEY: "metrics",
+    COMPONENT_PATH: "entity-metrics",
+    DEFAULT_TITLE: "Metric Anomalies"
+  },
+  GROUPS: {
+    KEY: "groups",
+    COMPONENT_PATH: "entity-groups",
+    DEFAULT_TITLE: "ENTITY:"
+  },
+  ENTITIES: {
+    KEY: "entities",
+    COMPONENT_PATH: "parent-anomalies",
+    DEFAULT_TITLE: "Entity"
+  }
+};
+const BREADCRUMB_TIME_DISPLAY_FORMAT = "MMM D HH:mm";
+
+/**
+ * Format the timestamp into the form to be shown in the breadcrumb
+ *
+ * @param {Number} timestamp
+ *   The timestamp of anomaly creation time in milliseconds
+ *
+ * @returns {String}
+ *   Formatted timestamp. Example of the required format - "Sep 15 16:49 EST"
+ */
+const getFormattedBreadcrumbTime = timestamp => {
+  const zoneName = moment.tz.guess();
+  const timeZoneAbbreviation = moment.tz(zoneName).zoneAbbr();
+
+  return `${moment(timestamp).format(
+    BREADCRUMB_TIME_DISPLAY_FORMAT
+  )} ${timeZoneAbbreviation}`;
+};
+
+/**
+ * Parse the anomalies generated by the composite alert to populate parent-anomalies table with relevent details about
+ * children for each anomaly.
+ *
+ * @param {Array<Object>} input
+ *   The anomalies for composite alert.
+ *
+ * @returns {Array<Object>}
+ *   Parsed out contents to populate parent-anomalies table
+ */
+const populateParentAnomaliesTable = input => {

Review comment:
       Sure.

##########
File path: thirdeye/thirdeye-frontend/app/utils/anomalies-tree-parser.js
##########
@@ -0,0 +1,563 @@
+import { isEmpty } from "@ember/utils";
+import { set } from "@ember/object";
+import moment from "moment";
+
+const CLASSIFICATIONS = {
+  METRICS: {
+    KEY: "metrics",
+    COMPONENT_PATH: "entity-metrics",
+    DEFAULT_TITLE: "Metric Anomalies"
+  },
+  GROUPS: {
+    KEY: "groups",
+    COMPONENT_PATH: "entity-groups",
+    DEFAULT_TITLE: "ENTITY:"
+  },
+  ENTITIES: {
+    KEY: "entities",
+    COMPONENT_PATH: "parent-anomalies",
+    DEFAULT_TITLE: "Entity"
+  }
+};
+const BREADCRUMB_TIME_DISPLAY_FORMAT = "MMM D HH:mm";
+
+/**
+ * Format the timestamp into the form to be shown in the breadcrumb
+ *
+ * @param {Number} timestamp
+ *   The timestamp of anomaly creation time in milliseconds
+ *
+ * @returns {String}
+ *   Formatted timestamp. Example of the required format - "Sep 15 16:49 EST"
+ */
+const getFormattedBreadcrumbTime = timestamp => {
+  const zoneName = moment.tz.guess();
+  const timeZoneAbbreviation = moment.tz(zoneName).zoneAbbr();
+
+  return `${moment(timestamp).format(
+    BREADCRUMB_TIME_DISPLAY_FORMAT
+  )} ${timeZoneAbbreviation}`;
+};
+
+/**
+ * Parse the anomalies generated by the composite alert to populate parent-anomalies table with relevent details about
+ * children for each anomaly.
+ *
+ * @param {Array<Object>} input
+ *   The anomalies for composite alert.
+ *
+ * @returns {Array<Object>}
+ *   Parsed out contents to populate parent-anomalies table
+ */
+const populateParentAnomaliesTable = input => {
+  const output = [];
+
+  for (const entry of input) {
+    const { id, startTime, endTime, feedback, children } = entry;
+    const entryOutput = {
+      id,
+      startTime,
+      endTime,
+      feedback
+    };
+
+    const details = {};
+    let item;
+    if (children.length > 0) {
+      for (const child of children) {
+        const { metric, properties: { subEntityName } = {} } = child;
+
+        if (!isEmpty(metric)) {
+          item = metric;
+        } else {
+          item = subEntityName;
+        }
+
+        if (item in details) {
+          details[item]++;
+        } else {
+          details[item] = 1;
+        }
+      }
+      entryOutput.details = details;
+      output.push(entryOutput);
+    }
+  }
+
+  return output;
+};
+
+/**
+ * Parse the generated bucket for metric anomalies into the schema for the entity-metrics component
+ *
+ * @param {Object} input
+ *   The metric anomalies bucket constituents
+ *
+ * @returns {Array<Object>}
+ *   The content to be passed into the the leaf level entity-metrics component. Each item in the array represents
+ *   contents for the row in the table.
+ */
+const parseMetricsBucket = input => {

Review comment:
       Sure.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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