You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ch...@apache.org on 2016/01/30 19:48:41 UTC

[3/4] stratos git commit: Adding oracle db support for metering and monitoring dashboard

Adding oracle db support for metering and monitoring dashboard


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/18c09319
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/18c09319
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/18c09319

Branch: refs/heads/master
Commit: 18c0931950b24159c3ca845e7f0dcfee4de6deb3
Parents: 25083bf
Author: Thanuja <th...@wso2.com>
Authored: Thu Jan 28 09:02:03 2016 +0530
Committer: Chamila de Alwis <cs...@chamiladealwis.com>
Committed: Sat Jan 30 23:58:25 2016 +0530

----------------------------------------------------------------------
 .../artifacts/metering-dashboard/README.md      |  17 +--
 .../database-scripts/mysql/metering-script.sql  |  28 +++++
 .../database-scripts/oracle/metering-script.sql |  29 +++++
 .../jaggery-files/applications.jag              |  40 -------
 .../jaggery-files/clusters.jag                  |  41 -------
 .../jaggery-files/member-count.jag              |  90 ---------------
 .../jaggery-files/member-info.jag               |  57 ---------
 .../jaggery-files/member-status.jag             |  77 -------------
 .../jaggery-files/metering-authentication.jag   |  75 ------------
 .../jaggery-files/mysql/applications.jag        |  40 +++++++
 .../jaggery-files/mysql/clusters.jag            |  41 +++++++
 .../jaggery-files/mysql/member-count.jag        |  90 +++++++++++++++
 .../jaggery-files/mysql/member-info.jag         |  57 +++++++++
 .../jaggery-files/mysql/member-status.jag       |  77 +++++++++++++
 .../mysql/metering-authentication.jag           |  75 ++++++++++++
 .../jaggery-files/oracle/applications.jag       |  40 +++++++
 .../jaggery-files/oracle/clusters.jag           |  42 +++++++
 .../jaggery-files/oracle/member-count.jag       | 115 +++++++++++++++++++
 .../jaggery-files/oracle/member-info.jag        |  65 +++++++++++
 .../jaggery-files/oracle/member-status.jag      |  89 ++++++++++++++
 .../oracle/metering-authentication.jag          |  75 ++++++++++++
 .../metering-dashboard/metering-mysqlscript.sql |  24 ----
 .../metering-dashboard/ues-patch/README.md      |   4 +-
 .../artifacts/monitoring-dashboard/README.md    |  21 ++--
 .../scaling_decision.xml                        |   2 +-
 .../in_flight_request.xml                       |   2 +-
 .../SparkscriptsLoadAverage/load_average.xml    |   4 +-
 .../SparkscriptsMemoryUsage/memory_usage.xml    |   4 +-
 .../scaling_decision.xml                        |   4 +-
 .../mysql/monitoring-script.sql                 |  36 ++++++
 .../oracle/monitoring-script.sql                |  35 ++++++
 .../jaggery-files/health-stats-clusters.jag     |  42 -------
 .../jaggery-files/health-stats-members.jag      |  42 -------
 .../jaggery-files/in-flight-request.jag         |  84 --------------
 .../jaggery-files/load-average.jag              |  91 ---------------
 .../jaggery-files/memory-usage.jag              |  91 ---------------
 .../jaggery-files/monitoring-authentication.jag |  74 ------------
 .../mysql/health-stats-clusters.jag             |  42 +++++++
 .../mysql/health-stats-members.jag              |  42 +++++++
 .../jaggery-files/mysql/in-flight-request.jag   |  84 ++++++++++++++
 .../jaggery-files/mysql/load-average.jag        |  91 +++++++++++++++
 .../jaggery-files/mysql/memory-usage.jag        |  91 +++++++++++++++
 .../mysql/monitoring-authentication.jag         |  74 ++++++++++++
 .../jaggery-files/mysql/scaling-details.jag     |  73 ++++++++++++
 .../oracle/health-stats-clusters.jag            |  42 +++++++
 .../oracle/health-stats-members.jag             |  43 +++++++
 .../jaggery-files/oracle/in-flight-request.jag  |  94 +++++++++++++++
 .../jaggery-files/oracle/load-average.jag       | 112 ++++++++++++++++++
 .../jaggery-files/oracle/memory-usage.jag       | 112 ++++++++++++++++++
 .../oracle/monitoring-authentication.jag        |  74 ++++++++++++
 .../jaggery-files/oracle/scaling-details.jag    |  85 ++++++++++++++
 .../jaggery-files/scaling-details.jag           |  73 ------------
 .../monitoring-mysqlscript.sql                  |  28 -----
 extensions/das/modules/distribution/README.md   |  44 +++----
 .../modules/distribution/src/assembly/bin.xml   |   4 +-
 .../das/modules/stratos-das-extension/README.md |   6 +-
 56 files changed, 2051 insertions(+), 983 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/README.md
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/README.md b/extensions/das/modules/artifacts/metering-dashboard/README.md
index c0df3d5..0a48879 100644
--- a/extensions/das/modules/artifacts/metering-dashboard/README.md
+++ b/extensions/das/modules/artifacts/metering-dashboard/README.md
@@ -11,17 +11,18 @@
 
 ## Follow the below steps to generate the metering dashboard:
 
-1. Follow instruction given in <Stratos-SOURCE-HOME>/extensions/das/stratos-das-extension/README.md file to add
+1. Follow instruction given in `<Stratos-SOURCE-HOME>/extensions/das/stratos-das-extension/README.md` file to add
 stratos-das-extension jar to DAS.
 
-2. Add jaggery files which can be found in <Stratos-DAS-Distribution>/metering-dashboard/jaggery-files/ to DAS server
- path <DAS_HOME/repository/deployment/server/jaggeryapps/portal/controllers/apis/
+2. Add jaggery files needed for your db type which can be found in
+`<Stratos-DAS-Distribution>/metering-dashboard/jaggery-files/<db>` to DAS server path
+`<DAS_HOME/repository/deployment/server/jaggeryapps/portal/controllers/apis/`
 
-3. Create MySQL database and tables using queries in
-<Stratos-DAS-Distribution>/metering-dashboard/metering-mysqlscript.sql manually.
+3. Create MySQL/Oracle database and tables using queries in
+`<Stratos-DAS-Distribution>/metering-dashboard/database-scripts/<db>/metering-script.sql` manually.
 
-4. Apply ues-patch files in <Stratos-DAS-Distribution>/metering-dashboard/ues-patch/ to DAS as mentioned in its
+4. Apply ues-patch files in `<Stratos-DAS-Distribution>/metering-dashboard/ues-patch/` to DAS as mentioned in its
 README file.
 
-5. Add stratos-metering-service car file in <Stratos-DAS-Distribution>/metering-dashboard/ to
-<DAS-HOME>/repository/deployment/server/carbonapps/ to generate the metering dashboard.
\ No newline at end of file
+5. Add stratos-metering-service car file in `<Stratos-DAS-Distribution>/metering-dashboard/` to
+`<DAS-HOME>/repository/deployment/server/carbonapps/` to generate the metering dashboard.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/database-scripts/mysql/metering-script.sql
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/database-scripts/mysql/metering-script.sql b/extensions/das/modules/artifacts/metering-dashboard/database-scripts/mysql/metering-script.sql
new file mode 100644
index 0000000..b3fe0ff
--- /dev/null
+++ b/extensions/das/modules/artifacts/metering-dashboard/database-scripts/mysql/metering-script.sql
@@ -0,0 +1,28 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+CREATE DATABASE IF NOT EXISTS ANALYTICS_FS_DB;
+CREATE DATABASE IF NOT EXISTS ANALYTICS_EVENT_STORE;
+CREATE DATABASE IF NOT EXISTS ANALYTICS_PROCESSED_DATA_STORE;
+CREATE TABLE ANALYTICS_PROCESSED_DATA_STORE.MEMBER_STATUS(Time long, ApplicationId VARCHAR(150), ClusterAlias VARCHAR
+(150), MemberId VARCHAR(150), MemberStatus VARCHAR(50));
+CREATE TABLE ANALYTICS_PROCESSED_DATA_STORE.MEMBER_COUNT(Time long, ApplicationId VARCHAR(150), ClusterAlias VARCHAR
+(150), CreatedInstanceCount int, InitializedInstanceCount int, ActiveInstanceCount int, TerminatedInstanceCount int);
+CREATE TABLE ANALYTICS_PROCESSED_DATA_STORE.MEMBER_INFORMATION(MemberId VARCHAR(150), InstanceType VARCHAR(150),
+ImageId VARCHAR(150), HostName VARCHAR(150), PrivateIPAddresses VARCHAR(150), PublicIPAddresses VARCHAR(150),
+Hypervisor VARCHAR(150), CPU VARCHAR(10) , RAM VARCHAR(10), OSName VARCHAR(150), OSVersion VARCHAR(150));

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/database-scripts/oracle/metering-script.sql
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/database-scripts/oracle/metering-script.sql b/extensions/das/modules/artifacts/metering-dashboard/database-scripts/oracle/metering-script.sql
new file mode 100644
index 0000000..c5fd915
--- /dev/null
+++ b/extensions/das/modules/artifacts/metering-dashboard/database-scripts/oracle/metering-script.sql
@@ -0,0 +1,29 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+CREATE TABLE MEMBER_STATUS(Time NUMBER(20), ApplicationId VARCHAR2(150), ClusterAlias VARCHAR2(150), MemberId VARCHAR2
+(150), MemberStatus VARCHAR2(50));
+CREATE TABLE MEMBER_COUNT(Time NUMBER(20), ApplicationId VARCHAR2(150), ClusterAlias VARCHAR2(150),
+CreatedInstanceCount NUMBER(10), InitializedInstanceCount NUMBER(10), ActiveInstanceCount NUMBER(10),
+TerminatedInstanceCount NUMBER(10));
+CREATE TABLE MEMBER_INFORMATION(MemberId VARCHAR2(150), InstanceType VARCHAR2(150), ImageId VARCHAR2(150), HostName
+VARCHAR2(150), PrivateIPAddresses VARCHAR2(150), PublicIPAddresses VARCHAR2(150), Hypervisor VARCHAR2(150), CPU
+VARCHAR2(10), RAM VARCHAR2(10), OSName VARCHAR2(150), OSVersion VARCHAR2(150));
+
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/applications.jag
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/applications.jag b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/applications.jag
deleted file mode 100644
index 851885a..0000000
--- a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/applications.jag
+++ /dev/null
@@ -1,40 +0,0 @@
-<%
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-include('metering-authentication.jag');
-
-(function () {
-    var db = new Database("WSO2_ANALYTICS_PROCESSED_DATA_STORE_DB");
-
-    try {
-        var result = db.query("SELECT DISTINCT ApplicationId FROM MEMBER_COUNT");
-
-        if (result != null) {
-            print(result);
-        }
-    }
-    catch (e) {
-        print(e.toString());
-    }
-    finally {
-        db.close();
-    }
-}());
-%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/clusters.jag
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/clusters.jag b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/clusters.jag
deleted file mode 100644
index fe863df..0000000
--- a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/clusters.jag
+++ /dev/null
@@ -1,41 +0,0 @@
-<%
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-include('metering-authentication.jag');
-
-(function () {
-    var db = new Database("WSO2_ANALYTICS_PROCESSED_DATA_STORE_DB");
-
-    try {
-        var applicationId = request.getParameter('applicationId');
-        var result = db.query("SELECT DISTINCT ClusterAlias FROM MEMBER_COUNT WHERE ApplicationId = ?", applicationId);
-
-        if (result != null) {
-            print(result);
-        }
-    }
-    catch (e) {
-        print(e.toString());
-    }
-    finally {
-        db.close();
-    }
-}());
-%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/member-count.jag
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/member-count.jag b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/member-count.jag
deleted file mode 100644
index 6850012..0000000
--- a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/member-count.jag
+++ /dev/null
@@ -1,90 +0,0 @@
-<%
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-include('metering-authentication.jag');
-
-(function () {
-    var log = new Log();
-
-    var TIME_INTERVAL_1 = '30 Min';
-    var TIME_INTERVAL_2 = '1 Hour';
-    var TIME_INTERVAL_3 = '1 Day';
-    var TIME_INTERVAL_4 = '1 Week';
-    var TIME_INTERVAL_5 = '1 Month';
-    var ALL_CLUSTERS = 'All Clusters';
-
-    var content = request.getContent();
-    var contentAsString = null;
-    if (content != '' && content != null) {
-        contentAsString = stringify(content);
-        if (log.isDebugEnabled()) {
-            log.debug("Value of content: " + contentAsString);
-        }
-    }
-
-    var db = new Database("WSO2_ANALYTICS_PROCESSED_DATA_STORE_DB");
-
-    try {
-        var result;
-
-        var timeInterval = request.getParameter("time");
-        var interval = 1800000;
-        var x_axis_interval;
-        var time_format;
-        if (timeInterval === TIME_INTERVAL_1) {
-            interval = 1800000;
-            x_axis_interval = 60;
-            time_format = '%h:%i';
-        } else if (timeInterval === TIME_INTERVAL_2) {
-            interval = 3600000;
-            x_axis_interval = 120;
-            time_format = '%h:%i';
-        } else if (timeInterval === TIME_INTERVAL_3) {
-            interval = 86400000;
-            x_axis_interval = 2880;
-            time_format = '%Y:%m:%d %h:%i';
-        } else if (timeInterval === TIME_INTERVAL_4) {
-            interval = 604800000;
-            x_axis_interval = 20160;
-            time_format = '%Y:%m:%d %h:%i';
-        } else if (timeInterval === TIME_INTERVAL_5) {
-            interval = 2419200000;
-            x_axis_interval = 80640;
-            time_format = '%Y:%m:%d';
-        }
-        var applicationId = request.getParameter("applicationId");
-        var clusterId = request.getParameter("clusterId");
-
-        if (clusterId == ALL_CLUSTERS) {
-            result = db.query("SELECT FROM_UNIXTIME(CEILING( Time/('" + x_axis_interval + "'*1000)) *'" + x_axis_interval + "', '" + time_format + "') AS Time, SUM(CreatedInstanceCount) AS CreatedInstanceCount , SUM(InitializedInstanceCount) AS InitializedInstanceCount , SUM(ActiveInstanceCount) AS ActiveInstanceCount, SUM(TerminatedInstanceCount) AS TerminatedInstanceCount FROM MEMBER_COUNT WHERE ApplicationId=? AND Time > ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000-'" + interval + "' ) AND Time <= ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000) GROUP BY FROM_UNIXTIME( CEILING( Time/('" + x_axis_interval + "'*1000)) *'"+x_axis_interval+"', '" + time_format + "'), ApplicationId", applicationId);
-        } else {
-            result = db.query("SELECT FROM_UNIXTIME(CEILING( Time/('" + x_axis_interval + "'*1000)) *'" + x_axis_interval + "', '" + time_format + "') AS Time, SUM(CreatedInstanceCount) AS CreatedInstanceCount , SUM(InitializedInstanceCount) AS InitializedInstanceCount , SUM(ActiveInstanceCount) AS ActiveInstanceCount, SUM(TerminatedInstanceCount) AS TerminatedInstanceCount FROM MEMBER_COUNT WHERE ApplicationId=? AND ClusterAlias=? AND Time > ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000-'" + interval + "' ) AND Time <= ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000) GROUP BY FROM_UNIXTIME( CEILING( Time/('" + x_axis_interval + "'*1000)) *'"+x_axis_interval+"', '" + time_format + "')", applicationId, clusterId);
-        }
-        print(result);
-
-    }
-    catch (e) {
-        print(e.toString());
-    }
-    finally {
-        db.close();
-    }
-}());
-%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/member-info.jag
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/member-info.jag b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/member-info.jag
deleted file mode 100644
index 68337f8..0000000
--- a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/member-info.jag
+++ /dev/null
@@ -1,57 +0,0 @@
-<%
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-include('metering-authentication.jag');
-
-(function () {
-    var log = new Log();
-    var ALL_CLUSTERS = 'All Clusters';
-
-    var content = request.getContent();
-    var contentAsString = null;
-    if (content != '' && content != null) {
-        contentAsString = stringify(content);
-        if (log.isDebugEnabled()) {
-            log.debug("Value of content: " + contentAsString);
-        }
-    }
-
-    var db = new Database("WSO2_ANALYTICS_PROCESSED_DATA_STORE_DB");
-
-    try {
-        var result;
-        var applicationId = request.getParameter("applicationId");
-        var clusterId = request.getParameter("clusterId");
-
-        if (clusterId == ALL_CLUSTERS) {
-            result = db.query("SELECT * FROM MEMBER_INFORMATION WHERE MemberId IN (SELECT DISTINCT MemberId FROM ANALYTICS_PROCESSED_DATA_STORE.MEMBER_STATUS WHERE ApplicationId= ?)", applicationId);
-        } else {
-            result = db.query("SELECT * FROM MEMBER_INFORMATION WHERE MemberId IN (SELECT DISTINCT MemberId FROM ANALYTICS_PROCESSED_DATA_STORE.MEMBER_STATUS WHERE ApplicationId= ? AND ClusterAlias= ?)", applicationId, clusterId);
-        }
-        print(result);
-    }
-    catch (e) {
-        print(e.toString());
-    }
-    finally {
-        db.close();
-    }
-}());
-%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/member-status.jag
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/member-status.jag b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/member-status.jag
deleted file mode 100644
index 2aff4ac..0000000
--- a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/member-status.jag
+++ /dev/null
@@ -1,77 +0,0 @@
-<%
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-include('metering-authentication.jag');
-
-(function () {
-    var log = new Log();
-
-    var TIME_INTERVAL_1 = '30 Min';
-    var TIME_INTERVAL_2 = '1 Hour';
-    var TIME_INTERVAL_3 = '1 Day';
-    var TIME_INTERVAL_4 = '1 Week';
-    var TIME_INTERVAL_5 = '1 Month';
-    var ALL_CLUSTERS = 'All Clusters';
-
-    var content = request.getContent();
-    var contentAsString = null;
-    if (content != '' && content != null) {
-        contentAsString = stringify(content);
-        if (log.isDebugEnabled()) {
-            log.debug("Value of content: " + contentAsString);
-        }
-    }
-
-    var db = new Database("WSO2_ANALYTICS_PROCESSED_DATA_STORE_DB");
-
-    try {
-        var result;
-
-        var timeInterval = request.getParameter("time");
-        var interval = 1800000;
-        if (timeInterval === TIME_INTERVAL_1) {
-            interval = 1800000;
-        } else if (timeInterval === TIME_INTERVAL_2) {
-            interval = 3600000;
-        } else if (timeInterval === TIME_INTERVAL_3) {
-            interval = 86400000;
-        } else if (timeInterval === TIME_INTERVAL_4) {
-            interval = 604800000;
-        } else if (timeInterval === TIME_INTERVAL_5) {
-            interval = 2419200000;
-        }
-        var applicationId = request.getParameter("applicationId");
-        var clusterId = request.getParameter("clusterId");
-
-        if (clusterId == ALL_CLUSTERS) {
-            result = db.query("SELECT FROM_UNIXTIME(Time/1000, '%Y:%m:%d %h:%i:%s') AS Time, MemberId, MemberStatus FROM MEMBER_STATUS WHERE ApplicationId= ? AND Time > ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000-'" + interval + "' ) AND Time <= ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000) ORDER BY MemberID, Time", applicationId);
-        }else {
-            result = db.query("SELECT FROM_UNIXTIME(Time/1000, '%Y:%m:%d %h:%i:%s') AS Time, MemberId, MemberStatus FROM MEMBER_STATUS WHERE ApplicationId= ? AND ClusterAlias= ? AND Time > ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000-'" + interval + "' ) AND Time <= ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000) ORDER BY MemberID, Time", applicationId, clusterId);
-        }
-        print(result);
-    }
-    catch (e) {
-        print(e.toString());
-    }
-    finally {
-        db.close();
-    }
-}());
-%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/metering-authentication.jag
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/metering-authentication.jag b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/metering-authentication.jag
deleted file mode 100644
index 78db550..0000000
--- a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/metering-authentication.jag
+++ /dev/null
@@ -1,75 +0,0 @@
-<%
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-(function () {
-    var log = new Log();
-
-    var HTTPS_TRANSPORT = "https";
-    var AUTHORIZATION_HEADER = "Authorization";
-    var ANALYTICS_SERVICE = "/services/AnalyticsWebService";
-    var AUTHENTICATION_SERVICE = "/services/AuthenticationAdmin";
-    var AUTH_TOKEN = "authToken";
-    var LOCALHOST = "localhost";
-    var HTTP_USER_NOT_AUTHENTICATED = 403;
-
-    var carbon = require('carbon');
-    var configs = require('/configs/designer.json');
-    var HTTPConstants = Packages.org.apache.axis2.transport.http.HTTPConstants;
-    var AnalyticsWebServiceStub = Packages.org.wso2.carbon.analytics.webservice.stub.AnalyticsWebServiceStub;
-    var AuthenticationAdminStub = Packages.org.wso2.carbon.authenticator.stub.AuthenticationAdminStub;
-
-    var analyticsWSUrl = carbon.server.address(HTTPS_TRANSPORT) + ANALYTICS_SERVICE;
-    var authenticationWSUrl = carbon.server.address(HTTPS_TRANSPORT) + AUTHENTICATION_SERVICE;
-    var analyticsStub;
-    try {
-        analyticsStub = new AnalyticsWebServiceStub(analyticsWSUrl);
-    } catch (e) {
-        if (log.isDebugEnabled()) {
-            log.debug("Unable to instantiate AnalyticsWebServiceStub instance. This could be a CEP server. Returning");
-        }
-        return;
-    }
-    var serviceClient = analyticsStub._getServiceClient();
-    var options = serviceClient.getOptions();
-    options.setManageSession(true);
-
-    var authParam = request.getHeader(AUTHORIZATION_HEADER);
-    if (authParam != null) {
-        credentials = JSUtils.authenticate(authParam);
-        authenticationAdminStub = new AuthenticationAdminStub(authenticationWSUrl);
-        authenticationAdminStub.login(credentials[0], credentials[1], LOCALHOST);
-        var serviceContext = authenticationAdminStub._getServiceClient().getLastOperationContext()
-                .getServiceContext();
-        var sessionCookie = serviceContext.getProperty(HTTPConstants.COOKIE_STRING);
-        options.setProperty(HTTPConstants.COOKIE_STRING, sessionCookie);
-    } else {
-        var token = session.get(AUTH_TOKEN);
-        if (token != null) {
-            options.setProperty(HTTPConstants.COOKIE_STRING, token);
-        } else {
-            log.error("user is not authenticated!");
-            response.status = HTTP_USER_NOT_AUTHENTICATED;
-            print('{ "status": "Failed", "message": "User is not authenticated." }');
-            return;
-        }
-    }
-});
-
-%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/applications.jag
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/applications.jag b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/applications.jag
new file mode 100644
index 0000000..851885a
--- /dev/null
+++ b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/applications.jag
@@ -0,0 +1,40 @@
+<%
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+include('metering-authentication.jag');
+
+(function () {
+    var db = new Database("WSO2_ANALYTICS_PROCESSED_DATA_STORE_DB");
+
+    try {
+        var result = db.query("SELECT DISTINCT ApplicationId FROM MEMBER_COUNT");
+
+        if (result != null) {
+            print(result);
+        }
+    }
+    catch (e) {
+        print(e.toString());
+    }
+    finally {
+        db.close();
+    }
+}());
+%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/clusters.jag
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/clusters.jag b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/clusters.jag
new file mode 100644
index 0000000..fe863df
--- /dev/null
+++ b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/clusters.jag
@@ -0,0 +1,41 @@
+<%
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+include('metering-authentication.jag');
+
+(function () {
+    var db = new Database("WSO2_ANALYTICS_PROCESSED_DATA_STORE_DB");
+
+    try {
+        var applicationId = request.getParameter('applicationId');
+        var result = db.query("SELECT DISTINCT ClusterAlias FROM MEMBER_COUNT WHERE ApplicationId = ?", applicationId);
+
+        if (result != null) {
+            print(result);
+        }
+    }
+    catch (e) {
+        print(e.toString());
+    }
+    finally {
+        db.close();
+    }
+}());
+%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/member-count.jag
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/member-count.jag b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/member-count.jag
new file mode 100644
index 0000000..6850012
--- /dev/null
+++ b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/member-count.jag
@@ -0,0 +1,90 @@
+<%
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+include('metering-authentication.jag');
+
+(function () {
+    var log = new Log();
+
+    var TIME_INTERVAL_1 = '30 Min';
+    var TIME_INTERVAL_2 = '1 Hour';
+    var TIME_INTERVAL_3 = '1 Day';
+    var TIME_INTERVAL_4 = '1 Week';
+    var TIME_INTERVAL_5 = '1 Month';
+    var ALL_CLUSTERS = 'All Clusters';
+
+    var content = request.getContent();
+    var contentAsString = null;
+    if (content != '' && content != null) {
+        contentAsString = stringify(content);
+        if (log.isDebugEnabled()) {
+            log.debug("Value of content: " + contentAsString);
+        }
+    }
+
+    var db = new Database("WSO2_ANALYTICS_PROCESSED_DATA_STORE_DB");
+
+    try {
+        var result;
+
+        var timeInterval = request.getParameter("time");
+        var interval = 1800000;
+        var x_axis_interval;
+        var time_format;
+        if (timeInterval === TIME_INTERVAL_1) {
+            interval = 1800000;
+            x_axis_interval = 60;
+            time_format = '%h:%i';
+        } else if (timeInterval === TIME_INTERVAL_2) {
+            interval = 3600000;
+            x_axis_interval = 120;
+            time_format = '%h:%i';
+        } else if (timeInterval === TIME_INTERVAL_3) {
+            interval = 86400000;
+            x_axis_interval = 2880;
+            time_format = '%Y:%m:%d %h:%i';
+        } else if (timeInterval === TIME_INTERVAL_4) {
+            interval = 604800000;
+            x_axis_interval = 20160;
+            time_format = '%Y:%m:%d %h:%i';
+        } else if (timeInterval === TIME_INTERVAL_5) {
+            interval = 2419200000;
+            x_axis_interval = 80640;
+            time_format = '%Y:%m:%d';
+        }
+        var applicationId = request.getParameter("applicationId");
+        var clusterId = request.getParameter("clusterId");
+
+        if (clusterId == ALL_CLUSTERS) {
+            result = db.query("SELECT FROM_UNIXTIME(CEILING( Time/('" + x_axis_interval + "'*1000)) *'" + x_axis_interval + "', '" + time_format + "') AS Time, SUM(CreatedInstanceCount) AS CreatedInstanceCount , SUM(InitializedInstanceCount) AS InitializedInstanceCount , SUM(ActiveInstanceCount) AS ActiveInstanceCount, SUM(TerminatedInstanceCount) AS TerminatedInstanceCount FROM MEMBER_COUNT WHERE ApplicationId=? AND Time > ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000-'" + interval + "' ) AND Time <= ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000) GROUP BY FROM_UNIXTIME( CEILING( Time/('" + x_axis_interval + "'*1000)) *'"+x_axis_interval+"', '" + time_format + "'), ApplicationId", applicationId);
+        } else {
+            result = db.query("SELECT FROM_UNIXTIME(CEILING( Time/('" + x_axis_interval + "'*1000)) *'" + x_axis_interval + "', '" + time_format + "') AS Time, SUM(CreatedInstanceCount) AS CreatedInstanceCount , SUM(InitializedInstanceCount) AS InitializedInstanceCount , SUM(ActiveInstanceCount) AS ActiveInstanceCount, SUM(TerminatedInstanceCount) AS TerminatedInstanceCount FROM MEMBER_COUNT WHERE ApplicationId=? AND ClusterAlias=? AND Time > ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000-'" + interval + "' ) AND Time <= ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000) GROUP BY FROM_UNIXTIME( CEILING( Time/('" + x_axis_interval + "'*1000)) *'"+x_axis_interval+"', '" + time_format + "')", applicationId, clusterId);
+        }
+        print(result);
+
+    }
+    catch (e) {
+        print(e.toString());
+    }
+    finally {
+        db.close();
+    }
+}());
+%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/member-info.jag
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/member-info.jag b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/member-info.jag
new file mode 100644
index 0000000..68337f8
--- /dev/null
+++ b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/member-info.jag
@@ -0,0 +1,57 @@
+<%
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+include('metering-authentication.jag');
+
+(function () {
+    var log = new Log();
+    var ALL_CLUSTERS = 'All Clusters';
+
+    var content = request.getContent();
+    var contentAsString = null;
+    if (content != '' && content != null) {
+        contentAsString = stringify(content);
+        if (log.isDebugEnabled()) {
+            log.debug("Value of content: " + contentAsString);
+        }
+    }
+
+    var db = new Database("WSO2_ANALYTICS_PROCESSED_DATA_STORE_DB");
+
+    try {
+        var result;
+        var applicationId = request.getParameter("applicationId");
+        var clusterId = request.getParameter("clusterId");
+
+        if (clusterId == ALL_CLUSTERS) {
+            result = db.query("SELECT * FROM MEMBER_INFORMATION WHERE MemberId IN (SELECT DISTINCT MemberId FROM ANALYTICS_PROCESSED_DATA_STORE.MEMBER_STATUS WHERE ApplicationId= ?)", applicationId);
+        } else {
+            result = db.query("SELECT * FROM MEMBER_INFORMATION WHERE MemberId IN (SELECT DISTINCT MemberId FROM ANALYTICS_PROCESSED_DATA_STORE.MEMBER_STATUS WHERE ApplicationId= ? AND ClusterAlias= ?)", applicationId, clusterId);
+        }
+        print(result);
+    }
+    catch (e) {
+        print(e.toString());
+    }
+    finally {
+        db.close();
+    }
+}());
+%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/member-status.jag
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/member-status.jag b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/member-status.jag
new file mode 100644
index 0000000..2aff4ac
--- /dev/null
+++ b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/member-status.jag
@@ -0,0 +1,77 @@
+<%
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+include('metering-authentication.jag');
+
+(function () {
+    var log = new Log();
+
+    var TIME_INTERVAL_1 = '30 Min';
+    var TIME_INTERVAL_2 = '1 Hour';
+    var TIME_INTERVAL_3 = '1 Day';
+    var TIME_INTERVAL_4 = '1 Week';
+    var TIME_INTERVAL_5 = '1 Month';
+    var ALL_CLUSTERS = 'All Clusters';
+
+    var content = request.getContent();
+    var contentAsString = null;
+    if (content != '' && content != null) {
+        contentAsString = stringify(content);
+        if (log.isDebugEnabled()) {
+            log.debug("Value of content: " + contentAsString);
+        }
+    }
+
+    var db = new Database("WSO2_ANALYTICS_PROCESSED_DATA_STORE_DB");
+
+    try {
+        var result;
+
+        var timeInterval = request.getParameter("time");
+        var interval = 1800000;
+        if (timeInterval === TIME_INTERVAL_1) {
+            interval = 1800000;
+        } else if (timeInterval === TIME_INTERVAL_2) {
+            interval = 3600000;
+        } else if (timeInterval === TIME_INTERVAL_3) {
+            interval = 86400000;
+        } else if (timeInterval === TIME_INTERVAL_4) {
+            interval = 604800000;
+        } else if (timeInterval === TIME_INTERVAL_5) {
+            interval = 2419200000;
+        }
+        var applicationId = request.getParameter("applicationId");
+        var clusterId = request.getParameter("clusterId");
+
+        if (clusterId == ALL_CLUSTERS) {
+            result = db.query("SELECT FROM_UNIXTIME(Time/1000, '%Y:%m:%d %h:%i:%s') AS Time, MemberId, MemberStatus FROM MEMBER_STATUS WHERE ApplicationId= ? AND Time > ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000-'" + interval + "' ) AND Time <= ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000) ORDER BY MemberID, Time", applicationId);
+        }else {
+            result = db.query("SELECT FROM_UNIXTIME(Time/1000, '%Y:%m:%d %h:%i:%s') AS Time, MemberId, MemberStatus FROM MEMBER_STATUS WHERE ApplicationId= ? AND ClusterAlias= ? AND Time > ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000-'" + interval + "' ) AND Time <= ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000) ORDER BY MemberID, Time", applicationId, clusterId);
+        }
+        print(result);
+    }
+    catch (e) {
+        print(e.toString());
+    }
+    finally {
+        db.close();
+    }
+}());
+%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/metering-authentication.jag
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/metering-authentication.jag b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/metering-authentication.jag
new file mode 100644
index 0000000..78db550
--- /dev/null
+++ b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/mysql/metering-authentication.jag
@@ -0,0 +1,75 @@
+<%
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+(function () {
+    var log = new Log();
+
+    var HTTPS_TRANSPORT = "https";
+    var AUTHORIZATION_HEADER = "Authorization";
+    var ANALYTICS_SERVICE = "/services/AnalyticsWebService";
+    var AUTHENTICATION_SERVICE = "/services/AuthenticationAdmin";
+    var AUTH_TOKEN = "authToken";
+    var LOCALHOST = "localhost";
+    var HTTP_USER_NOT_AUTHENTICATED = 403;
+
+    var carbon = require('carbon');
+    var configs = require('/configs/designer.json');
+    var HTTPConstants = Packages.org.apache.axis2.transport.http.HTTPConstants;
+    var AnalyticsWebServiceStub = Packages.org.wso2.carbon.analytics.webservice.stub.AnalyticsWebServiceStub;
+    var AuthenticationAdminStub = Packages.org.wso2.carbon.authenticator.stub.AuthenticationAdminStub;
+
+    var analyticsWSUrl = carbon.server.address(HTTPS_TRANSPORT) + ANALYTICS_SERVICE;
+    var authenticationWSUrl = carbon.server.address(HTTPS_TRANSPORT) + AUTHENTICATION_SERVICE;
+    var analyticsStub;
+    try {
+        analyticsStub = new AnalyticsWebServiceStub(analyticsWSUrl);
+    } catch (e) {
+        if (log.isDebugEnabled()) {
+            log.debug("Unable to instantiate AnalyticsWebServiceStub instance. This could be a CEP server. Returning");
+        }
+        return;
+    }
+    var serviceClient = analyticsStub._getServiceClient();
+    var options = serviceClient.getOptions();
+    options.setManageSession(true);
+
+    var authParam = request.getHeader(AUTHORIZATION_HEADER);
+    if (authParam != null) {
+        credentials = JSUtils.authenticate(authParam);
+        authenticationAdminStub = new AuthenticationAdminStub(authenticationWSUrl);
+        authenticationAdminStub.login(credentials[0], credentials[1], LOCALHOST);
+        var serviceContext = authenticationAdminStub._getServiceClient().getLastOperationContext()
+                .getServiceContext();
+        var sessionCookie = serviceContext.getProperty(HTTPConstants.COOKIE_STRING);
+        options.setProperty(HTTPConstants.COOKIE_STRING, sessionCookie);
+    } else {
+        var token = session.get(AUTH_TOKEN);
+        if (token != null) {
+            options.setProperty(HTTPConstants.COOKIE_STRING, token);
+        } else {
+            log.error("user is not authenticated!");
+            response.status = HTTP_USER_NOT_AUTHENTICATED;
+            print('{ "status": "Failed", "message": "User is not authenticated." }');
+            return;
+        }
+    }
+});
+
+%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/applications.jag
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/applications.jag b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/applications.jag
new file mode 100644
index 0000000..33346d7
--- /dev/null
+++ b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/applications.jag
@@ -0,0 +1,40 @@
+<%
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+include('metering-authentication.jag');
+
+(function () {
+    var db = new Database("WSO2_ANALYTICS_PROCESSED_DATA_STORE_DB");
+
+    try {
+        var result = db.query("SELECT DISTINCT ApplicationId \"ApplicationId\" FROM MEMBER_COUNT");
+
+        if (result != null) {
+            print(result);
+        }
+    }
+    catch (e) {
+        print(e.toString());
+    }
+    finally {
+        db.close();
+    }
+}());
+%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/clusters.jag
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/clusters.jag b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/clusters.jag
new file mode 100644
index 0000000..82b845f
--- /dev/null
+++ b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/clusters.jag
@@ -0,0 +1,42 @@
+<%
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+include('metering-authentication.jag');
+
+(function () {
+    var db = new Database("WSO2_ANALYTICS_PROCESSED_DATA_STORE_DB");
+
+    try {
+        var applicationId = request.getParameter('applicationId');
+        var result = db.query("SELECT DISTINCT ClusterAlias \"ClusterAlias\" FROM MEMBER_COUNT WHERE ApplicationId = " +
+                "?", applicationId);
+
+        if (result != null) {
+            print(result);
+        }
+    }
+    catch (e) {
+        print(e.toString());
+    }
+    finally {
+        db.close();
+    }
+}());
+%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/member-count.jag
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/member-count.jag b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/member-count.jag
new file mode 100644
index 0000000..6fae1ea
--- /dev/null
+++ b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/member-count.jag
@@ -0,0 +1,115 @@
+<%
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+include('metering-authentication.jag');
+
+(function () {
+    var log = new Log();
+
+    var TIME_INTERVAL_1 = '30 Min';
+    var TIME_INTERVAL_2 = '1 Hour';
+    var TIME_INTERVAL_3 = '1 Day';
+    var TIME_INTERVAL_4 = '1 Week';
+    var TIME_INTERVAL_5 = '1 Month';
+    var ALL_CLUSTERS = 'All Clusters';
+
+    var content = request.getContent();
+    var contentAsString = null;
+    if (content != '' && content != null) {
+        contentAsString = stringify(content);
+        if (log.isDebugEnabled()) {
+            log.debug("Value of content: " + contentAsString);
+        }
+    }
+
+    var db = new Database("WSO2_ANALYTICS_PROCESSED_DATA_STORE_DB");
+
+    try {
+        var result;
+        var timeInterval = request.getParameter("time");
+        var interval = 1800;
+        var x_axis_interval;
+        var time_format;
+        if (timeInterval === TIME_INTERVAL_1) {
+            interval = 1800;
+            x_axis_interval = 60;
+            time_format = 'hh24:mi';
+        } else if (timeInterval === TIME_INTERVAL_2) {
+            interval = 3600;
+            x_axis_interval = 120;
+            time_format = 'hh24:mi';
+        } else if (timeInterval === TIME_INTERVAL_3) {
+            interval = 86400;
+            x_axis_interval = 2880;
+            time_format = 'yyyy-mm-dd hh24:mi';
+        } else if (timeInterval === TIME_INTERVAL_4) {
+            interval = 604800;
+            x_axis_interval = 20160;
+            time_format = 'yyyy-mm-dd hh24:mi';
+        } else if (timeInterval === TIME_INTERVAL_5) {
+            interval = 2419200;
+            x_axis_interval = 80640;
+            time_format = 'yyyy-mm-dd';
+        }
+
+        var applicationId = request.getParameter("applicationId");
+        var clusterId = request.getParameter("clusterId");
+
+        if (clusterId == ALL_CLUSTERS) {
+            result = db.query("SELECT TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC' + NUMTODSINTERVAL" +
+                    "(CEIL(Time/(" + x_axis_interval + " * 1000)) * " + x_axis_interval + ", 'second')) AT LOCAL, '"
+                    + time_format + "') \"Time\", SUM(CreatedInstanceCount) AS \"CreatedInstanceCount\", SUM" +
+                    "(InitializedInstanceCount) AS \"InitializedInstanceCount\", SUM(ActiveInstanceCount) AS " +
+                    "\"ActiveInstanceCount\", SUM(TerminatedInstanceCount) AS \"TerminatedInstanceCount\" FROM " +
+                    "MEMBER_COUNT WHERE ApplicationId=? AND TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE " +
+                    "'UTC' + NUMTODSINTERVAL(Time/1000,'second')) AT LOCAL, 'yyyy-mm-dd hh24:mi') BETWEEN TO_CHAR" +
+                    "(LOCALTIMESTAMP - NUMTODSINTERVAL(" +  interval + ", 'second'),'yyyy-mm-dd hh24:mi') AND TO_CHAR" +
+                    "(LOCALTIMESTAMP,'yyyy-mm-dd hh24:mi') GROUP BY TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME " +
+                    "ZONE 'UTC' + NUMTODSINTERVAL(CEIL(Time/(" + x_axis_interval + " * 1000)) * " + x_axis_interval +
+                    ", 'second')) AT LOCAL, '" + time_format + "'), ApplicationId ORDER BY TO_CHAR((TIMESTAMP " +
+                    "'1970-01-01 00:00:00' AT TIME ZONE 'UTC'  + NUMTODSINTERVAL(CEIL(Time/(" + x_axis_interval + " *" +
+                    " 1000)) * " + x_axis_interval + ", 'second')) AT LOCAL, '" + time_format + "')", applicationId);
+        } else {
+            result = db.query("SELECT TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC' + NUMTODSINTERVAL" +
+                    "(CEIL(Time/(" + x_axis_interval + " * 1000)) * " + x_axis_interval + ", 'second')) AT LOCAL, '"
+                    + time_format + "')  \"Time\", SUM(CreatedInstanceCount) AS \"CreatedInstanceCount\", SUM" +
+                    "(InitializedInstanceCount) AS \"InitializedInstanceCount\", SUM(ActiveInstanceCount) AS " +
+                    "\"ActiveInstanceCount\", SUM(TerminatedInstanceCount) AS \"TerminatedInstanceCount\" FROM " +
+                    "MEMBER_COUNT WHERE ApplicationId=? AND ClusterAlias=? AND TO_CHAR((TIMESTAMP '1970-01-01 " +
+                    "00:00:00' AT TIME ZONE 'UTC' + NUMTODSINTERVAL(Time/1000,'second')) AT LOCAL, 'yyyy-mm-dd " +
+                    "hh24:mi') BETWEEN TO_CHAR(LOCALTIMESTAMP - NUMTODSINTERVAL(" +  interval + ", 'second')," +
+                    "'yyyy-mm-dd hh24:mi') AND TO_CHAR(LOCALTIMESTAMP,'yyyy-mm-dd hh24:mi') GROUP BY TO_CHAR(" +
+                    "(TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC' + NUMTODSINTERVAL(CEIL(Time/(" +
+                    x_axis_interval + " * 1000)) * " + x_axis_interval + ", 'second')) AT LOCAL, '" + time_format +
+                    "'), ApplicationId ORDER BY TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC'  + " +
+                    "NUMTODSINTERVAL(CEIL(Time/(" + x_axis_interval + " * 1000)) * " + x_axis_interval + ", 'second')" +
+                    ") AT LOCAL, '" + time_format + "')", applicationId, clusterId);
+        }
+        print(result);
+
+    }
+    catch (e) {
+        print(e.toString());
+    }
+    finally {
+        db.close();
+    }
+}());
+%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/member-info.jag
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/member-info.jag b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/member-info.jag
new file mode 100644
index 0000000..b37ecb8
--- /dev/null
+++ b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/member-info.jag
@@ -0,0 +1,65 @@
+<%
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+include('metering-authentication.jag');
+
+(function () {
+    var log = new Log();
+    var ALL_CLUSTERS = 'All Clusters';
+
+    var content = request.getContent();
+    var contentAsString = null;
+    if (content != '' && content != null) {
+        contentAsString = stringify(content);
+        if (log.isDebugEnabled()) {
+            log.debug("Value of content: " + contentAsString);
+        }
+    }
+
+    var db = new Database("WSO2_ANALYTICS_PROCESSED_DATA_STORE_DB");
+
+    try {
+        var result;
+        var applicationId = request.getParameter("applicationId");
+        var clusterId = request.getParameter("clusterId");
+
+        if (clusterId == ALL_CLUSTERS) {
+            result = db.query("SELECT MemberId \"MemberId\", InstanceType \"InstanceType\" , ImageId \"ImageId\", " +
+                    "HostName \"HostName\", PrivateIPAddresses \"PrivateIPAddresses\", PublicIPAddresses " +
+                    "\"PublicIPAddresses\", Hypervisor \"Hypervisor\", CPU \"CPU\", RAM \"RAM\", OSName \"OSName\" , " +
+                    "OSVersion \"OSVersion\" FROM MEMBER_INFORMATION WHERE MemberId IN (SELECT DISTINCT MemberId FROM" +
+                    " MEMBER_STATUS WHERE ApplicationId= ?)", applicationId);
+        } else {
+            result = db.query("SELECT MemberId \"MemberId\", InstanceType \"InstanceType\" , ImageId \"ImageId\", " +
+                    "HostName \"HostName\", PrivateIPAddresses \"PrivateIPAddresses\", PublicIPAddresses " +
+                    "\"PublicIPAddresses\", Hypervisor \"Hypervisor\", CPU \"CPU\", RAM \"RAM\", OSName \"OSName\" , " +
+                    "OSVersion \"OSVersion\" FROM MEMBER_INFORMATION WHERE MemberId IN (SELECT DISTINCT MemberId FROM" +
+                    " MEMBER_STATUS WHERE ApplicationId= ? AND ClusterAlias= ?)", applicationId, clusterId);
+        }
+        print(result);
+    }
+    catch (e) {
+        print(e.toString());
+    }
+    finally {
+        db.close();
+    }
+}());
+%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/member-status.jag
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/member-status.jag b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/member-status.jag
new file mode 100644
index 0000000..68cbc36
--- /dev/null
+++ b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/member-status.jag
@@ -0,0 +1,89 @@
+<%
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+include('metering-authentication.jag');
+
+(function () {
+    var log = new Log();
+
+    var TIME_INTERVAL_1 = '30 Min';
+    var TIME_INTERVAL_2 = '1 Hour';
+    var TIME_INTERVAL_3 = '1 Day';
+    var TIME_INTERVAL_4 = '1 Week';
+    var TIME_INTERVAL_5 = '1 Month';
+    var ALL_CLUSTERS = 'All Clusters';
+
+    var content = request.getContent();
+    var contentAsString = null;
+    if (content != '' && content != null) {
+        contentAsString = stringify(content);
+        if (log.isDebugEnabled()) {
+            log.debug("Value of content: " + contentAsString);
+        }
+    }
+
+    var db = new Database("WSO2_ANALYTICS_PROCESSED_DATA_STORE_DB");
+
+    try {
+        var result;
+        var timeInterval = request.getParameter("time");
+        var interval;
+        var time_format = 'yyyy-mm-dd hh24:mi:ss';
+        if (timeInterval === TIME_INTERVAL_1) {
+            interval = 1800;
+        } else if (timeInterval === TIME_INTERVAL_2) {
+            interval = 3600;
+        } else if (timeInterval === TIME_INTERVAL_3) {
+            interval = 86400;
+        } else if (timeInterval === TIME_INTERVAL_4) {
+            interval = 604800;
+        } else if (timeInterval === TIME_INTERVAL_5) {
+            interval = 2419200;
+        }
+        var applicationId = request.getParameter("applicationId");
+        var clusterId = request.getParameter("clusterId");
+
+        if (clusterId == ALL_CLUSTERS) {
+            result = db.query("SELECT TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC' + NUMTODSINTERVAL" +
+                    "(CEIL(Time/1000), 'second')) AT LOCAL, '" + time_format + "') as \"Time\", MemberId" +
+                    "\"MemberId\", MemberStatus \"MemberStatus\" FROM MEMBER_STATUS WHERE ApplicationId=? AND TO_CHAR" +
+                    "((TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC' + NUMTODSINTERVAL(Time/1000,'second')) AT " +
+                    "LOCAL, 'yyyy-mm-dd hh24:mi') BETWEEN TO_CHAR(LOCALTIMESTAMP - NUMTODSINTERVAL(" + interval + "," +
+                    "'second'),'yyyy-mm-dd hh24:mi') AND TO_CHAR(LOCALTIMESTAMP,'yyyy-mm-dd hh24:mi') ORDER BY Time," +
+                    "MemberID", applicationId);
+        } else {
+            result = db.query("SELECT TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC' + NUMTODSINTERVAL" +
+                    "(CEIL(Time/1000), 'second')) AT LOCAL, '" + time_format + "') as \"Time\", MemberId" +
+                    " \"MemberId\", MemberStatus \"MemberStatus\" FROM MEMBER_STATUS WHERE ApplicationId=? AND" +
+                    " ClusterAlias=? AND TO_CHAR((TIMESTAMP '1970-01-01 00:00:00' AT TIME ZONE 'UTC' + " +
+                    "NUMTODSINTERVAL(Time/1000,'second')) AT LOCAL, 'yyyy-mm-dd hh24:mi') BETWEEN TO_CHAR" +
+                    "(LOCALTIMESTAMP - NUMTODSINTERVAL(" + interval + ", 'second'),'yyyy-mm-dd hh24:mi') AND TO_CHAR" +
+                    "(LOCALTIMESTAMP, 'yyyy-mm-dd hh24:mi') ORDER BY Time, MemberID", applicationId, clusterId);
+        }
+        print(result);
+    }
+    catch (e) {
+        print(e.toString());
+    }
+    finally {
+        db.close();
+    }
+}());
+%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/metering-authentication.jag
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/metering-authentication.jag b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/metering-authentication.jag
new file mode 100644
index 0000000..78db550
--- /dev/null
+++ b/extensions/das/modules/artifacts/metering-dashboard/jaggery-files/oracle/metering-authentication.jag
@@ -0,0 +1,75 @@
+<%
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+(function () {
+    var log = new Log();
+
+    var HTTPS_TRANSPORT = "https";
+    var AUTHORIZATION_HEADER = "Authorization";
+    var ANALYTICS_SERVICE = "/services/AnalyticsWebService";
+    var AUTHENTICATION_SERVICE = "/services/AuthenticationAdmin";
+    var AUTH_TOKEN = "authToken";
+    var LOCALHOST = "localhost";
+    var HTTP_USER_NOT_AUTHENTICATED = 403;
+
+    var carbon = require('carbon');
+    var configs = require('/configs/designer.json');
+    var HTTPConstants = Packages.org.apache.axis2.transport.http.HTTPConstants;
+    var AnalyticsWebServiceStub = Packages.org.wso2.carbon.analytics.webservice.stub.AnalyticsWebServiceStub;
+    var AuthenticationAdminStub = Packages.org.wso2.carbon.authenticator.stub.AuthenticationAdminStub;
+
+    var analyticsWSUrl = carbon.server.address(HTTPS_TRANSPORT) + ANALYTICS_SERVICE;
+    var authenticationWSUrl = carbon.server.address(HTTPS_TRANSPORT) + AUTHENTICATION_SERVICE;
+    var analyticsStub;
+    try {
+        analyticsStub = new AnalyticsWebServiceStub(analyticsWSUrl);
+    } catch (e) {
+        if (log.isDebugEnabled()) {
+            log.debug("Unable to instantiate AnalyticsWebServiceStub instance. This could be a CEP server. Returning");
+        }
+        return;
+    }
+    var serviceClient = analyticsStub._getServiceClient();
+    var options = serviceClient.getOptions();
+    options.setManageSession(true);
+
+    var authParam = request.getHeader(AUTHORIZATION_HEADER);
+    if (authParam != null) {
+        credentials = JSUtils.authenticate(authParam);
+        authenticationAdminStub = new AuthenticationAdminStub(authenticationWSUrl);
+        authenticationAdminStub.login(credentials[0], credentials[1], LOCALHOST);
+        var serviceContext = authenticationAdminStub._getServiceClient().getLastOperationContext()
+                .getServiceContext();
+        var sessionCookie = serviceContext.getProperty(HTTPConstants.COOKIE_STRING);
+        options.setProperty(HTTPConstants.COOKIE_STRING, sessionCookie);
+    } else {
+        var token = session.get(AUTH_TOKEN);
+        if (token != null) {
+            options.setProperty(HTTPConstants.COOKIE_STRING, token);
+        } else {
+            log.error("user is not authenticated!");
+            response.status = HTTP_USER_NOT_AUTHENTICATED;
+            print('{ "status": "Failed", "message": "User is not authenticated." }');
+            return;
+        }
+    }
+});
+
+%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/metering-mysqlscript.sql
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/metering-mysqlscript.sql b/extensions/das/modules/artifacts/metering-dashboard/metering-mysqlscript.sql
deleted file mode 100644
index c84d38f..0000000
--- a/extensions/das/modules/artifacts/metering-dashboard/metering-mysqlscript.sql
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-CREATE DATABASE IF NOT EXISTS ANALYTICS_FS_DB;
-CREATE DATABASE IF NOT EXISTS ANALYTICS_EVENT_STORE;
-CREATE DATABASE IF NOT EXISTS ANALYTICS_PROCESSED_DATA_STORE;
-CREATE TABLE ANALYTICS_PROCESSED_DATA_STORE.MEMBER_STATUS(Time long, ApplicationId VARCHAR(150), ClusterAlias VARCHAR(150), MemberId VARCHAR(150), MemberStatus VARCHAR(50));
-CREATE TABLE ANALYTICS_PROCESSED_DATA_STORE.MEMBER_COUNT(Time long, ApplicationId VARCHAR(150), ClusterAlias VARCHAR(150), CreatedInstanceCount int, InitializedInstanceCount int, ActiveInstanceCount int, TerminatedInstanceCount int);
-CREATE TABLE ANALYTICS_PROCESSED_DATA_STORE.MEMBER_INFORMATION(MemberId VARCHAR(150), InstanceType VARCHAR(150), ImageId VARCHAR(150), HostName VARCHAR(150), PrivateIPAddresses VARCHAR(150), PublicIPAddresses VARCHAR(150), Hypervisor VARCHAR(150), CPU VARCHAR(10) , RAM VARCHAR(10), OSName VARCHAR(150), OSVersion VARCHAR(150));

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/metering-dashboard/ues-patch/README.md
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/metering-dashboard/ues-patch/README.md b/extensions/das/modules/artifacts/metering-dashboard/ues-patch/README.md
index 0d85e02..9ac2469 100644
--- a/extensions/das/modules/artifacts/metering-dashboard/ues-patch/README.md
+++ b/extensions/das/modules/artifacts/metering-dashboard/ues-patch/README.md
@@ -5,7 +5,7 @@ You can find the related UES product jira here: https://wso2.org/jira/browse/UES
 
 Please follow below steps to apply the patch locally:
 
-1. Copy 'ues-gadgets.js' and 'ues-pubsub.js' files to <DAS-HOME>/repository/deployment/server/jaggeryapps/portal/js/ 
+1. Copy 'ues-gadgets.js' and 'ues-pubsub.js' files to `<DAS-HOME>/repository/deployment/server/jaggeryapps/portal/js/`
 folder.
 
-2. Copy 'dashboard.jag' file to <DAS-HOME>/repository/deployment/server/jaggeryapps/portal/theme/templates/ folder.
\ No newline at end of file
+2. Copy 'dashboard.jag' file to `<DAS-HOME>/repository/deployment/server/jaggeryapps/portal/theme/templates/` folder.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/monitoring-dashboard/README.md
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/README.md b/extensions/das/modules/artifacts/monitoring-dashboard/README.md
index 0f5ca8e..583104a 100644
--- a/extensions/das/modules/artifacts/monitoring-dashboard/README.md
+++ b/extensions/das/modules/artifacts/monitoring-dashboard/README.md
@@ -8,18 +8,19 @@ Gadgets, SparkScripts and Dashboard artifacts.
 
 ## Follow the below steps to generate the monitoring dashboard:
 
-1. Add jaggery files which can be found in <Stratos-DAS-Distribution>/monitoring-dashboard/jaggery-files/ to DAS path
- <DAS_HOME/repository/deployment/server/jaggeryapps/portal/controllers/apis/.
+1. Add jaggery files needed for your database type which can be found in
+`<Stratos-DAS-Distribution>/monitoring-dashboard/jaggery-files/<db>/` to DAS server path
+`<DAS_HOME/repository/deployment/server/jaggeryapps/portal/controllers/apis/`.
 
-2. Create MySQL database and tables using queries in
-<Stratos-DAS-Distribution>/monitoring-dashboard/monitoring-mysqlscript.sql manually.
+2. Create MySQL/Oracle database and tables using queries in
+`<Stratos-DAS-Distribution>/monitoring-dashboard/database-scripts/<db>/monitoring-script.sql` manually.
 
-3. Copy CEP  EventFormatter artifacts in <Stratos-DAS-Distribution>/wso2cep-<version>/eventformatters/ to
-<CEP-HOME>/repository/deployment/server/eventformatters/.
+3. Copy CEP  EventFormatter artifacts in `<Stratos-DAS-Distribution>/wso2cep-<version>/eventformatters/` to
+`<CEP-HOME>/repository/deployment/server/eventformatters/`.
 
-4. Copy CEP OutputEventAdapter artifact in <Stratos-DAS-Distribution>/wso2cep-<version>/outputeventadaptors/ to
-<CEP-HOME>/repository/deployment/server/outputeventadaptors  and update the tcp and ssl ports according to DAS server
+4. Copy CEP OutputEventAdapter artifact in `<Stratos-DAS-Distribution>/wso2cep-<version>/outputeventadaptors/` to
+`<CEP-HOME>/repository/deployment/server/outputeventadaptors/`  and update the tcp and ssl ports according to DAS server
  port offset.
 
-5. Add stratos-monitoring-service car file in <Stratos-DAS-Distribution>/monitoring-dashboard/ to
-<DAS-HOME>/repository/deployment/server/carbonapps/ to generate the monitoring dashboard.
+5. Add stratos-monitoring-service car file in `<Stratos-DAS-Distribution>/monitoring-dashboard/` to
+`<DAS-HOME>/repository/deployment/server/carbonapps/` to generate the monitoring dashboard.

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/EventstoreScalingDecision/scaling_decision.xml
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/EventstoreScalingDecision/scaling_decision.xml b/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/EventstoreScalingDecision/scaling_decision.xml
index 49c07ac..e239f84 100644
--- a/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/EventstoreScalingDecision/scaling_decision.xml
+++ b/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/EventstoreScalingDecision/scaling_decision.xml
@@ -30,7 +30,7 @@
         </ColumnDefinition>
         <ColumnDefinition>
             <Name>scaling_decision_id</Name>
-            <EnableIndexing>true</EnableIndexing>
+            <EableIndexing>false</EableIndexing>
             <IsPrimaryKey>true</IsPrimaryKey>
             <EnableScoreParam>false</EnableScoreParam>
             <Type>STRING</Type>

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/SparkscriptsInFlightRequest/in_flight_request.xml
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/SparkscriptsInFlightRequest/in_flight_request.xml b/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/SparkscriptsInFlightRequest/in_flight_request.xml
index 70fb660..ee3636a 100644
--- a/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/SparkscriptsInFlightRequest/in_flight_request.xml
+++ b/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/SparkscriptsInFlightRequest/in_flight_request.xml
@@ -27,7 +27,7 @@
         OPTIONS (tableName "AVERAGE_IN_FLIGHT_REQUESTS");
 
         create temporary table average_in_flight_requests_new
-        using CarbonJDBC options (dataSource "WSO2_ANALYTICS_EVENT_STORE_DB", tableName "AVERAGE_IN_FLIGHT_REQUESTS");
+        using CarbonJDBC options (dataSource "WSO2_ANALYTICS_EVENT_STORE_DB", tableName "AVG_IN_FLIGHT_REQUESTS");
 
         INSERT OVERWRITE TABLE average_in_flight_requests_new select * from average_in_flight_requests;
     </Script>

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/SparkscriptsLoadAverage/load_average.xml
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/SparkscriptsLoadAverage/load_average.xml b/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/SparkscriptsLoadAverage/load_average.xml
index 3dcc196..cc14215 100644
--- a/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/SparkscriptsLoadAverage/load_average.xml
+++ b/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/SparkscriptsLoadAverage/load_average.xml
@@ -27,7 +27,7 @@
         OPTIONS (tableName "AVERAGE_LOAD_AVERAGE_STATS");
 
         create temporary table average_load_average_stats_new
-        using CarbonJDBC options (dataSource "WSO2_ANALYTICS_EVENT_STORE_DB", tableName "AVERAGE_LOAD_AVERAGE_STATS");
+        using CarbonJDBC options (dataSource "WSO2_ANALYTICS_EVENT_STORE_DB", tableName "AVG_LOAD_AVERAGE_STATS");
 
         INSERT OVERWRITE TABLE average_load_average_stats_new select timestamp, cluster_id, cluster_instance_id,
         network_partition_id, average_load_average from average_load_average_stats;
@@ -37,7 +37,7 @@
         OPTIONS (tableName "MEMBER_AVERAGE_LOAD_AVERAGE_STATS");
 
         create temporary table member_average_load_average_stats_new
-        using CarbonJDBC options (dataSource "WSO2_ANALYTICS_EVENT_STORE_DB", tableName "MEMBER_AVERAGE_LOAD_AVERAGE_STATS");
+        using CarbonJDBC options (dataSource "WSO2_ANALYTICS_EVENT_STORE_DB", tableName "M_AVG_LOAD_AVERAGE_STATS");
 
         INSERT OVERWRITE TABLE member_average_load_average_stats_new select timestamp, member_id, cluster_id, cluster_instance_id,
         network_partition_id, member_average_load_average from member_average_load_average_stats;

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/SparkscriptsMemoryUsage/memory_usage.xml
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/SparkscriptsMemoryUsage/memory_usage.xml b/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/SparkscriptsMemoryUsage/memory_usage.xml
index b93f503..8e15cd3 100644
--- a/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/SparkscriptsMemoryUsage/memory_usage.xml
+++ b/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/SparkscriptsMemoryUsage/memory_usage.xml
@@ -27,7 +27,7 @@
         OPTIONS (tableName "AVERAGE_MEMORY_CONSUMPTION_STATS");
 
         create temporary table average_memory_consumption_stats_new
-        using CarbonJDBC options (dataSource "WSO2_ANALYTICS_EVENT_STORE_DB", tableName "AVERAGE_MEMORY_CONSUMPTION_STATS");
+        using CarbonJDBC options (dataSource "WSO2_ANALYTICS_EVENT_STORE_DB", tableName "AVG_MEMORY_CONSUMPTION_STATS");
 
         INSERT OVERWRITE TABLE average_memory_consumption_stats_new select timestamp, cluster_id, cluster_instance_id,
         network_partition_id, average_memory_consumption from average_memory_consumption_stats;
@@ -37,7 +37,7 @@
         OPTIONS (tableName "MEMBER_AVERAGE_MEMORY_CONSUMPTION_STATS");
 
         create temporary table member_average_memory_consumption_stats_new
-        using CarbonJDBC options (dataSource "WSO2_ANALYTICS_EVENT_STORE_DB", tableName "MEMBER_AVERAGE_MEMORY_CONSUMPTION_STATS");
+        using CarbonJDBC options (dataSource "WSO2_ANALYTICS_EVENT_STORE_DB", tableName "M_AVG_MEMORY_CONSUMPTION_STATS");
 
         INSERT OVERWRITE TABLE member_average_memory_consumption_stats_new select timestamp, member_id, cluster_id, cluster_instance_id,
         network_partition_id, member_average_memory_consumption from member_average_memory_consumption_stats;

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/SparkscriptsScalingDecision/scaling_decision.xml
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/SparkscriptsScalingDecision/scaling_decision.xml b/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/SparkscriptsScalingDecision/scaling_decision.xml
index c7f9730..743adc9 100644
--- a/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/SparkscriptsScalingDecision/scaling_decision.xml
+++ b/extensions/das/modules/artifacts/monitoring-dashboard/capps/stratos-monitoring-service/SparkscriptsScalingDecision/scaling_decision.xml
@@ -22,14 +22,14 @@
 <Analytics>
     <Name>scaling_decision</Name>
     <Script>
-        CREATE TEMPORARY TABLE scalingdecision
+        CREATE TEMPORARY TABLE scaling_decision
         USING CarbonAnalytics
         OPTIONS (tableName "SCALING_DECISION");
 
         create temporary table scaling_details
         using CarbonJDBC options (dataSource "WSO2_ANALYTICS_EVENT_STORE_DB", tableName "SCALING_DETAILS");
 
-        INSERT OVERWRITE TABLE scaling_details select * from scalingdecision;
+        INSERT OVERWRITE TABLE scaling_details select * from scaling_decision;
     </Script>
     <CronExpression>0/15 * * * * ?</CronExpression>
 </Analytics>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/18c09319/extensions/das/modules/artifacts/monitoring-dashboard/database-scripts/mysql/monitoring-script.sql
----------------------------------------------------------------------
diff --git a/extensions/das/modules/artifacts/monitoring-dashboard/database-scripts/mysql/monitoring-script.sql b/extensions/das/modules/artifacts/monitoring-dashboard/database-scripts/mysql/monitoring-script.sql
new file mode 100644
index 0000000..9c31466
--- /dev/null
+++ b/extensions/das/modules/artifacts/monitoring-dashboard/database-scripts/mysql/monitoring-script.sql
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+CREATE DATABASE IF NOT EXISTS ANALYTICS_FS_DB;
+CREATE DATABASE IF NOT EXISTS ANALYTICS_EVENT_STORE;
+CREATE DATABASE IF NOT EXISTS ANALYTICS_PROCESSED_DATA_STORE;
+CREATE TABLE ANALYTICS_EVENT_STORE.AVG_MEMORY_CONSUMPTION_STATS(Time long, ClusterId VARCHAR(150), ClusterInstanceId
+VARCHAR(150), NetworkPartitionId VARCHAR(150), Value DOUBLE);
+CREATE TABLE ANALYTICS_EVENT_STORE.M_AVG_MEMORY_CONSUMPTION_STATS(Time long, MemberId VARCHAR(150), ClusterId VARCHAR
+(150), ClusterInstanceId VARCHAR(150), NetworkPartitionId VARCHAR(150), Value DOUBLE);
+CREATE TABLE ANALYTICS_EVENT_STORE.AVG_LOAD_AVERAGE_STATS(Time long, ClusterId VARCHAR(150), ClusterInstanceId
+VARCHAR(150), NetworkPartitionId VARCHAR(150), Value DOUBLE);
+CREATE TABLE ANALYTICS_EVENT_STORE.M_AVG_LOAD_AVERAGE_STATS(Time long, MemberId VARCHAR(150), ClusterId VARCHAR(150),
+ ClusterInstanceId VARCHAR(150), NetworkPartitionId VARCHAR(150), Value DOUBLE);
+CREATE TABLE ANALYTICS_EVENT_STORE.AVG_IN_FLIGHT_REQUESTS(Time long, ClusterId VARCHAR(150), ClusterInstanceId
+VARCHAR(150), NetworkPartitionId VARCHAR(150), COUNT DOUBLE);
+CREATE TABLE ANALYTICS_EVENT_STORE.SCALING_DETAILS(Time long, ScalingDecisionId VARCHAR(150), ClusterId VARCHAR(150),
+MinInstanceCount INT, MaxInstanceCount INT, RIFPredicted INT, RIFThreshold INT ,RIFRequiredInstances INT, MCPredicted
+ INT, MCThreshold INT, MCRequiredInstances INT ,LAPredicted INT, LAThreshold INT,LARequiredInstances INT,
+ RequiredInstanceCount INT, ActiveInstanceCount INT, AdditionalInstanceCount INT, ScalingReason VARCHAR(150));