eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h..@apache.org
Subject [1/3] incubator-eagle git commit: [EAGLE-815] Add eagle alert template, severity and category support
Date Mon, 05 Dec 2016 06:13:02 GMT
Repository: incubator-eagle
Updated Branches:
  refs/heads/master e5e215e0b -> 1c81c0865


http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1c81c086/eagle-hadoop-metric/src/test/java/org/apache/eagle/metric/SendSampleDataToKafka.java
----------------------------------------------------------------------
diff --git a/eagle-hadoop-metric/src/test/java/org/apache/eagle/metric/SendSampleDataToKafka.java
b/eagle-hadoop-metric/src/test/java/org/apache/eagle/metric/SendSampleDataToKafka.java
index 67b94f8..026f60b 100644
--- a/eagle-hadoop-metric/src/test/java/org/apache/eagle/metric/SendSampleDataToKafka.java
+++ b/eagle-hadoop-metric/src/test/java/org/apache/eagle/metric/SendSampleDataToKafka.java
@@ -16,21 +16,25 @@
  */
 package org.apache.eagle.metric;
 
-import com.google.common.base.Preconditions;
 import com.typesafe.config.ConfigFactory;
 import kafka.producer.KeyedMessage;
 import kafka.producer.ProducerConfig;
-import org.apache.commons.io.IOUtils;
 import org.apache.eagle.app.messaging.KafkaStreamProvider;
 import org.apache.eagle.app.messaging.KafkaStreamSinkConfig;
 
 import java.io.IOException;
-import java.io.InputStream;
 import java.net.URISyntaxException;
 import java.util.Properties;
 
 public class SendSampleDataToKafka {
     public static void main(String[] args) throws URISyntaxException, IOException {
+        String data = "{" +
+            "\"host\":\"localhost\", " +
+            "\"timestamp\": 1480319109000, " +
+            "\"metric\": \"hadoop.cpu.usage\", " +
+            "\"component\": \"namenode\", " +
+            "\"site\": \"test\", " +
+            "\"value\": 0.98}";
         KafkaStreamSinkConfig config = new KafkaStreamProvider().getSinkConfig("HADOOP_JMX_METRIC_STREAM",ConfigFactory.load());
         Properties properties = new Properties();
         properties.put("metadata.broker.list", config.getBrokerList());
@@ -44,10 +48,7 @@ public class SendSampleDataToKafka {
         ProducerConfig producerConfig = new ProducerConfig(properties);
         kafka.javaapi.producer.Producer producer = new kafka.javaapi.producer.Producer(producerConfig);
         try {
-            InputStream is = SendSampleDataToKafka.class.getResourceAsStream("hadoop_jmx_metric_sample.json");
-            Preconditions.checkNotNull(is, "hadoop_jmx_metric_sample.json");
-            String value = IOUtils.toString(is);
-            producer.send(new KeyedMessage(config.getTopicId(), value));
+            producer.send(new KeyedMessage(config.getTopicId(), data));
         } finally {
             producer.close();
         }

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1c81c086/eagle-hadoop-metric/src/test/resources/hadoop_jmx_metric_sample.json
----------------------------------------------------------------------
diff --git a/eagle-hadoop-metric/src/test/resources/hadoop_jmx_metric_sample.json b/eagle-hadoop-metric/src/test/resources/hadoop_jmx_metric_sample.json
index f0f62f2..68472a0 100644
--- a/eagle-hadoop-metric/src/test/resources/hadoop_jmx_metric_sample.json
+++ b/eagle-hadoop-metric/src/test/resources/hadoop_jmx_metric_sample.json
@@ -1,6 +1,6 @@
 {
   "host":"localhost",
-  "timestamp": 1480319107,
+  "timestamp": 1480319107000,
   "metric": "hadoop.cpu.usage",
   "component": "namenode",
   "site": "test",

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1c81c086/eagle-hadoop-metric/src/test/resources/integrate_test_policy.json
----------------------------------------------------------------------
diff --git a/eagle-hadoop-metric/src/test/resources/integrate_test_policy.json b/eagle-hadoop-metric/src/test/resources/integrate_test_policy.json
new file mode 100644
index 0000000..e9de11c
--- /dev/null
+++ b/eagle-hadoop-metric/src/test/resources/integrate_test_policy.json
@@ -0,0 +1,37 @@
+{
+  "name": "TEST_POLICY",
+  "description": "from HADOOP_JMX_METRIC_STREAM_SANDBOX[site==\"test\"] insert into ALERT_STREAM;",
+  "inputStreams": [
+    "HADOOP_JMX_METRIC_STREAM_SANDBOX"
+  ],
+  "outputStreams": [
+    "ALERT_STREAM"
+  ],
+  "definition": {
+    "type": "siddhi",
+    "value": "from HADOOP_JMX_METRIC_STREAM_SANDBOX[site==\"test\"] select component,value,
name insert into ALERT_STREAM;",
+    "handlerClass": null,
+    "properties": {},
+    "inputStreams": [],
+    "outputStreams": []
+  },
+  "stateDefinition": null,
+  "policyStatus": "ENABLED",
+  "alertDefinition": {
+    "templateType": "TEXT",
+    "subject": "$component Disk Usage $value",
+    "body": "#set($usage_percentage = $value * 100)\r\n\r\nDisk Usage (<strong>$metric<strong>)
reached <span style=\"color:red\">$usage_percentage %</span> (Threshold: 90%)
on <strong>$component</strong> of cluster: <strong>$site</strong>
on:\r\n<ul>\r\n    <li><strong>Hostname</strong>: $host</li>\r\n
   <li><strong>When</strong>: $ALERT_TIME</li>\r\n    <li><strong>Root
Cause</strong>: UNKNOWN</li>\r\n    <li><strong>Action Required</strong>:
N/A</li>\r\n</ul>",
+    "severity": "CRITICAL",
+    "category": "HDFS"
+  },
+  "partitionSpec": [
+    {
+      "streamId": "HADOOP_JMX_METRIC_STREAM_SANDBOX",
+      "type": "SHUFFLE",
+      "columns": [],
+      "sortSpec": null
+    }
+  ],
+  "dedicated": false,
+  "parallelismHint": 5
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1c81c086/eagle-jpm/eagle-jpm-spark-history/src/main/java/org/apache/eagle/jpm/spark/history/storm/SparkHistoryJobParseBolt.java
----------------------------------------------------------------------
diff --git a/eagle-jpm/eagle-jpm-spark-history/src/main/java/org/apache/eagle/jpm/spark/history/storm/SparkHistoryJobParseBolt.java
b/eagle-jpm/eagle-jpm-spark-history/src/main/java/org/apache/eagle/jpm/spark/history/storm/SparkHistoryJobParseBolt.java
index 16f1144..f0fb6b5 100644
--- a/eagle-jpm/eagle-jpm-spark-history/src/main/java/org/apache/eagle/jpm/spark/history/storm/SparkHistoryJobParseBolt.java
+++ b/eagle-jpm/eagle-jpm-spark-history/src/main/java/org/apache/eagle/jpm/spark/history/storm/SparkHistoryJobParseBolt.java
@@ -134,7 +134,7 @@ public class SparkHistoryJobParseBolt extends BaseRichBolt {
         List<String> attempts = new ArrayList<String>();
         SparkApplication app = null;
         /*try {
-            List apps = this.historyServerFetcher.getResource(Constants.ResourceType.SPARK_JOB_DETAIL,
appId);
+            List apps = this.historyServerFetcher.getBodyTemplate(Constants.ResourceType.SPARK_JOB_DETAIL,
appId);
             if (apps != null) {
                 app = (SparkApplication) apps.get(0);
                 attempts = app.getAttempts();

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1c81c086/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 1d38f2e..d5829c5 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
@@ -143,7 +143,6 @@
 					<p class="text-danger">{{definitionMessage}}</p>
 				</div>
 
-
 				<ul class="sm-padding">
 					<li class="text-danger" ng-if="policy.outputStreams.length === 0"><i class="fa
fa-fw fa-warning"></i> No alert stream defined</li>
 					<li ng-repeat="stream in outputStreams track by $index">
@@ -154,6 +153,30 @@
 					</li>
 				</ul>
 
+				<div class="form-group">
+					<label>Alert Definition*</label><br/>
+					<span class="text-muted">Category</span>
+					<input class="form-control" type="text" ng-model="policy.alertDefinition.category"
ng-disabled="policyLock" />
+					<span class="text-muted">Severity</span>
+					<select class="form-control" ng-model="policy.alertDefinition.severity" ng-disabled="policyLock"
>
+						<option value="WARNING" class="text-warning">WARNING</option>
+						<option value="CRITICAL" class="text-danger">CRITICAL</option>
+						<option value="FATAL" class="text-danger">FATAL</option>
+						<option value="OK" class="text-success">OK</option>
+					</select>
+					<span class="text-muted">Alert Subject</span>
+					<span class="fa fa-question-circle ng-scope"
+						  uib-tooltip="Alert subject, support template with alert stream fields and built-in
context like: STREAM_ID, ALERT_ID, CREATED_BY, POLICY_ID, CREATED_TIMESTAMP, CREATED_TIME,
ALERT_TIMESTAMP, ALERT_TIME, ALERT_SCHEMA, POLICY_DESC, POLICY_TYPE, POLICY_DEFINITION, POLICY_HANDLER">
+					</span>
+					<input type="text" class="form-control" placeholder="Please input alert subject (support
template)" ng-model="policy.alertDefinition.subject" ng-disabled="policyLock"/>
+					<span class="text-muted">Alert Body</span>
+					<span class="fa fa-question-circle ng-scope"
+						  uib-tooltip="Alert body, support template with alert stream fields and built-in 
context like: STREAM_ID, ALERT_ID, CREATED_BY, POLICY_ID, CREATED_TIMESTAMP, CREATED_TIME,
ALERT_TIMESTAMP, ALERT_TIME, ALERT_SCHEMA, POLICY_DESC, POLICY_TYPE, POLICY_DEFINITION, POLICY_HANDLER">
+					</span>
+					<!--<textarea class="form-control" rows="3" placeholder="Please input alert body
(support template)" ng-model="policy.alertDefinition.body" ng-disabled="policyLock"></textarea>-->
+					<div editor placeholder="Please input alert body (support template)" ng-model="policy.alertDefinition.body"
ng-disabled="policyLock"></div>
+				</div>
+
 				<label>
 					Publish Alerts
 				</label>

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/1c81c086/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 e202450..3bb5609 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
@@ -69,6 +69,12 @@
 				type: "siddhi",
 				value: ""
 			},
+			alertDefinition: {
+				subject: "",
+				body: "",
+				severity: "WARNING",
+				category: "DEFAULT"
+			},
 			partitionSpec: [],
 			parallelismHint: 5
 		}, $scope.policy);


Mime
View raw message