Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Using GoAccess to realize visual real-time monitoring of Nginx access logs

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1. Introduction to GoAccess:

GoAccess is an open source real-time Web log analysis tool with interactive view interface. Its core idea is to analyze and view the statistical information of Web server in real time. GoAccess supports the generation of complete real-time HTML reports and reports in JSON and CSV formats.

2. Install the required software packages for GoAccess in yum mode:

# yum install GeoIP-devel ncurses ncurses-devel wget epel-release

3. Compile and install GoAccess:

# wget https://tar.goaccess.io/goaccess-1.3.tar.gz

# tar-xf goaccess-1.3.tar.gz-C / usr/src

# cd / usr/src/goaccess-1.3

#. / configure-prefix=/usr/local/goaccess-enable-utf8-enable-geoip

# make & & make install

4. Configure environment variables:

# vim / etc/profile.d/goaccess.sh

Export PATH=/usr/local/goaccess/bin:$PATH

#. / etc/profile.d/goaccess.sh

# goaccess-V

5. Modify the nginx.conf configuration file:

# vim / etc/nginx/nginx.conf, confirm that the following configuration is enabled by default:

Log_format main'$remote_addr-$remote_user [$time_local] "$request"'

'$status $body_bytes_sent "$http_referer"'

'"$http_user_agent"$http_x_forwarded_for"'

Access_log / var/log/nginx/access.log main

6. Modify the goaccess.conf configuration file:

# cd / usr/local/goaccess/etc/goaccess/

# cp goaccess.conf {, .bak}

# vim goaccess.conf

Before modification

After modification

# time-format% H:%M:%S

Time-format H:%M:%S

# date-format% d/%b/%Y

Date-format d/%b/%Y

# log-format% h% ^ [% dvv% t% ^] "% r"% s% b "% R"% u"

Log-format% h% ^ [% dvv% t% ^] "% r"% s% b "% R"% u"

# log-format COMBINED

Log-format COMBINED

# addr 0.0.0.0

Addr 192.168.0.121

# daemonize false

Daemonize true

# port 7890

Port 7890

# pid-file / var/run/goaccess.pid

Pid-file / var/run/goaccess.pid

# real-time-html true

Real-time-html true

# ws-url goaccess.io

Ws-url 192.168.0.121

# log-file / var/log/apache2/access.log

Log-file / var/log/nginx/access.log

# config-file

Config-file / usr/local/goaccess/etc/goaccess/goaccess.conf

# output / path/file.html

Output / usr/share/nginx/html/goaccess.html

7. Run GoAccess on the console:

# goaccess / var/log/nginx/access.log

8. The backend generates data to the GoAccess interface in real time, and saves the analysis result as HTML:

# goaccess-p / usr/local/goaccess/etc/goaccess/goaccess.conf

Or # goaccess / var/log/nginx/access.log-time-format='%H:%M:%S'-date-format='%d/%b/%Y'-log-format=COMBINED-o / usr/share/nginx/html/goaccess.html-addr=192.168.0.121-real-time-html-daemonize

# ps-ef | grep goaccess

# ss-tunlp | grep 7890

Note: if you need to output real-time HTML, you need to open firewall port 7890

9. Browsers access http://192.168.0.121/goaccess.html

10. Use the ab command to conduct a stress test, simulate the visit, and observe whether the page value changes in real time:

# yum-y install httpd-tools

# ab-n 500000-c 20 http://192.168.0.121/

Note: help information can be obtained from https://goaccess.io/

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report