Apache Kylin : Analytical Data Warehouse for Big Data
Kylin 的监控系统的验证, 解释和增强
一 背景
在 Kylin 2.3 发布后, eBay 的 Kylin team 发布了 System Cube 和 Dashboard, 使得 Kylin 用户可以更加容易地收集和观测 Kylin 应用级别的 Metrics 信息. 在目前版本的 Kylin, 通过配置 System Cube 为 HiveSink 或者 KafkaSink, 可以将 Metrics 信息发布到不同的 Sink, 并且通过定时调度构建任务可以构建 System Cube 以满足通过 SQL 查询 Kylin的系统信息. 此外, 借助 Dashboard 用户可以轻松地做到 Kylin 系统监控信息的可视化分析.
在 Kylin 3.0, eBay 的 Kylin team 发布了另外一个特性, 也就是 Real-time OLAP, 可以使得用户可以实时地获取和查询流式数据源.
这里, 我尝试探索如何将 System Cube 和 Real-time OLAP 相集成, 来降低 System Cube 的数据准备延迟. 事实上, System Cube 本身已经包含了 KafkaSink, 所以需要增加的工作是修改 SSCreator, 使之能准备 Real-time OLAP 所需的 Cube 元数据.
二 设计
eBay 引入的 System Cube 特性引入了一个新的 Metrics System, 代码主要包含在 core-metrics, metrics-reporter-hive, metrics-reporter-kafka 三个 Maven module中, 另外还有 QueryMetricsFacade, JobMetricsFacade.
JIRA issue 列表如下:
Metrics System 示意图如下:
三 如何使用
1. 开启 Metrics 信息收集
kylin.metrics.monitor-enabled=true kylin.metrics.reporter-job-enabled=true kylin.metrics.reporter-query-enabled=true kylin.web.dashboard-enabled=true
2. 准备 System Cube 所需的参数文件
[ { "sink": "hive", "storage_type": 2, "cube_desc_override_properties": { "kylin.cube.algorithm": "INMEM", "kylin.cube.max-building-segments": "1" } }, { "sink": "kafka", "storage_type": 3, "cube_desc_override_properties": { "kylin.cube.algorithm": "INMEM", "kylin.stream.cube.window": 28800, "kylin.stream.cube.duration": 3600, "kylin.stream.segment.retention.policy": "fullBuild", "kylin.cube.max-building-segments": "20" }, "table_properties": { "bootstrap.servers": "{YOUR_SERVERS_LIST}" } } ]
3. 生成 System Cube(Real-time OLAP) 元数据
4. 创建 Kafka Topic
在 create_kafka_topic_for_system_cubes.sh 中, 参数 zookeeper,
sh create_kafka_topic_for_system_cubes.sh
5. 导入 Cube 元数据
sh bin/metastore.sh restore system-cube/
6. 更新 kylinMetrics.xml
Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> <description>Kylin Metrics Related Configuration (System Cube)</description> <!-- A Reservoir which don't staged metrics message at all, emit it in no time. Maybe good for debug purpose.--> <bean id="instantReservoir" class="org.apache.kylin.metrics.lib.impl.InstantReservoir"/> <bean id="kafkaSink" class="org.apache.kylin.metrics.lib.impl.kafka.KafkaSink"/> <bean id="initMetricsManager" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> <property name="targetClass" value="org.apache.kylin.metrics.MetricsManager"/> <property name="targetMethod" value="initMetricsManager"/> <property name="arguments"> <list> <!-- Sink of System Cube. --> <ref bean="kafkaSink"/> <!-- Bind properties for each ActiveReservoirReporter. --> <map key-type="org.apache.kylin.metrics.lib.ActiveReservoir" value-type="java.util.List"> <!-- Each ActiveReservoir can have multi ReservoirReporter --> <entry key-ref="instantReservoir"> <list> <bean class="org.apache.kylin.common.util.Pair"> <!-- Implementation of ReservoirReporter--> <property name="first" value="org.apache.kylin.metrics.lib.impl.kafka.KafkaReservoirReporter"/> <!-- Properties for specific ReservoirReporter--> <property name="second"> <props> <prop key="bootstrap.servers">cdh-master:9092,cdh-worker-1:9092,cdh-worker-2:9092</prop> </props> </property> </bean> </list> </entry> </map> </list> </property> </bean> </beans>
7. 启用 System Cube
四 Metrics信息
五 参考链接
http://kylin.apache.org/docs/tutorial/setup_systemcube.html
http://kylin.apache.org/docs/tutorial/realtime_olap.html
http://kylin.apache.org/docs/tutorial/use_dashboard.html
http://kylin.apache.org/blog/2016/08/27/query-metrics-in-kylin/