电子科学技术第 02 卷第 06 期 2015 年 11 月 Electronic Science & Technology Vol.02 No.06 Nov.2015 年 基于 ELK 和 Spark Streaming 的日志分析系统设计与实现 李祥池 ( 杭州华三通信技术有限公司北京研究所, 北京,100085) 摘要 : 在大数据时代 对数据平台各组件的运行状态实时监控与运行分析具有重要意义 实现该目的需要符合企业自身应用场景的日志处理解决方案 本文基于业界主流的开源日志解决方案 ELK Stack 探讨该方案中各组件的主要功能和工作原理 以及其在解析数据库日志中的使用方法 并将该方案与分布式消息队列 Kafka 整合以保证数据可靠性 与 Spark 流数据处理框架 Spark Streaming 整合以实现实时告警 为数据平台的运维监控工作提供参考 关键词 :ELK Spark Kafka 日志分析中图分类号 :TP393.1 文献标识码 :B 文章编号 : 2095-8595 (2015) 06-674-05 电子科学技术 URL: http//www.china-est.com.cn DOI: 10.16453/j.issn.2095-8595.2015.06.013 Design and Implementation of Log Analysis System Based on ELK and Spark Streaming Xiangchi Li (Beijing Institute of H3C Technologies Co., Limited, Beijing, 100085, China) Abstract: In the era of big data, real-time monitoring of running status and operation analysis is significant to the data platform components. The realization of the objective needs log processing solutions in accordance with company's own application's situation. This article is based on the popular open source log process solution ELK Stack, discusses the scheme of the main functions of the components and working principle, and the methods of processing the database log, and integrated with Kafka to ensure the data reliability, and also integrated with Spark Streaming in order to realize the real-time alarm. This paper provides a reference for data platform operational monitoring environment. Key words: ELK; Spark; Kafka; Log Analysis 引言 [1] 674
第 06 期 李祥池 : 基于 ELK 和 Spark Streaming 的日志分析系统设计与实现 1 日志 1.1 日志定义 IT 1.2 日志处理方案演进 v1.0 v2.0 Hadoop Storm Spark Hadoop/Storm/Spark v3.0 TB Splunk ELK SILK 1 ELK Spark Hadoop 2 ELK Stack ELK Stack 1 Elastic https://www.elastic. co/ [2] Logstash Lucene Elasticsearch Kibana 2.1 Logstash Input Filter Output Logstash 675
2015 年 Codec 2 Logstash Input Multiline 2 Filter Grok Mutate Elasticsearch Elasticsearch Gossip Cluster name Elasticsearch Index Index Type Document json Filter json Output TCP Email 2.2 Elasticsearch 2.3 Kibana Kibana Elasticsearch Elasticsearch 3 3 Kibana Dashboard 676
第 06 期 李祥池 : 基于 ELK 和 Spark Streaming 的日志分析系统设计与实现 3 Kafka Kafka LinkedIn - [3] Server Kafka Broker DB2 Apache Logstash Kafka Output Kafka Broker Kafka Kafka Logstash Input Kafka Zookeeper Kafka Write Ahead Log WAL Kafka Zookeeper Topic Zookeeper 4 Kafka cluster 4 Kafka cluster Push&Pull Kafka 5 5 https://softwaremill.com/mqperf/ 4 Spark Spark AMP (Algorithms Machines and People Lab) [4] Spark Spark Streaming Storm Storm Spark Streaming Mini-batch Spark Streaming Kafka Kafka API Spark Kafka Spark Spark Job Spark Streaming Write Ahead Logs WAL Kafka WAL HDFS CreateDirectStream Kafka WAL 677
2015 年 Kafka RDD WAL Spark Streaming Spark Streaming Zookeeper/Kafka Spark Streaming Spark Streaming Tuple 6 6 5 结论 [3] [4] http://karaf.apache.org/. https://www.elastic.co/downloads/elasticsearch. ELK Stack Kafka Spark Streaming 作者简介 : 李祥池 (1988-) 硕士研究生 工程师 就职于杭州华三通信技术有限公司 研究方向 SDN 虚拟化 大数据 E-mail: yuanzhidanggui@126.com 参考文献 [1] [2] [M]., 2014. http://spark.apache.org/. 678