In today's digital era, website traffic and user behavior data is like a treasure that contains endless secrets. How to effectively mine and analyze these data has become a headache for many website managers and developers.GoAccessThe first is an open-source, real-time Web log analysis tool that may provide a window into these secrets.
GoAccess: your traffic analyzer!
GoAccessis a lightweight log analysis tool that helps users gain a deeper understanding of website traffic and user behavior through concise command line operations and an intuitive visual interface. It not only shows basic statistics such as unique visitors, requested files, 404 errors, etc., but also provides deeper analysis such as operating systems, browsers, search engines and HTTP response codes.
Starting from Scratch: Installing and Configuring GoAccess
GoAccessSupport a variety of download and installation methods, we recommend that you choose the appropriate way to install yourself according to the actual situation.
If you want to get the software package, you can reply to the keywords in the private comment.
goaccess
Automatic sending.
download and install
- Download and build from source code ()
- Package Manager for Linux Distributions
- Github development version
- Docker image containers
Configuring Usage
Once installed it is time to start using theGoAccessThe premise is to first confirm the format of the access log, and then configure theGoAccessto meet customization needs.
If you are using Apache or Nginx's standard logging format, configuring GoAccess will be simple.
# Common log-format format, more detailed custom log configuration please refer to the document!
# COMBINED | federated log-format
# VCOMBINED | Support for virtualized hosts with a common log-format.
# COMMON | Common log format
# VCOMMON | Common log format for supported virtual hosts.
# W3C | W3C Extended Log Format
# SQUID | Native Squid log format
# CLOUDFRONT | Amazon CloudFront Web Distributed System
# CLOUDSTORAGE | Google Cloud Storage
# AWSELB | Amazon Elastic Load Balancing
# AWSS3 | Amazon Simple Storage Service (S3)
# goaccess command to start
goaccess --log-format=COMBINED
# docker run --restart=always
docker run --restart=always -d -p 7890:7890 \
-v "/srv/goaccess/data:/srv/data" \
-v "/srv/goaccess/html:/srv/report" \
-v "/var/log/apache2:/srv/logs" \
--name=goaccess allinurl/goaccess
Of course, for common web log format , GoAccess has been preset to the corresponding log configuration , we can directly out of the box .
Hands-on exercise: analyzing Nginx logs
basic operation
To start analyzing Nginx logs with GoAccess, you first need to specify the path to the log file.
From the command line, enterfind / -name
Find the nginx log file, a common location may be/var/log/nginx/
.
Then use the same method to get the GoAccess configuration file location, and finally through the command line by typinggoaccess -f /var/log/nginx/
, GoAccess will read and analyze the specified log file.
Additionally, a configuration file path can be specified to use customized log formatting and display options.
# nginx log files
find / -name
# /var/log/nginx/
# goaccess configuration file
find / -name
# /etc/goaccess/
# Terminal to view Nginx logs
goaccess /var/log/nginx/ --log-format=COMBINED
Generating reports
GoAccess not only displays analysis results in real time, but also saves the results as a report in HTML format. With the commandgoaccess -f /var/log/nginx/ -o /code/log/
The analysis results can be exported to a specified HTML file. This allows the user to view a more aesthetically pleasing and easy-to-read report via a Web browser.
# static (as in electrostatic force)htmlreporting
goaccess /var/log/nginx/ -o /var/www/html/ --log-format=COMBINED
# (in) real timehtmlreporting: websocketDefault Binding 7890 ports
goaccess /var/log/nginx/ -o /var/www/html/ --log-format=COMBINED --real-time-html --daemonize
Real-time html reports need to be configurednginx
arrive at (a decision, conclusion etc)websocket
Support, dynamic real-time acquisition of log data Enabled7890
ports, the following examples are for reference only.
# increasegoaccess websocket service
location /wss {
proxy_redirect off;
proxy_pass http://127.0.0.1:7890;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
}
Check whether the page setup dot is green, is that the websocket connection is successful (title prompt Connected to wss:///wss:7890)
You can also see the result of the request via Browser-View-Network (status code: 101 Switching Protocols)
Of course, if you don't configure theWebSocket
Support, can be usedCron
Task scripts generate static reports at regular intervals, simulating the effect of real-time reports!
Deeper analysis: digging into the story behind the data
The GoAccess Analytics log output has a dozen items by default, press the down arrow to scroll the page to view them.
Independent visitors and requests for documentation
With GoAccess, we can clearly see the number of unique visitors to the site and the types of files requested. This data not only helps us understand how often users visit, but also reveals their preferences for specific content. For example, if an unusually high number of requests for certain types of image files are found, it may mean that users are particularly interested in this content.
404 Error and File Not Found
404 error is a common problem in website operation, which not only affects user experience, but also may affect search engine optimization. Through GoAccess analysis, we can find out the file paths that lead to 404 errors, and then optimize the website structure to reduce the occurrence of such errors.
Operating Systems and Browsers
The operating system and browser used by the user are also important metrics to analyze. With this data, we can understand the basic attributes of the users and optimize the compatibility and user experience of the website accordingly. For example, if it is found that most of the users are using Chrome, then the website should be designed with Chrome compatibility as a priority.
concluding remarks
In this data-driven era, GoAccess is not only a tool, but also a bridge that connects users and website operators. Through it, we can better understand user behavior, optimize website design and enhance user experience. Let's embrace data and light up the future with wisdom.