ELK log analysis system modular introduction

1. Introduction to ELK log analysis system

1.1 Overview

  • ELK log analysis system
E:ElasticSearch Cluster
L:LogStash Agent
K:kibana Server

1.2 Log server

  • Improve safety
  • Centralized storage of logs
  • Defect: Difficulty in analyzing logs

1.3 Log processing steps

1.将日志进行集中化管理,即将APP servers的日志进行集中化管理到Logstash agent
2.将日志格式化(Logstash)并输出到 Elasticsearch
3.对格式化后的数据进行索引和存储(Elasticsearch)
4.前端数据的展示(Kibana)
可以在线查看界面化展示

note:

Logstash收集APP server产生的log,然后存放到Elasticsearch集群节点中
kibana从Elasticsearch集群节点中查询数据生成图表,再返回给Brower

Insert picture description here

1.4 How the ELK architecture works

Insert picture description here

1) Logstash部署至服务主机,对各个服务的日志进行采集、过滤、推送。
2) Elasticsearch存储Logstash传送的结构化数据,提供给Kibana。
3) Kibana提供用户UIweb页面进行,数据展示和分析形成图表等。
4) logs 泛指,各种日志文件以及日志信息:windows,negix,tomcat,webserver等等。

2. Introduction to Elasticsearch

2.1 Overview of Elasticsearch

  • Provides a full-text search engine with distributed multi-user capabilities
是一个基于Lucene的搜索服务器
基于restful web接口
使用java开发
作为apache许可条款下的开放源码发布,是第二流行的企业搜索引擎
被设计用于云计算中,能够达到实时搜索、稳定、可靠、快速、安装实用方便的需求

2.2 Important concepts of Elasticsearch

2.2.1 Near Real Time (NRT)

  • Elasticsearch is a near-instant search platform. There is a slight delay in the process of indexing a document to know that the document can be searched (usually 1S)

2.2.2 Cluster (cluster)

  • Organized by one or more nodes, they jointly hold the entire data and provide indexing and search functions together

  • One of the nodes is the master node. This node can be elected and provides cross-node joint indexing and search functions

  • The cluster has a uniquely identifying name, the default is elaticsearch

  • The cluster name is very important. Each node is added to its cluster based on the cluster name;
    therefore, to ensure the uniqueness of the cluster, use different cluster names in different environments

  • A cluster can only have one node. It is recommended to configure the cluster mode when configuring elasticsearch

2.2.3 Node

1) 节点就是一台单一的服务器,是集群的一部分,存储数据并参与集群的索引和搜索功能

2) 像集群一样,节点之间可是通过名字来标识区分,默认是在节点启动时随机分配的字符名

3) 当然,你可以自己定义,该名字很重要,起到在集群中定位到对应的节点

4) 节点可以通过指定集群名字来加入到集群中,默认情况下,每个节点被设置成加入到elasticsearch集群。

5) 如果启动了多个节点,假设能够自动发现对方,他们将会自动组建一个名为elastisearch的集群

2.2.4 Index (index)

  • Index (library) → type (table) → document (record)
1) 一个索引就是一个拥有几分相似特征的文档的集合

2) 比如说,你可以有一个客户数据的索引、一个产品目录的索引、还有一个订单数据的索引

3) 一个索引用一个名字来标识(必须全部是小写字母组合),并且当我们要对相应的索引中的文档进行索引、收缩、更新和
删除的时候,都要用到这个名字

4) 在一个集群中,可以定义多个索引

2.2.5 Type and Document

  • Type
1) 在一个索引中,你可以定义一种或多种类型

2) 一个类型是你的索引的一个逻辑上的分类分区,其寓意完全由你来定义。通常,会为具有一组共同字段的文档定义一个类型

比如:我们假设运营一个博客平台并且将所有的数据存储到一个索引中,在这个索引中,你可以为用户数据定义一个类型,
为博客数据定义一个类型,也可以为评论数据定义另一个类型
  • Document
1) 一个文档是一个可被索引的基础信息单元
2) 在一个index/type内,你可以存储任意多的文档

比如:你可以拥有一个客户的文档,某一个产品的文档;文档以JSON(Javascript Object Notation)格式来表示,
json是一个通用的互联网数据交互模式
注意:虽然一个文档在物理上位于一个索引内,但是实际上一个文档必须在一个索引内可以被索引和分配一个类型

2.2.6 Shards and Replicas

  • The purpose of using sharding: In actual situations, the data stored by the index may exceed the hardware settings of a single node
例如,一个30TB的日志,无法存储在单个磁盘上,而且索引极慢。
为了解决这个问题,elasticsearch集群提供将索引分割开,进行分片的功能

1) 当创建索引时,可以定义想要分片的数量
2) 每一个分片就是一个全功能的独立的索引,可以位于集群中的任何节点上
  • Sharding advantages
1) 水平分割扩展,增大存储量
2) 分布式并行跨分片操作,提高性能和吞吐量
  • Copy advantages
1) 高可用,应对分片节点单点故障
2) 提高性能,增大吞吐量

3.Introduction to Logstash

3.1 Overview of Logstash

1) 由JRuby语言编写,基于消息(message-based)的简单架构,并且运行在java虚拟机上

2) 一款强大的数据处理工具,可以实现数据传输、格式处理、格式化输出

3) 工作思路:数据输入(collect)、数据加工(如过滤、改写等enrich)以及数据输出(transport)

4) 特点:不同于分离的代理端(agent)或主机端(server),Logstash可配置单一的代理端(agent)与其他开源软件
结合,以实现不同的功能

3.2 Logstash main components

  • Shipper: Log collection
    is responsible for monitoring the changes of local log files and collecting the latest contents of log files in time.
    Usually, the remote agent only needs to run this component

  • Indexer: Log storage
    Responsible for receiving logs and writing to local files

  • Broker: The log hub
    is responsible for linking multiple shippers and corresponding number of indexers

  • Search and Storage
    allows searching and storing events

  • Web Interface
    Web-based display interface

note:

  • The above components can be deployed independently in the lLogstash architecture, thus providing good cluster scalability

3.3 How Logstash works

Insert picture description here

  • Logstash consists of three parts: input, filter and output
input负责从数据源提取数据,

filter负责解析、处理数据,

output负责输出数据,每部分都有提供丰富的插件

3.4 Logstash host classification

  • Divided into: agent host and central host
1)代理主机(agent):作为事件的传递者(shipper),将各种日志数据发送到中心主机;只需要运行logstash代理程序

2)中心主机(central host):可运行包括中间转发器(broker)、索引器(indexer)、搜索和存储器(search & storage)、
web界面端(web interface)在内的各个组件,以实现对日志数据地接收、处理和存储

4. Kibana

4.1 Kibana Overview

1) 一个针对Elasticsearch的开源分析及可视化平台
2) 搜索、查看存储在Elasticsearch索引中的数据
3) 通过各种图标进行高级数据分析及展示
  • Features
1) 让海量数据更容易理解
2) 操作简单,基于浏览器地用户界面就可以快速创建仪表板(dashboard)实时显示Elasticsearch查询动态
3) 设置安装Kibana非常简单,无需编写代码,几分钟内就可以完成Kibana安装并启动Elasticsearch监测

4.2 Main functions

  • Elasticsearch seamless integration
  • Integrated data, complex data analysis
  • Flexible interface, easy to share
  • Simple configuration and visualization of multiple data sources
  • Simple data export

Guess you like

Origin blog.csdn.net/weixin_42449832/article/details/112296136