blob: efebc24b08cae867c46c2755b5400b2b8afbd7c1 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
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.
-->
<Analytics>
<Name>member_count</Name>
<Script>
CREATE TEMPORARY TABLE memberstatus
USING CarbonAnalytics
OPTIONS (tableName "MEMBER_LIFECYCLE");
create temporary table member_count
using CarbonJDBC options (dataSource "WSO2_ANALYTICS_PROCESSED_DATA_STORE_DB", tableName "MEMBER_COUNT");
;WITH MemberCount as
(select application_id, cluster_alias,
count(case when member_status='Created' and timestamp &gt; current_time(null)-10000 and
timestamp&lt;= current_time(null) then 1 else NULL end) as created_instance_count,
count(case when member_status='Initialized' and timestamp &gt; current_time(null)-10000 and
timestamp&lt;= current_time(null) then 1 else NULL end) as initialized_instance_count,
count(case when member_status='Active' and timestamp &gt; current_time(null)-10000 and
timestamp&lt;= current_time(null) then 1 else NULL end) as active_instance_count,
count(case when member_status='Terminated' and timestamp &gt; current_time(null)-10000 and
timestamp&lt;= current_time(null) then 1 else NULL end) as terminated_instance_count
from memberstatus group by application_id, cluster_alias)
INSERT INTO table member_count
select current_time(null), application_id, cluster_alias,
created_instance_count,initialized_instance_count,active_instance_count,
terminated_instance_count from MemberCount;
create temporary table member_status_new
using CarbonJDBC options (dataSource "WSO2_ANALYTICS_PROCESSED_DATA_STORE_DB", tableName "MEMBER_STATUS");
INSERT OVERWRITE TABLE member_status_new select timestamp, application_id, cluster_alias, member_id,
member_status from memberstatus;
</Script>
<CronExpression>0/10 * * * * ?</CronExpression>
</Analytics>