Repository: eagle
Updated Branches:
  refs/heads/master a37d2e1bc -> 1db33df5a


[EAGLE-1037] Add alertDeduplication configurations on Eagle UI

https://issues.apache.org/jira/browse/EAGLE-1037

Add alertDeduplication configurations on Eagle UI.

Here is the sample policy
```json
{
    "name": "capacityUsage",
    "description": "Policy for 
HADOOP_JMX_METRIC_STREAM_SANDBOX_CAPACITY_USAGE_OUT",
    "inputStreams": [
      "HADOOP_JMX_METRIC_STREAM_SANDBOX"
    ],
    "outputStreams": [
      "HADOOP_JMX_METRIC_STREAM_SANDBOX_CAPACITY_USAGE_OUT"
    ],
    "siteId": "sandbox",
    "definition": {
      "type": "siddhi",
      "value": "from HADOOP_JMX_METRIC_STREAM_SANDBOX[metric == 
\"hadoop.namenode.fsnamesystemstate.capacityusage\" and convert(value, 
\"long\") > 90]select site, host, component, metric, convert(value, \"long\") 
as value, timestamp insert into 
HADOOP_JMX_METRIC_STREAM_SANDBOX_CAPACITY_USAGE_OUT;",
      "handlerClass": null,
      "properties": {},
      "inputStreams": [],
      "outputStreams": []
    },
    "stateDefinition": null,
    "policyStatus": "ENABLED",
    "alertDefinition": {
      "templateType": "TEXT",
      "subject": "$site capacity exceeds 90%",
      "body": "$site capacity exceeds 90%",
      "severity": "WARNING",
      "category": "HDFS"
    },
    "alertDeduplications": [
      {
        "outputStreamId": "HADOOP_JMX_METRIC_STREAM_SANDBOX_CAPACITY_USAGE_OUT",
        "dedupIntervalMin": "1",
        "dedupFields": [
          "site",
          "component",
          "host",
          "metric"
        ]
      }
    ],
    "partitionSpec": [
      {
        "streamId": "HADOOP_JMX_METRIC_STREAM_SANDBOX",
        "type": "SHUFFLE",
        "columns": [],
        "sortSpec": null
      }
    ],
    "dedicated": false,
    "parallelismHint": 5,
    "alertSeverity": "WARNING",
    "alertCategory": "HDFS"
  }
```

Author: zombieJ <[email protected]>

Closes #945 from zombieJ/EAGLE-1037.


Project: http://git-wip-us.apache.org/repos/asf/eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/eagle/commit/1db33df5
Tree: http://git-wip-us.apache.org/repos/asf/eagle/tree/1db33df5
Diff: http://git-wip-us.apache.org/repos/asf/eagle/diff/1db33df5

Branch: refs/heads/master
Commit: 1db33df5ab97e91e60711b512f5177142123a1b2
Parents: a37d2e1
Author: zombieJ <[email protected]>
Authored: Thu Jun 8 10:18:59 2017 +0800
Committer: Zhao, Qingwen <[email protected]>
Committed: Thu Jun 8 10:18:59 2017 +0800

----------------------------------------------------------------------
 .../partials/alert/policyEdit/advancedMode.html | 30 +++++++------
 .../app/dev/public/js/ctrls/alertEditCtrl.js    | 45 +++++++++++---------
 2 files changed, 44 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/eagle/blob/1db33df5/eagle-server/src/main/webapp/app/dev/partials/alert/policyEdit/advancedMode.html
----------------------------------------------------------------------
diff --git 
a/eagle-server/src/main/webapp/app/dev/partials/alert/policyEdit/advancedMode.html
 
b/eagle-server/src/main/webapp/app/dev/partials/alert/policyEdit/advancedMode.html
index db5d359..1da0d3d 100644
--- 
a/eagle-server/src/main/webapp/app/dev/partials/alert/policyEdit/advancedMode.html
+++ 
b/eagle-server/src/main/webapp/app/dev/partials/alert/policyEdit/advancedMode.html
@@ -196,19 +196,25 @@
                                        <div editor placeholder="Please input 
alert body (support template)" ng-model="policy.alertDefinition.body" 
ng-disabled="policyLock"></div>
                                </div>
 
-                               <div class="form-group">
-                                       <label>Alert De-duplication 
Interval(min)</label><br/>
-                                       <input class="form-control" type="text" 
ng-model="policy.deduplication.dedupIntervalMin" ng-disabled="policyLock" />
-                               </div>
+                               <!-- Alert dedup region -->
+                               <div>
+                                       <label>Alert De-duplication</label>
+                                       <ul>
+                                               <li 
ng-repeat="outputStreamDedup in policy.alertDeduplications track by $index">
+                                                       
<span>{{outputStreamDedup.outputStreamId}}</span><br />
+                                                       <div 
class="input-group">
+                                                               <span 
class="bg-gray disabled input-group-addon">Alert De-duplication 
Interval(min)</span>
+                                                               <input 
class="form-control" type="text" ng-model="outputStreamDedup.dedupIntervalMin" 
ng-disabled="policyLock" />
+                                                       </div>
 
-                               <div class="form-group" 
ng-if="getOutputFields().length">
-                                       <label>Alert De-duplication 
Fields</label><br/>
-                                       <ul class="sm-padding">
-                                               <li ng-repeat="field in 
getOutputFields() track by $index">
-                                               <label>
-                                                       <input type="checkbox" 
ng-checked="isDedupFieldSelected(field)" ng-click="checkDedupField(field)" 
ng-disabled="policyLock" />
-                                                       {{field}}
-                                               </label>
+                                                       <ul class="sm-padding">
+                                                               <li 
ng-repeat="field in getOutputStreamFields(outputStreamDedup.outputStreamId) 
track by $index">
+                                                                       <input 
type="checkbox" ng-disabled="policyLock"
+                                                                               
        ng-checked="isDedupFieldSelected(outputStreamDedup, field)"
+                                                                               
        ng-click="checkDedupField(outputStreamDedup, field)" />
+                                                                       
{{field}}
+                                                               </li>
+                                                       </ul>
                                                </li>
                                        </ul>
                                </div>

http://git-wip-us.apache.org/repos/asf/eagle/blob/1db33df5/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertEditCtrl.js
----------------------------------------------------------------------
diff --git 
a/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertEditCtrl.js 
b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertEditCtrl.js
index 404c563..ae8cf7e 100644
--- a/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertEditCtrl.js
+++ b/eagle-server/src/main/webapp/app/dev/public/js/ctrls/alertEditCtrl.js
@@ -73,10 +73,7 @@
                                severity: "WARNING",
                                category: "DEFAULT"
                        },
-                       deduplication: {
-                               dedupIntervalMin: '30',
-                               dedupFields: [],
-                       },
+                       alertDeduplications: [],
                        partitionSpec: [],
                        parallelismHint: 5
                }, $scope.policy);
@@ -207,7 +204,7 @@
                                                        autoDescription();
 
                                                        // Dedup fields
-                                                       
$scope.policy.deduplication.dedupFields = [];
+                                                       
$scope.refreshOutputSteamFields();
 
                                                        // Partition
                                                        
$scope.policy.partitionSpec = data.policyExecutionPlan.streamPartitions;
@@ -225,6 +222,7 @@
                // 
==============================================================
                $scope.outputStreams = ($scope.policy.outputStreams || 
[]).concat();
 
+               // Select output stream
                $scope.isOutputStreamSelected = function (streamId) {
                        return $.inArray(streamId, $scope.policy.outputStreams) 
>= 0;
                };
@@ -236,36 +234,45 @@
                                $scope.policy.outputStreams.push(streamId);
                        }
                        autoDescription();
+
+                       $scope.refreshOutputSteamFields();
                };
 
-               $scope.getOutputFields = function () {
+               // Select output steam field
+               $scope.refreshOutputSteamFields = function () {
                        var defOutputStreams = 
common.getValueByPath($scope.definition || {}, 
'policyExecutionPlan.outputStreams');
                        if (!defOutputStreams) return [];
 
-                       var fields = $.map($scope.policy.outputStreams, 
function (outputStream) {
-                               var fields = defOutputStreams[outputStream];
-                               return $.map(fields, function (field) {
-                                       return field.name;
-                               });
+                       $scope.policy.alertDeduplications = 
$.map($scope.policy.outputStreams, function (outputStream) {
+                               return {
+                                       outputStreamId: outputStream,
+                                       dedupIntervalMin: '30',
+                                       dedupFields: [],
+                               };
                        });
+               };
+               $scope.getOutputStreamFields = function (outputStream) {
+                       var defOutputStreams = 
common.getValueByPath($scope.definition || {}, 
'policyExecutionPlan.outputStreams');
+                       if (!defOutputStreams) return [];
 
-                       return fields;
+                       var fields = defOutputStreams[outputStream];
+                       return $.map(fields, function (field) {
+                               return field.name;
+                       });
                };
 
-               $scope.isDedupFieldSelected = function (field) {
-                       return $.inArray(field, 
$scope.policy.deduplication.dedupFields) >= 0;
+               $scope.isDedupFieldSelected = function (outputStreamDedup, 
field) {
+                       return $.inArray(field, outputStreamDedup.dedupFields) 
>= 0;
                };
 
-               $scope.checkDedupField = function (field) {
+               $scope.checkDedupField = function (outputStreamDedup, field) {
                        if($scope.isDedupFieldSelected(field)) {
-                               $scope.policy.deduplication.dedupFields = 
common.array.remove(field, $scope.policy.deduplication.dedupFields);
+                               outputStreamDedup.dedupFields = 
common.array.remove(field, outputStreamDedup.dedupFields);
                        } else {
-                               
$scope.policy.deduplication.dedupFields.push(field);
+                               outputStreamDedup.dedupFields.push(field);
                        }
                };
 
-               //$scope.policy.deduplication.dedupFields
-
                // 
==============================================================
                // =                         Partition                          
=
                // 
==============================================================

Reply via email to