eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h..@apache.org
Subject incubator-eagle git commit: [MINOR] Refactor alert list and detail pages
Date Wed, 07 Dec 2016 15:29:07 GMT
Repository: incubator-eagle
Updated Branches:
  refs/heads/master 3914e39dd -> 269ff147f


[MINOR] Refactor alert list and detail pages

# Changes

* Refactor alert list and detail pages
* Add "storage.hbase.autoCreateTable" (boolean) config to improve server startup speed with
hbase

Author: Hao Chen <hao@apache.org>

Closes #721 from haoch/RefactorAlertPage.


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

Branch: refs/heads/master
Commit: 269ff147f29cde959af50b1b9a4e528112ec4799
Parents: 3914e39
Author: Hao Chen <hao@apache.org>
Authored: Wed Dec 7 23:28:45 2016 +0800
Committer: Hao Chen <hao@apache.org>
Committed: Wed Dec 7 23:28:45 2016 +0800

----------------------------------------------------------------------
 .../apache/eagle/common/config/EagleConfig.java |  2 +
 .../common/config/EagleConfigConstants.java     |  1 +
 .../eagle/common/config/EagleConfigFactory.java | 11 +++++
 .../storage/hbase/HBaseEntitySchemaManager.java |  6 ++-
 .../src/main/resources/application.conf         |  2 +
 .../webapp/app/dev/partials/alert/detail.html   | 46 ++++++++------------
 .../webapp/app/dev/partials/alert/list.html     | 35 +++++++--------
 7 files changed, 57 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/269ff147/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfig.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfig.java
b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfig.java
index f85d161..14e2451 100755
--- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfig.java
+++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfig.java
@@ -57,4 +57,6 @@ public interface EagleConfig {
      * @return root config.
      */
     Config getConfig();
+
+    boolean isAutoCreateTable();
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/269ff147/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigConstants.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigConstants.java
b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigConstants.java
index c700c61..504174c 100644
--- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigConstants.java
+++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigConstants.java
@@ -32,6 +32,7 @@ public final class EagleConfigConstants {
     public static final String SERVICE_THREADPOOL_MAX_SIZE = "storage.hbase.threadpoolMaxSize";
     public static final String SERVICE_THREADPOOL_SHRINK_SIZE = "storage.hbase.threadpoolShrinkSize";
     public static final String SERVICE_AUDITING_ENABLED = "storage.hbase.auditEnabled";
+    public static final String AUTO_CREATE_TABLE = "storage.hbase.autoCreateTable";
 
     public static final String EAGLE_TIME_ZONE = "service.timezone";
     public static final String DEFAULT_EAGLE_TIME_ZONE = "UTC";

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/269ff147/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigFactory.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigFactory.java
b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigFactory.java
index 65d93e9..e95e65c 100755
--- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigFactory.java
+++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/config/EagleConfigFactory.java
@@ -43,6 +43,7 @@ public class EagleConfigFactory implements EagleConfig {
     private String storageType;
     private Config config;
     private TimeZone timeZone;
+    private boolean autoCreateTable = true;
 
     public boolean isCoprocessorEnabled() {
         return isCoprocessorEnabled;
@@ -102,6 +103,7 @@ public class EagleConfigFactory implements EagleConfig {
         final String zkZnodeParent = config.hasPath(EagleConfigConstants.SERVICE_ZOOKEEPER_ZNODE_PARENT)
             ? config.getString(EagleConfigConstants.SERVICE_ZOOKEEPER_ZNODE_PARENT) : EagleConfigConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT;
         String clientIPCPoolSize = getString(config, EagleConfigConstants.SERVICE_HBASE_CLIENT_IPC_POOL_SIZE,
"10");
+        this.autoCreateTable = !config.hasPath(EagleConfigConstants.AUTO_CREATE_TABLE) ||
config.getBoolean(EagleConfigConstants.AUTO_CREATE_TABLE);
         this.hbaseConf = HBaseConfiguration.create();
         this.hbaseConf.set("hbase.client.ipc.pool.size", clientIPCPoolSize);
 
@@ -207,4 +209,13 @@ public class EagleConfigFactory implements EagleConfig {
     public boolean isServiceAuditingEnabled() {
         return isServiceAuditingEnabled;
     }
+
+    @Override
+    public boolean isAutoCreateTable() {
+        return autoCreateTable;
+    }
+
+    public void setAutoCreateTable(boolean autoCreateTable) {
+        this.autoCreateTable = autoCreateTable;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/269ff147/eagle-core/eagle-query/eagle-storage-hbase/src/main/java/org/apache/eagle/storage/hbase/HBaseEntitySchemaManager.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-storage-hbase/src/main/java/org/apache/eagle/storage/hbase/HBaseEntitySchemaManager.java
b/eagle-core/eagle-query/eagle-storage-hbase/src/main/java/org/apache/eagle/storage/hbase/HBaseEntitySchemaManager.java
index d7483f5..354d641 100644
--- a/eagle-core/eagle-query/eagle-storage-hbase/src/main/java/org/apache/eagle/storage/hbase/HBaseEntitySchemaManager.java
+++ b/eagle-core/eagle-query/eagle-storage-hbase/src/main/java/org/apache/eagle/storage/hbase/HBaseEntitySchemaManager.java
@@ -26,7 +26,6 @@ import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
-import org.apache.hadoop.hbase.io.compress.Compression;
 import org.apache.hadoop.hbase.regionserver.BloomType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -57,7 +56,12 @@ public class HBaseEntitySchemaManager {
     }
 
     public void init() {
+        if (!EagleConfigFactory.load().isAutoCreateTable()) {
+            LOG.debug("Auto create table disabled, skip creating table");
+            return;
+        }
         Configuration conf = EagleConfigFactory.load().getHbaseConf();
+
         try {
             admin = new HBaseAdmin(conf);
             Map<String, EntityDefinition> entityServiceMap = EntityDefinitionManager.entities();

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/269ff147/eagle-server/src/main/resources/application.conf
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/resources/application.conf b/eagle-server/src/main/resources/application.conf
index b9f4ac0..84b467c 100644
--- a/eagle-server/src/main/resources/application.conf
+++ b/eagle-server/src/main/resources/application.conf
@@ -44,6 +44,8 @@ storage {
   type = "hbase"
 
   hbase {
+    autoCreateTable = true
+    
     # hbase configuration: hbase.zookeeper.quorum
     # default is "localhost"
     zookeeperQuorum = "localhost"

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/269ff147/eagle-server/src/main/webapp/app/dev/partials/alert/detail.html
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/partials/alert/detail.html b/eagle-server/src/main/webapp/app/dev/partials/alert/detail.html
index 96f7bd5..5f63ccf 100644
--- a/eagle-server/src/main/webapp/app/dev/partials/alert/detail.html
+++ b/eagle-server/src/main/webapp/app/dev/partials/alert/detail.html
@@ -20,7 +20,7 @@
 	<div class="box-header with-border">
 		<span class="fa fa-bell"></span>
 		<h3 class="box-title">
-			ID: {{alert.tags.alertId}}
+			<strong>[{{alert.tags.category}}]</strong> {{alert.alertSubject}}
 			<span class="fa fa-refresh fa-spin no-animate" ng-show="!alertList._done"></span>
 		</h3>
 	</div>
@@ -28,53 +28,43 @@
 		<table class="table">
 			<tbody>
 				<tr>
-					<th width="15%">severity</th>
-					<td width="35%">
-						<span class="label label-{{Policy.getSeverityClass(alert.tags.severity)}}">
-							{{alert.tags.severity}}
-						</span>
-					</td>
+					<th>Severity</th>
+					<td><span class="label label-{{Policy.getSeverityClass(alert.tags.severity)}}">{{alert.tags.severity}}</span></td>
 					<th width="15%">Time</th>
 					<td width="35%">{{Time.format(alert.timestamp)}}</td>
 				</tr>
 				<tr>
-					<th>Policy</th>
-					<td><a ui-sref="policyDetail({name: item.policyId})">{{alert.tags.policyId}}</a></td>
 					<th>Category</th>
 					<td>{{alert.tags.category}}</td>
-				</tr>
-				<tr>
 					<th>Site</th>
 					<td>{{alert.tags.siteId}}</td>
-					<th>Applications</th>
-					<td>
-						<ul class="list-unstyled">
-							<li ng-repeat="app in alert.appIds track by $index" class="label label-sm label-primary">
-								{{Application.findProvider(app).type || app}}
-							</li>
-						</ul>
-					</td>
 				</tr>
 				<tr>
-					<th>Policy</th>
+					<th>Message</th>
 					<td colspan="3">
-						<pre class="inline">{{alert.policyValue}}</pre>
+						<div ng-bind-html="alertBody"></div>
 					</td>
 				</tr>
 				<tr>
-					<th>Alert Data</th>
+					<th>Alert Policy</th>
+					<td colspan="3"><a ui-sref="policyDetail({name: item.policyId})">{{alert.tags.policyId}}</a></td>
+				</tr>
+				<tr>
+					<th>Alert Event</th>
 					<td colspan="3">
 						<pre>{{alert.alertData | json}}</pre>
 					</td>
 				</tr>
 				<tr>
-					<th>Alert Subject</th>
-					<td colspan="3">{{alert.alertSubject}}</td>
-				</tr>
-				<tr>
-					<th>Alert Body</th>
+					<th>Related Apps</th>
 					<td colspan="3">
-						<div ng-bind-html="alertBody"></div>
+						<ul>
+							<ul class="list-unstyled">
+								<li ng-repeat="app in alert.appIds track by $index" class="label label-sm label-default">
+									{{Application.findProvider(app).type || app}}
+								</li>
+							</ul>
+						</ul>
 					</td>
 				</tr>
 			</tbody>

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/269ff147/eagle-server/src/main/webapp/app/dev/partials/alert/list.html
----------------------------------------------------------------------
diff --git a/eagle-server/src/main/webapp/app/dev/partials/alert/list.html b/eagle-server/src/main/webapp/app/dev/partials/alert/list.html
index e326e47..806234d 100644
--- a/eagle-server/src/main/webapp/app/dev/partials/alert/list.html
+++ b/eagle-server/src/main/webapp/app/dev/partials/alert/list.html
@@ -44,35 +44,34 @@
 							Time
 							<span class="fa fa-refresh fa-spin no-animate" ng-show="!alertList._done || isSorting"></span>
 						</th>
-						<th sortpath="tags.siteId" width="75">Site</th>
-						<th sortpath="tags.policyId" width="75">Policy</th>
 						<th sortpath="tags.severity" width="85">Severity</th>
+						<th sortpath="tags.siteId" width="75">Site</th>
 						<!--th sortpath="streamId" width="75">Stream</th-->
-						<th width="100">Application</th>
-						<th>Alert Subject</th>
+						<th width="100" sortpath="tags.category" >Category</th>
+						<th>Subject</th>
+						<th sortpath="tags.policyId" width="75">Policy</th>
 						<th width="10"></th>
 					</tr>
 				</thead>
 				<tbody>
 					<tr>
 						<td>{{Time.format(item.timestamp)}}</td>
-						<td>{{item.tags.siteId}}</td>
-						<td>
-							<a ui-sref="policyDetail({name: item.tags.policyId})">{{item.tags.policyId}}</a>
-						</td>
 						<td>
 							<span class="label label-{{Policy.getSeverityClass(item.tags.severity)}}">
 								{{item.tags.severity}}
 							</span>
 						</td>
+						<td>{{item.tags.siteId}}</td>
+						<!--<td>-->
+							<!--<ul class="list-unstyled">-->
+								<!--<li ng-repeat="app in item.appIds track by $index" class="label label-sm
label-primary">-->
+									<!--{{Application.findProvider(app).type || app}}-->
+								<!--</li>-->
+							<!--</ul>-->
+						<!--</td>-->
+						<td>{{item.tags.category || "N/A"}}</td>
+						<td><a ui-sref="alertDetail({alertId: item.tags.alertId})" title="{{item.alertBody}}">{{item.alertSubject}}</a></td>
 						<!--td>{{item.streamId}}</td-->
-						<td>
-							<ul class="list-unstyled">
-								<li ng-repeat="app in item.appIds track by $index" class="label label-sm label-primary">
-									{{Application.findProvider(app).type || app}}
-								</li>
-							</ul>
-						</td>
 						<!--td class="text-break">
 							<span ng-if="displayType === 'raw'" na-block="item.alertData"></span>
 							<div ng-if="displayType === 'format'" na-block="!!item.alertData">
@@ -84,9 +83,11 @@
 								</ul>
 							</div>
 						</td-->
-						<td>{{item.alertSubject}}</td>
 						<td>
-							<a ui-sref="alertDetail({alertId: item.tags.alertId})">Detail</a>
+							<a ui-sref="policyDetail({name: item.tags.policyId})">{{item.tags.policyId}}</a>
+						</td>
+						<td>
+							<a ui-sref="alertDetail({alertId: item.tags.alertId})">detail</a>
 						</td>
 					</tr>
 				</tbody>


Mime
View raw message