You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eagle.apache.org by mw...@apache.org on 2016/07/25 09:37:14 UTC

[37/47] incubator-eagle git commit: EAGLE-303. Split event fields into table in email for clearly reading. prettify alert email

EAGLE-303. Split event fields into table in email for clearly reading.
prettify alert email

Author: @Huizhi <hn...@ebay.com>
Reviewer: @yonzhang <yo...@gmail.com>

Closes: #242


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

Branch: refs/heads/master
Commit: 2eb5d5387bb253d28259cdb714d4c68ad6f88269
Parents: b49bda1
Author: yonzhang <yo...@gmail.com>
Authored: Fri Jun 17 10:54:03 2016 -0700
Committer: yonzhang <yo...@gmail.com>
Committed: Fri Jun 17 10:54:03 2016 -0700

----------------------------------------------------------------------
 .../notification/email/AlertEmailGenerator.java |  31 +-
 .../notification/email/AlertEmailSender.java    |  16 +-
 .../src/main/resources/ALERT_DEFAULT.vm         | 488 ++++++++++---------
 .../siddhi/SiddhiAlertAPIEntityRender.java      |  18 +-
 .../src/main/resources/application.conf         |  13 +-
 .../apache/eagle/policy/common/Constants.java   |   1 +
 6 files changed, 311 insertions(+), 256 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/2eb5d538/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/email/AlertEmailGenerator.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/email/AlertEmailGenerator.java b/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/email/AlertEmailGenerator.java
index fd6b794..db24390 100644
--- a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/email/AlertEmailGenerator.java
+++ b/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/email/AlertEmailGenerator.java
@@ -41,7 +41,9 @@ public class AlertEmailGenerator{
 
     private final static Logger LOG = LoggerFactory.getLogger(AlertEmailGenerator.class);
 
-    private final static long MAX_TIMEOUT_MS =60000;
+    private final static long MAX_TIMEOUT_MS = 60000;
+
+    private final static String EVENT_FIELDS_SPLITTER = ",";
 
     public boolean sendAlertEmail(AlertAPIEntity entity) {
         return sendAlertEmail(entity, recipients, null);
@@ -56,15 +58,21 @@ public class AlertEmailGenerator{
         AlertEmailContext email = new AlertEmailContext();
 
         AlertEmailComponent component = new AlertEmailComponent();
-        AlertContext  context = AlertContext.fromJsonString(entity.getAlertContext());
+        AlertContext context = AlertContext.fromJsonString(entity.getAlertContext());
         component.setAlertContext(context);
+        AlertEmailComponent eventComponent = getEventComponent(context);
         List<AlertEmailComponent> components = new ArrayList<AlertEmailComponent>();
         components.add(component);
+        components.add(eventComponent);
         email.setComponents(components);
+
         if (context.getProperty(Constants.SUBJECT) != null) {
             email.setSubject(context.getProperty(Constants.SUBJECT));
         }
-        else email.setSubject(subject);
+        else {
+            email.setSubject(subject);
+        }
+
         email.setVelocityTplFile(tplFile);
         email.setRecipients(recipients);
         email.setCc(cc);
@@ -76,7 +84,7 @@ public class AlertEmailGenerator{
 
         if(this.executorPool == null) throw new IllegalStateException("Invoking thread executor pool but it's is not set yet");
 
-        LOG.info("Sending email  in asynchronous to: "+recipients+", cc: "+cc);
+        LOG.info("Sending email in asynchronous to: "+ recipients +", cc: " + cc);
         Future future = this.executorPool.submit(thread);
         try {
             future.get(MAX_TIMEOUT_MS, TimeUnit.MILLISECONDS);
@@ -135,4 +143,19 @@ public class AlertEmailGenerator{
     public void setExecutorPool(ThreadPoolExecutor executorPool) {
         this.executorPool = executorPool;
     }
+
+    private AlertEmailComponent getEventComponent(AlertContext context) {
+        AlertContext eventFieldsContext = new AlertContext();
+        String eventFields = context.getProperty(Constants.ALERT_EVENT_FIELDS);
+        String[] fields = eventFields.split(EVENT_FIELDS_SPLITTER);
+
+        for (String key : fields) {
+            eventFieldsContext.addProperty(key, context.getProperty(key));
+        }
+
+        AlertEmailComponent component = new AlertEmailComponent();
+        component.setAlertContext(eventFieldsContext);
+
+        return component;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/2eb5d538/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/email/AlertEmailSender.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/email/AlertEmailSender.java b/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/email/AlertEmailSender.java
index c2c4949..ef98f22 100644
--- a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/email/AlertEmailSender.java
+++ b/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/java/org/apache/eagle/notification/email/AlertEmailSender.java
@@ -88,7 +88,8 @@ public class AlertEmailSender implements Runnable {
         String tmp = ManagementFactory.getRuntimeMXBean().getName();
         this.origin = tmp.split("@")[1] + "(pid:" + tmp.split("@")[0] + ")";
         threadName = Thread.currentThread().getName();
-        LOG.info("Initialized "+threadName+": origin is : " + this.origin+", recipient of the email: " + this.recipents+", velocity TPL file: " + this.configFileName);
+        LOG.info("Initialized "+threadName+": origin is : " + this.origin+", recipient of the email: "
+                + this.recipents+", velocity TPL file: " + this.configFileName);
     }
 
     public AlertEmailSender(AlertEmailContext alertEmail, ConfigObject eagleProps){
@@ -100,8 +101,8 @@ public class AlertEmailSender implements Runnable {
     public void run() {
         int count = 0;
         boolean success = false;
-        while(count++ < MAX_RETRY_COUNT && !success){
-            LOG.info("Sending email, tried: " + count+", max: "+ MAX_RETRY_COUNT);
+        while(count++ < MAX_RETRY_COUNT && !success) {
+            LOG.info("Sending email, tried: " + count + ", max: " + MAX_RETRY_COUNT);
             try {
                 final EagleMailClient client;
                 if (eagleProps != null) {
@@ -172,20 +173,21 @@ public class AlertEmailSender implements Runnable {
 
         if(success){
             sentSuccessfully = true;
-            LOG.info(String.format("Successfully send email, thread: %s",threadName));
+            LOG.info(String.format("Successfully send email, thread: %s", threadName));
         }else{
-            LOG.warn(String.format("Fail sending email after tries %s times, thread: %s",MAX_RETRY_COUNT,threadName));
+            LOG.warn(String.format("Fail sending email after tries %s times, thread: %s", MAX_RETRY_COUNT, threadName));
         }
     }
 
     private void generateCommonContext(VelocityContext context) {
-        context.put(Constants.ALERT_EMAIL_TIME_PROPERTY, DateTimeUtil.millisecondsToHumanDateWithSeconds( System.currentTimeMillis() ));
+        context.put(Constants.ALERT_EMAIL_TIME_PROPERTY,
+                DateTimeUtil.millisecondsToHumanDateWithSeconds(System.currentTimeMillis()));
         context.put(Constants.ALERT_EMAIL_COUNT_PROPERTY, alertContexts.size());
         context.put(Constants.ALERT_EMAIL_ALERTLIST_PROPERTY, alertContexts);
         context.put(Constants.ALERT_EMAIL_ORIGIN_PROPERTY, origin);
     }
 
-    public boolean sentSuccessfully(){
+    public boolean sentSuccessfully() {
         return this.sentSuccessfully;
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/2eb5d538/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/resources/ALERT_DEFAULT.vm
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/resources/ALERT_DEFAULT.vm b/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/resources/ALERT_DEFAULT.vm
index 3e29439..7135569 100644
--- a/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/resources/ALERT_DEFAULT.vm
+++ b/eagle-core/eagle-alert/eagle-alert-notification-plugin/src/main/resources/ALERT_DEFAULT.vm
@@ -16,251 +16,263 @@
   -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
-	<head>
-		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-		<meta name="viewport" content="width=device-width"/>
-		<style>
-			body {
-				width:100% !important;
-				min-width: 100%;
-				-webkit-text-size-adjust:100%;
-				-ms-text-size-adjust:100%;
-				margin:0;
-				padding:0;
-			}
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+        <meta name="viewport" content="width=device-width"/>
+        <style>
+            body {
+                width:100% !important;
+                min-width: 100%;
+                -webkit-text-size-adjust:100%;
+                -ms-text-size-adjust:100%;
+                margin:0;
+                padding:0;
+            }
 
-			table {
-				border-spacing: 0;
-				border-collapse: collapse;
-			}
+            table {
+                border-spacing: 0;
+                border-collapse: collapse;
+            }
 
-			table th,
-			table td {
-				padding: 3px 0 3px 0;
-			}
+            table th,
+            table td {
+                padding: 3px 0 3px 0;
+            }
 
-			.body {
-				width: 100%;
-			}
+            .body {
+                width: 100%;
+            }
 
-			p,a,h1,h2,h3,ul,ol,li {
-				font-family: Helvetica, Arial, sans-serif;
-				font-weight: normal;
-				margin: 0;
-				padding: 0;
-			}
-			p {
-				font-size: 14px;
-				line-height: 19px;
-			}
-			a {
-				color: #3294b1;
-			}
-			h1 {
-				font-size: 36px;
-				margin: 15px 0 5px 0;
-			}
-			h2 {
-				font-size: 32px;
-			}
-			h3 {
-				font-size: 28px;
-			}
+            p,a,h1,h2,h3,ul,ol,li {
+                font-family: Helvetica, Arial, sans-serif;
+                font-weight: normal;
+                margin: 0;
+                padding: 0;
+            }
+            p {
+                font-size: 14px;
+                line-height: 19px;
+            }
+            a {
+                color: #3294b1;
+            }
+            h1 {
+                font-size: 36px;
+                margin: 15px 0 5px 0;
+            }
+            h2 {
+                font-size: 32px;
+            }
+            h3 {
+                font-size: 28px;
+            }
 
-			ul,ol {
-				margin: 0 0 0 25px;
-				padding: 0;
-			}
+            ul,ol {
+                margin: 0 0 0 25px;
+                padding: 0;
+            }
 
-			.btn {
-				background: #2ba6cb !important;
-				border: 1px solid #2284a1;
-				padding: 10px 20px 10px 20px;
-				text-align: center;
-			}
-			.btn:hover {
-				background: #2795b6 !important;
-			}
-			.btn a {
-				color: #FFFFFF;
-				text-decoration: none;
-				font-weight: bold;
-				padding: 10px 20px 10px 20px;
-			}
+            .btn {
+                background: #2ba6cb !important;
+                border: 1px solid #2284a1;
+                padding: 10px 20px 10px 20px;
+                text-align: center;
+            }
+            .btn:hover {
+                background: #2795b6 !important;
+            }
+            .btn a {
+                color: #FFFFFF;
+                text-decoration: none;
+                font-weight: bold;
+                padding: 10px 20px 10px 20px;
+            }
 
-			.tableBordered {
-				border-top: 1px solid #b9e5ff;
-			}
-			.tableBordered th {
-				background: #ECF8FF;
-			}
-			.tableBordered th p {
-				font-weight: bold;
-				color: #3294b1;
-			}
-			.tableBordered th,
-			.tableBordered td {
-				color: #333333;
-				border-bottom: 1px solid #b9e5ff;
-				text-align: center;
-				padding-bottom: 5px;
-			}
+            .tableBordered {
+                border-top: 1px solid #b9e5ff;
+            }
+            .tableBordered th {
+                background: #ECF8FF;
+            }
+            .tableBordered th p {
+                font-weight: bold;
+                color: #3294b1;
+            }
+            .tableBordered th,
+            .tableBordered td {
+                color: #333333;
+                border-bottom: 1px solid #b9e5ff;
+                text-align: center;
+                padding-bottom: 5px;
+            }
 
-			.panel {
-				height: 100px;
-			}
-		</style>
-	</head>
-	<body>
-		#set ( $elem = $alertList[0] )
-		#set ( $alertUrl = $elem["alertDetailUrl"] )
-		#set ( $policyUrl = $elem["policyDetailUrl"] )
-		<table class="body">
-			<tr>
-				<td align="center" valign="top" style="background: #999999; padding: 0 0 0 0;">
-					<!-- Eagle Header -->
-					<table width="580">
-						<tr>
-							<td style="padding: 0 0 0 0;" align="left" >
-								<p style="color:#FFFFFF;font-weight: bold; font-size: 24px">Eagle</p>
-							</td>
-						</tr>
-					</table>
-				</td>
-			</tr>
+            .panel {
+                height: 100px;
+            }
+        </style>
+    </head>
+    <body>
+        #set ( $elem = $alertList[0] )
+        #set ( $eventFields = $alertList[1] )
+        #set ( $alertUrl = $elem["alertDetailUrl"] )
+        #set ( $policyUrl = $elem["policyDetailUrl"] )
+        <table class="body">
+            <tr>
+                <td align="center" valign="top" style="background: #999999; padding: 0 0 0 0;">
+                    <!-- Eagle Header -->
+                    <table width="90%">
+                        <tr>
+                            <td style="padding: 0 0 0 0;" align="left" >
+                                <p style="color:#FFFFFF;font-weight: bold; font-size: 24px">Eagle</p>
+                            </td>
+                        </tr>
+                    </table>
+                </td>
+            </tr>
 
-			<tr>
-				<td align="center" valign="top">
-					<!-- Eagle Body -->
-					<table width="580">
-						<tr>
-							<!-- Title -->
-							<td align="center">
-								<h1>$elem["application"] Alert Detected</h1>
-							</td>
-						</tr>
-						<tr>
-							<!-- Time -->
-							<td>
-								<table width="580">
-									<tr>
-										<td>
-											<p><b>Detected Time: $elem["alertTimestamp"]</b></p>
-										</td>
-										#set ( $severity = $elem["severity"] )
-										#if (!$severity || ("$severity" == ""))
-											#set ( $elem["severity"] = "WARNING")
-										#end
-										<td align="right">
-											<p><b>
-												Severity:
-									            #if ($elem["severity"] == "WARNING")
-													<span>$elem["severity"]</span>												
-    											#else
-													<span style="color: #FF0000;">$elem["severity"]</span>
-    											#end
-											</b></p>
-										</td>
-									</tr>
-								</table>
-							</td>
-						</tr>
-						<tr>
-							<!-- Description -->
-							<td valign="top" style="background: #ECF8FF; border: 1px solid #b9e5ff; padding: 10px 10px 12px 10px;">
-								<p>$elem["alertMessage"]</p>
-							</td>
-						</tr>
-						<tr>
-							<!-- View Detail -->
-							<td align="center" style="padding: 10px 0 0 0;">
-								<table width="580">
-									<tr>
-										<td class="btn">
-											<a href="$alertUrl">View Alert Details on Eagle Web</a>
-										</td>
-									</tr>
-								</table>
-							</td>
-						</tr>
-						<tr>
-							<!-- Basic Information -->
-							<td style="padding: 20px 0 0 0;">
-								<p><b>Basic Information:</b></p>
-							</td>
-						</tr>
-						<tr>
-							<!-- Basic Information Content -->
-							<td>
-								<table class="tableBordered" width="580">
-									<tr>
-										<th>
-											<p>Site</p>
-										</th>
-										<th>
-											<p>Data Source</p>
-										</th>
-									</tr>
-									<tr>
-										<td>
-											<p>$elem["site"]</p>
-										</td>
-										<td>
-											<p>$elem["application"]</p>
-										</td>
-									</tr>
-									<tr>
-										<th>
-											<p>Policy Name</p>
-										</th>
-										<th>
-											<p>Severity</p>
-										</th>
-									</tr>
-									<tr>
-										<td>
-											<p>$elem["policyId"]</p>
-										</td>
-										<td>
-											<p>$elem["severity"]</p>
-										</td>
-									</tr>
-								</table>
-							</td>
-						</tr>
-						<tr>
-							<!-- View Detail -->
-							<td align="center" style="padding: 10px 0 0 0;">
-								<table width="580">
-									<tr>
-										<td class="btn">
-											<a href="$policyUrl">View Policy Details on Eagle Web</a>
-										</td>
-									</tr>
-								</table>
-							</td>
-						</tr>						
-						<tr>
-							<!-- Actions Required -->
-							<td style="padding: 20px 0 0 0;">
-								<p><b>Actions Required:</b></p>
-							</td>
-						</tr>
-						<tr>
-							<!-- Possible Root Causes Content -->
-							<td class="panel" valign="top" style="background: #F4F4F4; border: 1px solid #AAAAAA; padding: 10px 10px 12px 10px;">
-								<p> $elem["application"] alert found, please check.</p>
-							</td>
-						</tr>
-						<tr>
-							<!-- Copyright -->
-							<td align="center">
-								<p><a href="<Eagle-Host>/alerts/alertlist.html">Apache Eagle</a></p>
-							</td>
-						</tr>
-					</table>
-				</td>
-			</tr>
-		</table>
-	</body>
+            <tr>
+                <td align="center" valign="top">
+                    <!-- Eagle Body -->
+                    <table width="90%">
+                        <tr>
+                            <!-- Title -->
+                            <td align="center">
+                                <h1>$elem["application"] Alert Detected</h1>
+                            </td>
+                        </tr>
+                        <tr>
+                            <!-- Time -->
+                            <td>
+                                <table width="100%">
+                                    <tr>
+                                        <td>
+                                            <p><b>Detected Time: $elem["alertTimestamp"]</b></p>
+                                        </td>
+                                        #set ( $severity = $elem["severity"] )
+                                        #if (!$severity || ("$severity" == ""))
+                                            #set ( $elem["severity"] = "WARNING")
+                                        #end
+                                        <td align="right">
+                                            <p><b>
+                                                Severity:
+                                                #if ($elem["severity"] == "WARNING")
+                                                    <span>$elem["severity"]</span>
+                                                #else
+                                                    <span style="color: #FF0000;">$elem["severity"]</span>
+                                                #end
+                                            </b></p>
+                                        </td>
+                                    </tr>
+                                </table>
+                            </td>
+                        </tr>
+                        <!-- Description -->
+                        <tr>
+                            <td>
+                                <table class="tableBordered" width="100%">
+                                    #foreach ($key in $eventFields.keySet())
+                                        <tr>
+                                            <th>
+                                                <p>$key</p>
+                                            </th>
+                                            <td>
+                                                $eventFields.get($key)
+                                            </td>
+                                        </tr>
+                                    #end
+                                </table>
+                            </td>
+                        </tr>
+                        <tr>
+                            <!-- View Detail -->
+                            <td align="center" style="padding: 10px 0 0 0;">
+                                <table width="100%">
+                                    <tr>
+                                        <td class="btn">
+                                            <a href="$alertUrl">View Alert Details on Eagle Web</a>
+                                        </td>
+                                    </tr>
+                                </table>
+                            </td>
+                        </tr>
+                        <tr>
+                            <!-- Basic Information -->
+                            <td style="padding: 20px 0 0 0;">
+                                <p><b>Basic Information:</b></p>
+                            </td>
+                        </tr>
+                        <tr>
+                            <!-- Basic Information Content -->
+                            <td>
+                                <table class="tableBordered" width="100%">
+                                    <tr>
+                                        <th>
+                                            <p>Site</p>
+                                        </th>
+                                        <th>
+                                            <p>Data Source</p>
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <td>
+                                            <p>$elem["site"]</p>
+                                        </td>
+                                        <td>
+                                            <p>$elem["application"]</p>
+                                        </td>
+                                    </tr>
+                                    <tr>
+                                        <th>
+                                            <p>Policy Name</p>
+                                        </th>
+                                        <th>
+                                            <p>Severity</p>
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <td>
+                                            <p>$elem["policyId"]</p>
+                                        </td>
+                                        <td>
+                                            <p>$elem["severity"]</p>
+                                        </td>
+                                    </tr>
+                                </table>
+                            </td>
+                        </tr>
+                        <tr>
+                            <!-- View Detail -->
+                            <td align="center" style="padding: 10px 0 0 0;">
+                                <table width="100%">
+                                    <tr>
+                                        <td class="btn">
+                                            <a href="$policyUrl">View Policy Details on Eagle Web</a>
+                                        </td>
+                                    </tr>
+                                </table>
+                            </td>
+                        </tr>
+                        <tr>
+                            <!-- Actions Required -->
+                            <td style="padding: 20px 0 0 0;">
+                                <p><b>Actions Required:</b></p>
+                            </td>
+                        </tr>
+                        <tr>
+                            <!-- Possible Root Causes Content -->
+                            <td class="panel" valign="top" style="background: #F4F4F4; border: 1px solid #AAAAAA; padding: 10px 10px 12px 10px;">
+                                <p> $elem["application"] alert found, please check.</p>
+                            </td>
+                        </tr>
+                        <tr>
+                            <!-- Copyright -->
+                            <td align="center">
+                                <p><a href="https://eagle.incubator.apache.org">Apache Eagle</a></p>
+                            </td>
+                        </tr>
+                    </table>
+                </td>
+            </tr>
+        </table>
+    </body>
 </html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/2eb5d538/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/siddhi/SiddhiAlertAPIEntityRender.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/siddhi/SiddhiAlertAPIEntityRender.java b/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/siddhi/SiddhiAlertAPIEntityRender.java
index c7ff74c..cef2a28 100644
--- a/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/siddhi/SiddhiAlertAPIEntityRender.java
+++ b/eagle-core/eagle-alert/eagle-alert-process/src/main/java/org/apache/eagle/alert/siddhi/SiddhiAlertAPIEntityRender.java
@@ -73,20 +73,31 @@ public class SiddhiAlertAPIEntityRender implements ResultRender<AlertDefinitionA
 		}
 
 		StringBuilder sb = new StringBuilder();
+		StringBuilder keysSb = new StringBuilder();
+		String prefix = "";
+
 		for (Entry<String, String> entry : context.getProperties().entrySet()) {
 			String key = entry.getKey();
 			String value = entry.getValue();
-			sb.append(key + "=\"" + value + "\" ");			
+			sb.append(key).append("=\"").append(value).append("\" ");
+
+			keysSb.append(prefix).append(key);
+			prefix = ",";
 		}
+
+		String alertEventFields = keysSb.toString();
+		String alertEvent = sb.toString();
+
 		context.addAll(evaluator.getAdditionalContext());
 		String policyId = context.getProperty(Constants.POLICY_ID);
-		String alertMessage = "The Policy \"" + policyId + "\" has been detected with the below information: " + sb.toString() ;
+		String alertMessage = "The Policy \"" + policyId + "\" has been detected with the below information: " + alertEvent;
 		String site = config.getString(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.SITE);
 		String application = config.getString(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.APPLICATION);
 		String host = config.getString(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.HOST);
 		Integer port = config.getInt(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.EAGLE_SERVICE + "." + EagleConfigConstants.PORT);
 
-		context.addProperty(Constants.ALERT_EVENT, sb.toString());
+		context.addProperty(Constants.ALERT_EVENT, alertEvent);
+		context.addProperty(Constants.ALERT_EVENT_FIELDS, alertEventFields);
 		context.addProperty(Constants.ALERT_MESSAGE, alertMessage);
 		context.addProperty(Constants.ALERT_TIMESTAMP_PROPERTY, DateTimeUtil.millisecondsToHumanDateWithSeconds(System.currentTimeMillis()));
 		context.addProperty(EagleConfigConstants.APPLICATION, application);
@@ -104,6 +115,7 @@ public class SiddhiAlertAPIEntityRender implements ResultRender<AlertDefinitionA
 		context.addProperty(Constants.POLICY_DETAIL_URL, UrlBuilder.buiildPolicyDetailUrl(host, port, tags));
 		context.addProperty(Constants.ALERT_DETAIL_URL, UrlBuilder.buildAlertDetailUrl(host, port, entity));
 		entity.setAlertContext(context.toJsonString());
+
 		return entity;
 	}	
 }

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/2eb5d538/eagle-core/eagle-data-process/eagle-stream-process-api/src/main/resources/application.conf
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-data-process/eagle-stream-process-api/src/main/resources/application.conf b/eagle-core/eagle-data-process/eagle-stream-process-api/src/main/resources/application.conf
index 72c2ae5..526e47f 100644
--- a/eagle-core/eagle-data-process/eagle-stream-process-api/src/main/resources/application.conf
+++ b/eagle-core/eagle-data-process/eagle-stream-process-api/src/main/resources/application.conf
@@ -47,9 +47,14 @@
     "site" : "sandbox",
     "application": "SpadesMonitor",
     "dataJoinPollIntervalSec" : 30,
-    "mailHost" : "mailHost.com",
-    "mailSmtpPort":"25",
-    "mailDebug" : "true",
+    "mailHost" : "smtp.office365.com",
+    "mailSmtpPort":"587",
+    "mailSmtpAuth" : "true",
+    "mailSmtpUser" : "username",
+    "mailSmtpPassword" : "password",
+    #"mailSmtpSslEnable" : "true",
+    "mailSmtpTlsEnable" : "true",
+    "mailDebug" : "false",
     "balancePartitionEnabled" : true,
     #"partitionRefreshIntervalInMin" : 60,
     #"kafkaStatisticRangeInMin" : 60,
@@ -70,4 +75,4 @@
     "eagleStoreEnabled": true,
     "kafka_broker":"127.0.0.1:6667"
   }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/2eb5d538/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/common/Constants.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/common/Constants.java b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/common/Constants.java
index 2a33460..1b65685 100644
--- a/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/common/Constants.java
+++ b/eagle-core/eagle-policy/eagle-policy-base/src/main/java/org/apache/eagle/policy/common/Constants.java
@@ -53,6 +53,7 @@ public class Constants {
 	public static final String POLICY_ID = "policyId";
     public static final String SOURCE_STREAMS = "sourceStreams";
     public static final String ALERT_EVENT = "alertEvent";
+	public static final String ALERT_EVENT_FIELDS = "alertEventFields";
 	public static final String POLICY_DETAIL_URL = "policyDetailUrl";
 	public static final String ALERT_DETAIL_URL = "alertDetailUrl";