You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ak...@apache.org on 2019/03/14 23:37:47 UTC
[incubator-pinot] branch master updated: [TE] Fix alert filter and
enrich header (#3974)
This is an automated email from the ASF dual-hosted git repository.
akshayrai09 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 7b0b00c [TE] Fix alert filter and enrich header (#3974)
7b0b00c is described below
commit 7b0b00cb40ef5793167c6472eef8bcbe526a4437
Author: Akshay Rai <ak...@gmail.com>
AuthorDate: Thu Mar 14 16:37:42 2019 -0700
[TE] Fix alert filter and enrich header (#3974)
---
.../app/mirage/factories/alert.js | 2 +-
.../self-serve-alert-details/template.hbs | 4 +-
.../app/pods/manage/alerts/index/controller.js | 6 +-
.../app/pods/manage/alerts/index/route.js | 20 +++----
.../app/pods/manage/explore/route.js | 2 +-
.../app/pods/manage/yaml/route.js | 67 +++++++++++++---------
.../app/pods/manage/yaml/template.hbs | 3 +-
.../thirdeye/detection/yaml/YamlResource.java | 11 ++--
8 files changed, 65 insertions(+), 50 deletions(-)
diff --git a/thirdeye/thirdeye-frontend/app/mirage/factories/alert.js b/thirdeye/thirdeye-frontend/app/mirage/factories/alert.js
index 5cdfcc0..3cdf338 100644
--- a/thirdeye/thirdeye-frontend/app/mirage/factories/alert.js
+++ b/thirdeye/thirdeye-frontend/app/mirage/factories/alert.js
@@ -29,7 +29,7 @@ export default Factory.extend({
dimensionName2 : [ "dimensionValue3" ]
},
pipelineType : "Composite",
- isActive : true,
+ active : true,
dataset : null,
dimensionExploration : {
dimensions : [ "dimensionName" ],
diff --git a/thirdeye/thirdeye-frontend/app/pods/components/self-serve-alert-details/template.hbs b/thirdeye/thirdeye-frontend/app/pods/components/self-serve-alert-details/template.hbs
index b4548e7..ec22bdc 100644
--- a/thirdeye/thirdeye-frontend/app/pods/components/self-serve-alert-details/template.hbs
+++ b/thirdeye/thirdeye-frontend/app/pods/components/self-serve-alert-details/template.hbs
@@ -4,11 +4,11 @@
{{#if (eq displayMode "single")}}
<span title={{alertData.functionName}}>{{alertData.functionName}}</span>
{{/if}}
- <div class="te-search-results__tag {{if (eq displayMode "list") "te-search-results__tag--list"}} {{if alertData.isActive "te-search-results__tag--active"}}">
+ <div class="te-search-results__tag {{if (eq displayMode "list") "te-search-results__tag--list"}} {{if alertData.active "te-search-results__tag--active"}}">
{{#if isLoadError}}
Error
{{else}}
- {{if alertData.isActive "Active" "Inactive"}}
+ {{if alertData.active "Active" "Inactive"}}
{{/if}}
</div>
{{#if (eq displayMode "list")}}
diff --git a/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/controller.js b/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/controller.js
index 04575dc..9cec7cd 100644
--- a/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/controller.js
+++ b/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/controller.js
@@ -333,8 +333,8 @@ export default Controller.extend({
const concatStatus = filters.status.length ? filters.status.join().toLowerCase() : 'active';
const requireAll = filters.status.includes('Active') && filters.status.includes('Inactive');
const alertsByState = {
- active: filteredAlerts.filter(alert => alert.isActive),
- inactive: filteredAlerts.filter(alert => !alert.isActive)
+ active: filteredAlerts.filter(alert => alert.active),
+ inactive: filteredAlerts.filter(alert => !alert.active)
};
filteredAlerts = requireAll ? [ ...alertsByState.active, ...alertsByState.inactive ] : alertsByState[concatStatus];
}
@@ -394,7 +394,7 @@ export default Controller.extend({
Object.assign(alertFilters, { primary: 'none' });
// Set correct status on current alert
- const alertStatus = alert.isActive ? 'Active' : 'Inactive';
+ const alertStatus = alert.active ? 'Active' : 'Inactive';
newFilterBlocksLocal.find(filter => filter.name === 'status').selected = [ alertStatus ];
// Reset local (secondary) filters, and set select fields to 'disabled'
diff --git a/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/route.js b/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/route.js
index df31451..e2b67c9 100644
--- a/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/route.js
+++ b/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/route.js
@@ -23,18 +23,18 @@ export default Route.extend({
model() {
return hash({
- subscriberGroups: fetch('/thirdeye/entity/ALERT_CONFIG').then(checkStatus),
applications: fetch('/thirdeye/entity/APPLICATION').then(checkStatus),
detectionAlertConfig: fetch('/thirdeye/entity/DETECTION_ALERT_CONFIG').then(checkStatus),
- detectionYaml: fetch('/yaml/list').then(checkStatus)
+ polishedDetectionYaml: fetch('/yaml/list').then(checkStatus)
});
},
afterModel(model) {
this._super(model);
- // format Yaml configs
- const yamlAlerts = model.detectionYaml;
- for (let yamlAlert of yamlAlerts) {
+
+ // Fetch all the detection alerts
+ const alerts = model.polishedDetectionYaml;
+ for (let yamlAlert of alerts) {
let dimensions = '';
let dimensionsArray = yamlAlert.dimensionExploration ? yamlAlert.dimensionExploration.dimensions : null;
if (Array.isArray(dimensionsArray)) {
@@ -57,7 +57,7 @@ export default Route.extend({
for (let subscriptionGroup of model.detectionAlertConfig){
const detectionConfigIds = Object.keys(subscriptionGroup.vectorClocks);
for (let id of detectionConfigIds) {
- let foundAlert = yamlAlerts.find(yamlAlert => yamlAlert.id.toString() === id);
+ let foundAlert = alerts.find(yamlAlert => yamlAlert.id.toString() === id);
if (foundAlert) {
Object.assign(foundAlert, {
application: subscriptionGroup.application,
@@ -67,11 +67,9 @@ export default Route.extend({
}
}
- const alerts = yamlAlerts;
-
// Perform initial filters for our 'primary' filter types and add counts
const user = getWithDefault(get(this, 'session'), 'data.authenticated.name', null);
- const myAlertIds = user ? this._findAlertIdsByUserGroup(user, model.subscriberGroups) : [];
+ const myAlertIds = user ? this._findAlertIdsByUserGroup(user, model.detectionAlertConfig) : [];
const ownedAlerts = alerts.filter(alert => alert.createdBy === user);
const subscribedAlerts = alerts.filter(alert => myAlertIds.includes(alert.id));
const totalCounts = [subscribedAlerts.length, ownedAlerts.length, alerts.length];
@@ -217,13 +215,13 @@ export default Route.extend({
const isLookupLenient = true; // For 'alerts I subscribe to'
// Find subscription groups current user is associated with
const myGroups = subscriberGroups.filter((group) => {
- let userInRecipients = getWithDefault(group, 'receiverAddresses.to', []).includes(user);
+ let userInRecipients = getWithDefault(group, 'properties.recipients.to', []).includes(user);
let userAnywhere = userInRecipients || group.updatedBy === user || group.createdBy === user;
return isLookupLenient ? userAnywhere : userInRecipients;
});
// Extract alert ids from these groups
const myAlertIds = [ ...new Set(myGroups
- .map(group => getWithDefault(group, 'emailConfig.functionIds', []))
+ .map(group => getWithDefault(group, 'properties.detectionConfigIds', []))
.reduce((a, b) => [...a, ...b], [])
)];
return myAlertIds;
diff --git a/thirdeye/thirdeye-frontend/app/pods/manage/explore/route.js b/thirdeye/thirdeye-frontend/app/pods/manage/explore/route.js
index d219d42..af7b89e 100644
--- a/thirdeye/thirdeye-frontend/app/pods/manage/explore/route.js
+++ b/thirdeye/thirdeye-frontend/app/pods/manage/explore/route.js
@@ -39,7 +39,7 @@ export default Route.extend({
exploreDimensions: detection_json.dimensions,
filters: this._formatYamlFilter(detectionInfo.filters),
dimensionExploration: this._formatYamlFilter(detectionInfo.dimensionExploration),
- lastDetectionTime: lastDetection.toDateString() + ", " + lastDetection.toLocaleTimeString() + " (" + moment.tz.guess() + ")",
+ lastDetectionTime: lastDetection.toDateString() + ", " + lastDetection.toLocaleTimeString() + " (" + moment().tz(moment.tz.guess()).format('z') + ")",
rawYaml: detection_json.yaml
});
diff --git a/thirdeye/thirdeye-frontend/app/pods/manage/yaml/route.js b/thirdeye/thirdeye-frontend/app/pods/manage/yaml/route.js
index 336091c..d88f574 100644
--- a/thirdeye/thirdeye-frontend/app/pods/manage/yaml/route.js
+++ b/thirdeye/thirdeye-frontend/app/pods/manage/yaml/route.js
@@ -8,6 +8,7 @@ import RSVP from 'rsvp';
import { set, get } from '@ember/object';
import { inject as service } from '@ember/service';
import yamljs from 'yamljs';
+import moment from 'moment';
export default Route.extend({
notifications: service('toast'),
@@ -21,30 +22,32 @@ export default Route.extend({
const notifications = get(this, 'notifications');
//detection alert fetch
- const alertUrl = `/detection/${alertId}`;
+ const detectionUrl = `/detection/${alertId}`;
try {
- const alert_result = await fetch(alertUrl, postProps);
- const alert_status = get(alert_result, 'status');
- const alert_json = await alert_result.json();
- if (alert_status !== 200) {
+ const detection_result = await fetch(detectionUrl, postProps);
+ const detection_status = get(detection_result, 'status');
+ const detection_json = await detection_result.json();
+ if (detection_status !== 200) {
notifications.error('Retrieval of alert yaml failed.', 'Error');
} else {
- if (alert_json.yaml) {
- const yaml = yamljs.parse(alert_json.yaml);
- Object.assign(yaml, {
- application: alert_json.name,
- isActive: alert_json.active,
- createdBy: alert_json.createdBy,
- updatedBy: alert_json.updatedBy,
- functionName: yaml.detectionName,
- collection: yaml.dataset,
- type: alert_json.pipelineType,
- exploreDimensions: alert_json.dimensions,
- filters: this._formatYamlFilter(yaml.filters),
- dimensionExploration: this._formatYamlFilter(yaml.dimensionExploration),
- yaml: alert_json.yaml
+ if (detection_json.yaml) {
+ const detectionInfo = yamljs.parse(detection_json.yaml);
+ const lastDetection = new Date(detection_json.lastTimestamp);
+ Object.assign(detectionInfo, {
+ isActive: detection_json.active,
+ createdBy: detection_json.createdBy,
+ updatedBy: detection_json.updatedBy,
+ exploreDimensions: detection_json.dimensions,
+ filters: this._formatYamlFilter(detectionInfo.filters),
+ dimensionExploration: this._formatYamlFilter(detectionInfo.dimensionExploration),
+ lastDetectionTime: lastDetection.toDateString() + ", " + lastDetection.toLocaleTimeString() + " (" + moment().tz(moment.tz.guess()).format('z') + ")"
+ });
+
+ this.setProperties({
+ alertId: alertId,
+ detectionInfo,
+ rawDetectionYaml: detection_json.yaml
});
- set(this, 'detectionYaml', yaml);
}
}
} catch (error) {
@@ -66,15 +69,27 @@ export default Route.extend({
notifications.error('Retrieving subscription groups failed.', error);
}
- const subscriptionGroupYamlDisplay = typeof get(this, 'subscriptionGroups') === 'object' && get(this, 'subscriptionGroups').length > 0 ? get(this, 'subscriptionGroups')[0].yaml : get(this, 'subscriptionGroups').yaml;
- const subscriptionGroupId = typeof get(this, 'subscriptionGroups') === 'object' && get(this, 'subscriptionGroups').length > 0 ? get(this, 'subscriptionGroups')[0].id : get(this, 'subscriptionGroups').id;
+ let subscribedGroups = "";
+ if (typeof get(this, 'subscriptionGroups') === 'object' && get(this, 'subscriptionGroups').length > 0) {
+ const groups = get(this, 'subscriptionGroups');
+ for (let key in groups) {
+ if (groups.hasOwnProperty(key)) {
+ let group = groups[key];
+ if (subscribedGroups === "") {
+ subscribedGroups = group.name;
+ } else {
+ subscribedGroups = subscribedGroups + ", " + group.name;
+ }
+ }
+ }
+ }
+
return RSVP.hash({
alertId,
- subscriptionGroupId,
- alertData: get(this, 'detectionYaml'),
- detectionYaml: get (this, 'detectionYaml') ? get(this, 'detectionYaml').yaml : 'Yaml retrieval failed',
+ alertData: get(this, 'detectionInfo'),
+ detectionYaml: get (this, 'rawDetectionYaml'),
subscriptionGroups: get(this, 'subscriptionGroups'),
- subscriptionGroupYamlDisplay
+ subscribedGroups
});
},
diff --git a/thirdeye/thirdeye-frontend/app/pods/manage/yaml/template.hbs b/thirdeye/thirdeye-frontend/app/pods/manage/yaml/template.hbs
index 0a824fc..1c9d0b2 100644
--- a/thirdeye/thirdeye-frontend/app/pods/manage/yaml/template.hbs
+++ b/thirdeye/thirdeye-frontend/app/pods/manage/yaml/template.hbs
@@ -2,6 +2,7 @@
<div class="container">
{{#self-serve-alert-yaml-details
alertData=model.alertData
+ subscribedGroups=model.subscribedGroups
isLoadError=isLoadError
}}
<div class="te-search-results__cta">
@@ -24,12 +25,10 @@
{{else}}
{{yaml-editor
alertId=model.alertId
- subscriptionGroupId=model.subscriptionGroupId
isEditMode=true
showSettings=true
subscriptionGroupNames=model.subscriptionGroups
alertYaml=model.detectionYaml
- detectionSettingsYaml=model.subscriptionGroupYamlDisplay
}}
{{/if}}
</div>
diff --git a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/YamlResource.java b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/YamlResource.java
index 5a95c02..67e7327 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/YamlResource.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/YamlResource.java
@@ -588,9 +588,10 @@ public class YamlResource {
/**
- List all yaml configurations as JSON. enhanced with detection config id, isActive and createBy information.
- @param id id of a specific detection config yaml to list (optional)
- @return the yaml configuration converted in to JSON, with enhanced information from detection config DTO.
+ * List all yaml configurations as JSON enhanced with detection config id, isActive and createBy information.
+ *
+ * @param id id of a specific detection config yaml to list (optional)
+ * @return the yaml configuration converted in to JSON, with enhanced information from detection config DTO.
*/
@GET
@Path("/list")
@@ -609,8 +610,10 @@ public class YamlResource {
Map<String, Object> yamlObject = new HashMap<>();
yamlObject.putAll((Map<? extends String, ?>) this.yaml.load(detectionConfigDTO.getYaml()));
yamlObject.put("id", detectionConfigDTO.getId());
- yamlObject.put("isActive", detectionConfigDTO.isActive());
+ yamlObject.put("cron", detectionConfigDTO.getCron());
+ yamlObject.put("active", detectionConfigDTO.isActive());
yamlObject.put("createdBy", detectionConfigDTO.getCreatedBy());
+ yamlObject.put("updatedBy", detectionConfigDTO.getUpdatedBy());
yamlObjects.add(yamlObject);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org