Nginx logs can be used to analyze user address locations, behavior profiles, etc. How can we use Elastic Stack to perform one-stop data collection, data cleaning, data landing, and data visualization to make the data truly valuable? Architecture Design In the Elastic Stack, Filebeat is used to collect Nginx-related logs, Elasticsearch is an engine for data storage and search, and Kibana is a tool for data visualization. In Nginx, the relevant logs are stored in the /var/log/nginx directory, namely the access log access.log and the error log error.log. If it is a bare metal environment, you can directly install Filebeat on the same host to collect log files. There are different collection solutions for different scenarios. Some can use Daemonset to collect logs on the host, while others can use Sidecar to collect logs, depending on the business scenario. Implementation Methods Take Docker environment as an example Nginx Create a storage volume to facilitate the joint mounting of Nginx and Filebeat containers Start the Nginx container and map the storage volume to the log directory Enter the container to modify the configuration Since the default log in the container environment is output to stdout, cancel this setting and specify a file Filebeat Start the Filebeat container and map the storage volume to the data directory Enter the container to modify the configuration Modify the configuration and add the hosts for Elasticsearch and Kibana filebeat.config: modules: path: ${path.config}/modules.d/*.yml reload.enabled: false processors: - add_cloud_metadata: ~ - add_docker_metadata: ~ output.elasticsearch: hosts: 'elasticsearch:9200' username: "elastic" password: "xxx" setup.kibana: host: "kibana:5601" Enable Nginx collection module Edit Nginx collection configuration - module: nginx access: enabled: true var.paths: ["/data/access.log*"] error: enabled: true var.paths: ["/data/error.log*"] Set up Filebeat to create an Index Pattern and Dashboard on Kibana Restart Filebeat to take effect Visualization Use the Dashboard function in Kibana to display Nginx's access to logs, user address location, and browser information Displays Nginx's specific request information for access logs and error logs You may also be interested in:
|
<<: Summary of the pitfalls you may not have encountered in WeChat applet development
>>: A problem with MySQL 5.5 deployment
Preface: In the daily use of the database, it is ...
Previous words Line-height, font-size, and vertica...
1. Float: The main purpose is to achieve the effe...
Recently, our small team needs to share a shared ...
step: 1. Create a new docker-compose.yml file in ...
Vue stores storage with Boolean values I encounte...
Today we will learn how to use CSS to create a co...
I wrote a jsp page today. I tried to adjust <di...
Introduction to CentOS CentOS is an enterprise-cl...
8 optimization methods for MySQL database design,...
Problem phenomenon: [root@localhost ~]# docker im...
mysql obtains statistical data within a specified...
Table of contents As attribute and property value...
The earliest computers could only use ASCII chara...
"Page screenshot" is a requirement ofte...