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
Linux builds NFS server In order to achieve data ...
Table of contents 1. Swap partition SWAP 1.1 Crea...
Web Application Class 1. DownForEveryoneOrJustMe ...
What is a transaction? A transaction is a logical...
Introduction Memcached is a distributed caching s...
The pagination component is a common component in...
Hello everyone, I wonder if you have the same con...
Recent product testing found a problem that when ...
This article shares the specific code of Vue to a...
Preface Every time you use Docker to start a Hado...
Nowadays, the screen resolution of computer monit...
Background: Make a little progress every day, acc...
1. Download from the official website and unzip h...
Table of contents Preface Check Constraints Creat...
Table of contents 1. Download 2. Installation 3. ...