当前位置:网站首页>Elk enterprise log analysis system
Elk enterprise log analysis system
2022-06-11 15:51:00 【Richard_ Chiang】
ELK Enterprise log analysis system
one 、ELK brief introduction
- ELK The platform is a complete set of centralized log processing solutions , take ElasticSearch、Logstash and Kiabana Three open source tools are used together , Complete more powerful user query of logs 、 Sort 、 Statistical needs .
ElasticSearch:
ElasticSearch Is based on Lucene ( The architecture of a full-text search engine ) Distributed development Storage retrieval engine , Used to store all kinds of logs .
ElasticSearch Yes, it is Java Developed , It can be done by RESTful Web Interface , So that users can communicate with ElasticSearch signal communication .
ElasticSearch It's a real-time 、 Distributed and scalable Search engine , Allow full text 、 Structured search
ElasticSearch Usually Used to index and search large volumes of log data , It can also be used to search for many different types of documents .
Kiabana:
Kibana Usually with ElasticSearch Deploy together ,Kibana yes BlasticSearch A powerful data visualization Dashboard,
Kibana Provide graphical Web Interface to browse ElasticSearch Log data , Sure Used to summarize 、 Analyze and search important data .
Logstash:
Logstash As a log data collection engine . It supports Dynamically collect data from various data sources , And filter the data 、 analysis 、 Enrich 、 Unified format and other operations , then Store to the location specified by the user , Usually sent to ElasticSearch.
Logstash from Ruby Language writing , Running on the Java virtual machine (JVM) On , It's a powerful Data processing tools , Sure Realize data transmission 、 Format processing 、 Format output .Logstash It has powerful plug-in function , Commonly used in Log processing .
Filebeat:
Filebeat Lightweight open source log file data collector .
Filebeat It is usually installed on the client that needs to collect data Filebeat, and Specify directory and log format ,Filebeat Just Can quickly collect data , and Send to logstash To analyze , or Direct issue ElasticSearch Storage .
Filebeat Performance compared to JVM Upper logstash Obvious advantages , It's a replacement . Chang Ying be used for EFLK framework among .
Filebeat combination logstash Benefits :
- adopt Logstash With disk based adaptive buffering system , The system will absorb the incoming throughput , To lessen ElasticSearch Pressure to keep writing data
- From other data sources ( Like databases ,S3 Object store or message delivery queue ) Extract from
- Sending data to multiple destinations , for example S3,HDFS(Hadoop distributed file system ) Or write to a file
- Use conditional data flow logic to form more complex processing pipelines
- cache / Message queue (redis、kafka、RabbitAQ etc. ): Traffic peak shaving and buffering can be carried out for high concurrency log data , Such buffering can protect data from loss to a certain extent , You can also apply decoupling to the entire architecture .
Fluentd:
Fluentd Is a popular open source data collector . because logstash The disadvantage of being too heavy ,Logstash Low performance 、 More resource consumption and other problems , And then there's this Fluentd Appearance .
Fluentd Comparison logstash,Fluentd Easier to use 、 Less resource consumption 、 Higher performance , More efficient and reliable in data processing , Welcomed by enterprises , Become logstash An alternative to , Often applied to EFK Architecture .
Fluentd stay Kubernetes It is also commonly used in clusters EFK As a scheme for log data collection .
Fluentd stay Kubernetes In the cluster, it is generally through DaemonSet To run. , So that it's in every Kubernetes You can run one on a work node Pod.
Fluentd It gets the container log file 、 Filter and transform log data , And then pass the data to ElasticSearch colony , Index and store it in the cluster .
Ii. 、 Why use ELK
Logs mainly include system logs 、 Application logs and security logs . The system operation and maintenance personnel and developers can understand the software and hardware information of the server through the log 、 Check the errors in the configuration process and the causes of the errors . Regular log analysis can help you understand the load of the server , Performance security , So as to take measures to correct mistakes in time . Patrol the log regularly , Make countermeasures according to the error warning .
Often we use the log of a single machine grep、awk And other tools can basically achieve simple analysis , But when logs are distributed across different devices . If you manage hundreds of servers , You're still using the traditional method of logging in each machine in turn to look up the logs . Does this feel tedious and inefficient . We need to use centralized log management .
for example : Open source syslog, Summarize the log collection on all servers . After centralized management of logs , Log statistics and retrieval has become a more cumbersome thing , Generally we use grep、awk and wc etc. Linux Command can realize retrieval and statistics , But for more demanding queries 、 Sorting and statistics requirements and large number of machines are still using this method, which is hard to avoid .
Generally, a large system is a distributed deployment architecture , Different service modules are deployed on different servers , When problems arise , Most situations need to be based on the key information exposed by the problem , Go to specific servers and service modules , Building a centralized log system , It can improve the efficiency of location problem .
3 、 The basic characteristics of complete log system
collect : Be able to collect log data from multiple sources
transmission : It can stably parse, filter and transmit log data to the storage system
Storage : Store log data
analysis : Support UI analysis
Warning : Able to provide error reports , Monitoring mechanism
boss 、ELK How it works
(1) Deploy on all servers that need to collect logs Logstash, Or you can centralize the log management on the log server , Deploy on the log server Logstash.
(2)Logstash Collect the logs , Format the log and output it to ElasticSearch In a crowd .
(3)ElasticSearch Index and store the formatted data .
(4)Kibana from ES Query data in the cluster to generate charts , And display the front-end data .

summary :logstash As a log collector , Collect data from a data source , And filter the data , format processing , And then leave it to ElasticSearch Storage ,kibana Visualize the log .
wu 、ELK Deployment of log analysis system
Environment configuration
| host | operating system | IP Address | Tools / software package |
|---|---|---|---|
| node1 | CentOS7 | 192.168.80.20 | Elasticsearch/Kibana |
| node2 | CentOS7 | 192.168.80.30 | Elasticsearch |
| apache | CentOS7 | 192.168.80.50 | httpd / Logstash |
Experiment preparation
Turn off the firewall and system security mechanism

1、 To configure elasticsearch Environmental Science
node1(192.168.80.20)
node2(192.168.80.30)

2、 Deploy elasticsearch Software
node1(192.168.80.20)
node2(192.168.80.30)
(1) install elasticsearch—rpm package
Upload elasticsearch-5.5.0.rpm To /opt Under the table of contents

(2) change elasticsearch Master profile



- Verification configuration
(3) Create data storage path and authorize
(4) start-up elasticsearch Is it successfully opened

(5) View node information

(6) Verify cluster health status

(7) View the cluster status

3、 install elasticsearch-head plug-in unit
- install elasticsearch-head plug-in unit , be used for Management cluster
(1) Compilation and installation node Component dependency package
node1(192.168.80.20)
node2(192.168.80.30)

(2) install phantomjs( The front frame )
node1(192.168.80.20)
node2(192.168.80.30)


(3) install elasticsearch-head( Data visualization tool )
node1(192.168.80.20)
node2(192.168.80.30)


(4) Modify master profile
node1(192.168.80.20)
node2(192.168.80.30)


(5) start-up elasticsearch-head
node1(192.168.80.20)
node2(192.168.80.30)

(6) Use elasticsearch-head Plug in to view cluster status

(7) Create index
node1(192.168.80.20)
Create index as index-demo, The type is test

- Open the browser and enter the address , View index information

- Click data to browse – Will find node1 The index created on is index-demo, The type is test, Relevant information

4、 install logstash
Collect logs and output to elasticsearch in
(1) install Apahce service (httpd)
apache(192.168.80.50)
(2) install Java Environmental Science
apache(192.168.80.50)

(3) install logstash
apache(192.168.80.50)

(4) test logstash command
apache(192.168.80.50)

- Use rubydebug Show detailed output ,codec For a codec

- Use Logstash Write the information Elasticsearch in

- View index information

- Click data browse to view the content of the response

(5) stay Apache Make docking configuration on the host
apache(192.168.80.50)
- Logstash The configuration file consists of three parts :input、output、filter( According to need )

- View index information


5、 install kibana
node1(192.168.80.20)



- Access on Browser

- Then click the top left corner Discover Button Will find system-* Information

- Then click the following host Lateral add You will find that the picture on the right is only Time and host Options. This is friendly

(6) docking Apache The host Apache Log files ( Access log 、 Error log )
apache(192.168.80.50)


Open input on the browser http://192.168.80.50, Manufacturing point access record

Open the browser Input http://192.168.80.20:9100/ View index information
Can find apache_error-2022.03.01 and apache_access-2022.03.01

Open the browser Input http://192.168.80.20:5601
Click on the bottom left corner to have a management Options —index patterns—create index pattern
Create separate apache_error-* and apache_access-* The index of


summary
There are still some imperfections in this framework , So we can continue to optimize 、 Extended architecture , For example, expand to efk framework .
efk Architecture is made up of elasticsearch+logstash+filebeat+kafka+kibana+redis constitute , among elasticsearch For indexing and storing data ;logstash For format conversion ;filebeat( Lightweight file collection tools ) For log collection ;kafka( Message queue , It can process hundreds of thousands of concurrent data per second )+redis( Caching services ) Used to resist high concurrency ;kibana For the display of front-end data .
边栏推荐
- Code farming essential SQL tuning (Part 2)
- Shutter-- page Jump animation
- Verification code is the natural enemy of automation? Ali developed a solution
- It's really not human to let the express delivery arrive before the refund
- 让快递快到来不及退款的,真的不是人
- Overview and example analysis of opengauss database performance tuning
- Maui introductory tutorial series (1. framework introduction)
- Export configuration to FTP or TFTP server
- The most egregious error set of tone codes
- Kaixia was selected into the 2022 global top 100 innovation institutions list of Kerui Weian
猜你喜欢

【愚公系列】2022年06月 .NET架构班 076-分布式中间件 ScheduleMaster的执行原理

码农必备SQL调优(上)

一文教会你数据库系统调优

Yiwenjiaohui your database system tuning

How to predict SQL statement query time?

dapr 思维导图
![[系统安全] 四十二.Powershell恶意代码检测系列 (4)论文总结及抽象语法树(AST)提取](/img/d9/67ad40ba63de8006b67e51b0c82a84.png)
[系统安全] 四十二.Powershell恶意代码检测系列 (4)论文总结及抽象语法树(AST)提取

使用Cloud DB构建APP 快速入门-快游戏篇

Learn how to parse SQL from kernel code

Everything about JS functions
随机推荐
DB4AI: 数据库驱动AI
The most egregious error set of tone codes
使用Cloud DB构建APP 快速入门-快应用篇
With an average annual salary of 20W, automated test engineers are so popular?
数据库密态等值查询概述及操作
How to predict SQL statement query time?
拿到20K我用了5年,面了所有大厂,这些高频面试问题都帮你们划出来啦
关于 JS 函数的一切
Using cloud DB to build app quick start -server
How to write elegant secondary classification for enterprise development [small case of meituan]
The third generation Pentium B70 won the C-NCAP five-star safety performance again
selenium--显示等待(中)--详解篇
Learn automatic testing of postman interface from 0 to 1
Overview and example analysis of opengauss database performance tuning
GO语言-值类型和引用类型
Overview and operation of database dense equivalent query
[0006] title, keyword and page description
Kaixia was selected into the 2022 global top 100 innovation institutions list of Kerui Weian
Daily blog - wechat service permission 12 matters
Connect to the database using GSQL