1、 request-log-analyzer
request-log-analyzer這個工具是一個用ruby寫的gem包,它不僅能分析rails項目的訪問日志,還能分析nginx,apache,MySQL,PostgreSQL的日志,它能統計每個頁面的訪問次數,一天訪問的情況,還有來源分析等。
(1)安裝gem工具包
yum install rubygems -y
(2)安裝
request-log-analyzer包
gem install request-log-analyzer
gem install request-log-analyzer -p https://10.99.202.82:3128(如果需要使用前置代理)
(3)工具使用:(用日志文件作為參數)
request-log-analyzer access.log
request-log-analyzer access.log --format rails3 --output HTML --file report.html(輸出為HTML格式)
查詢分析結果輸出:
2、goaccess日志數據分析工具
(1)安裝基礎依賴包
yum install gcc-c++ -y
yum install glib2 glib2-devel GeoIP-devel ncurses-devel zlib zlib-devel
(2)安裝goaccess日志分析工具包
$ 不使用前置代理
$ wget https://tar.goaccess.io/goaccess-1.5.5.tar.gz
$ 使用前置代理
$ wget https://tar.goaccess.io/goaccess-1.5.5.tar.gz -e "https_proxy=https://10.99.202.82:3128" --no-check-certificate
$ tar -xzvf goaccess-1.5.5.tar.gz
$ cd goaccess-1.5.5/
$ ./configure --enable-utf8 --enable-geoip
$ ./configure(如果出錯的話)
$ make
$ make install
(3)Nginx日志數據結果輸出
① 第一種方式:直接輸出
goaccess -f access.log --log-format="%h %^[%d:%t %^] \"%r\" %s %b \"%R\" \"%u\"" --date-format="%d/%b/%Y" --time-format=%H:%M:%S
② 第二種方式:分析結果輸出為HTML格式
goaccess -f boot.log --log-format="%h %^[%d:%t %^] \"%r\" %s %b \"%R\" \"%u\"" --date-format="%d/%b/%Y" --time-format=%H:%M:%S --hour-spec=min -o /home/nginx-log.html
