Log Collection
In order to ensure the stable operation of the business and predict the unhealthy risks of the service, the collection of logs can help us observe the current health of the service. In traditional business development, when there are not many machine deployments, we usually log in directly to the server to view and debug logs. However, as the business increases, services continue to be split.
The maintenance cost of the service will also become more and more complicated. In a distributed system, there are more server machines, and the service is distributed on different servers. When problems are encountered, We can't use traditional methods to log in to the server for log investigation and debugging. The complexity can be imagined.
tip
If it is a simple single service system, or the service is too small, it is not recommended to use it directly, otherwise it will be counterproductive.
#
Prepare- kafka
- elasticsearch
- kibana
- filebeat、Log-Pilot(k8s)
- go-stash
#
Filebeattip
xx is the path where filebeat.yaml is located
#
go-stash configuration- Create a new
config.yaml
file - Add configuration content
#
Start services (start in order)- Start kafka
- Start elasticsearch
- Start kibana
- Start go-stash
- Start filebeat
- Start the order-api service and its dependent services (order-api service in the go-zero-demo project)
#
Visit kibanaEnter 127.0.0.1:5601
tip
Here we only demonstrate the logs generated by logx in the collection service, and log collection in nginx is the same.